Sphero First Impressions:
It is incredible how mesmerizing the Sphero is. Whenever I find myself bored in my room, I take my Sphero for walks around the hallways of my dorm. Every person I see along the way stops to stare at the colorful ball with awe before beginning to chase Ball-e. Keep in mind these are college students. Yet even more remarkable is the ability to program the Sphero. I have spent this week acquainting myself with the JavaScript SDK. This gives me the ability to directly change colors, speed, and direction. From learning these functions, I have a better sense of how the Sphero works and am definitely looking forward to applying my programming skills towards a fun project taking advantage of Sphero’s capabilities.
About the Project:
It’s fun directing the Sphero down the street, over ramps, and in just about any formation. But what if the Sphero could direct you? Director turns the Sphero into a rolling guide that helps direct people where they want to go. This takes advantage of Sphero’s location detection and roll function to act as a moving guide. Get from point A to point B in style with Director for Sphero.
Week 3 Update:
To begin writing code for Director, I used the Node SDK to first connect the Sphero and then test basic functionality such as rolling the ball. I used the data streaming functions to gather location data about the Sphero, specifically the x and y coordinates. With this information about the Sphero obtained in code, I wrote helper functions to determine how to move the Sphero between two points. At this point, it includes calculating distance between two specified points and then rolling the Sphero from the first point to the second. See the roll_distance function below which takes the distance between two points to determine how long to roll the ball in what direction.
function roll_distance(x1, y1, x2, y2, speed){
d = distance(x1, y1, x2, y2);
time = d/speed;
direction = Math.toDegrees(Math.atan2(y2-y1, x2-x1));
setInterval(function() {
orb.roll(speed, direction);
}, time);
}
Week 4 Update:
This week, I worked on moving the Sphero between multiple coordinates. This required some refactoring of last week’s code by improving the functions and supporting additional inputs. I wrote functions to take in coordinates and add them to a list. Then I set up a for loop to iterate through the points.
Coordinate:
function coordinate(x, y) {
this.x = x;
this.y = y;
}
function add_coord(x, y, arr){
arr.push(new coordinate(x, y));
}
Mutliple Coordinates:
for (i = i; i < coordinates.length; i++){
curr_x = data.xOdometer.value[0];
curr_y = data.yOdometer.value[0];
roll_distance(curr_x, curr_y, curr_x + coordinates[i][0], curr_y + coordinates[i][1], 180);
console.log("i: ", i, "(x,y): ", data.xOdometer.value[0], ",", data.yOdometer.value[0]);
}
Week 5 Update:
This week, I improved the code concerning direction calculation and traveling between coordinates. In addition, I worked on creating a front-end interface for the user to be able to enter coordinates. This is a screenshot of my progress so far. The goal is to have the user enter coordinates and then a path will be drawn to move from each coordinate to the next. The Sphero will then move along the specified paths.
Week 6 Update:
This week, I added to the website I began working on last week to help users enter coordinates to direct the Sphero. The user now sees the entered coordinates appear on a coordinate grid on the bottom part of the webpage. In addition, a line is drawn between coordinates in the order they are entered and tooltips appear when the mouse hovers over a point.
I have also started to integrate the site with Azure. I am looking to be able to host this website on Azure to be easily accessible.
Week 7 Update:
This week, I successfully hosted my website on GitHub at https://gracelu.github.io/! See my new repository for this website at: https://github.com/gracelu/gracelu.github.io. I also worked on connecting the web interface with the back-end code that actually moves the Sphero. I ran into some issues when trying this as the web interface is client facing, which limits the code that is run in browser especially for requiring Javascript modules and connecting with ports. I installed some great packages to work through these issues but am still trying to get the back-end code working with the web interface.
Showcase!
Director is an application that allows a user to enter coordinates to direct a Sphero and then have the robot ball roll along the chosen path. The front end consists of a web interface application to input the coordinates; the back end uses the Node SDK for Sphero. All the code is written in JavaScript. To build this app, many challenges were overcome, including navigating the Node SDK to move the Sphero and running the JavaScript code in a client-side webpage. Working through the issues that arose required constant trial and error. Overall, this project allowed me to gain great exposure to a variety of different technologies in working to create the application. As with any project, there are still improvements that can be made. The initial idea was to create a Windows phone app and integrate with GPS coordinates. I will continue to work on these features and may stumble upon new ideas to add to the current project or create another one!
Director is an application using the Sphero and its Node SDK to direct the robotic ball along a chosen path: https://www.youtube.com/watch?v=Ye2RGEiCXsw
Comments
Please log in or sign up to comment.