This week I have been focused on getting the control structure set up on the Sphero. The implementation revolves around reading from Standard Input and recording the key presses as they get recorded into the stream.
These two weeks I have been focused on translating the data I receive from the Sphero into something meaningful that I can use to generate a 2D graph. In this case I plan to use a mix of the odometer and key presses to generate direction and distance.
Using the odometer lets us get a feeling for how far we have traveled however the Sphero odometer works as if on a Cartesian plane in that 0,0 is the origin and any movement results in positive and negative values. Using this while also recording which key press was made last we can "reset" the origin and track a distance traveled in a certain direction. Add it all up and we can generate a full 2D graph.
Short Video showcasing the progress made so far!
Weeks 4 & 5I successfully got the data that was being recorded from the Sphero into a 2D representation of the distance It has travelled. On each key press I essentially detect whether or not I need to start a new line, this allows me to say whether or I am repeatedly pressing the same key or changing a direction. Once a direction change has been made I record the x and y values that were set at the time of the direction change.
Combine these two pieces of data together and you are able to apply the simple "tip to tail" approach that are used to draw vectors, since we now have a direction and magnitude.
While simple, below I have attached the first official floor plan that my app generated in the video below.
Ican now generate an albeit basic floor plan by driving around mySphero. Everything fromlearning the Sphero SDK to Node.js has been an absolute blast. Iwould say the majority of the problems I had stemmed from issues withblue tooth connectivity. The moment I generated a floor plan usingthe Sphero was definitelymy favorite moment as I got to see the project I have been working onactually create something. Usingthe Sphero'sodometer I was able to keep a track of the distance traveled and usedthe previous key press to determine the direction of movement andcombined that all to put together a floor plan.
Inthe video below I am showing off the various functions that I havecreated as well as the final floor plan that gets generated when I amfinished and hit the generate floor plan button.
Comments
Please log in or sign up to comment.