Potato Pirates 3: Battlechips – The Greatest Treasure of ‘Em All! For those of you who read my previous post, you’d...Read more
Hello curious tinkerer! If you’re new to the Sphero RVR, you could check out my first review on it here for an overview of what the RVR can do right out of the box. If you’re looking to do more with the RVR, then read on!
As I’d mentioned in the previous post, the RVR is Sphero’s first robot that’s made to be expandable and compatible with 3rd party electronics. For the engineering novice like myself, three of these immediately come to mind: micro:bit, Arduino and Raspberry Pi. These allow you to immediately add more functionality to your RVR (without having to take it apart) For this review I focused on what can be done with Arduino and RPi, if you want a sneak peek at using the micro:bit with the RVR, you can head over here
Having already played around with the Sphero’s highly intuitive Edu App, I decided I wanted to explore further. I looked up Sphero’s official website and youtube channel for inspiration, and googled all over to see what cool things other people have already come up with.
Cool project ideas that could potentially be done with the RVR include: robotic arms, flamethrowers even a parachute?? However I soon found out that things aren’t quite as straightforward as they seem, and there are some barriers to entry for the average user.
Access to these add-on parts can be costly. RVR add on kits offer some pretty cool features like GPS, but it does come with a hefty price tag too. To assemble a similar assortment of parts on your own would require some engineering background knowledge, and a lot of trial and error. (The covid situation is not helping that electronics shops are not open at this time!)
Access to fabrication tools like 3D printers.
The next alternative to buying these kits is of course to make your own! Unfortunately, I didn’t have a 3D printer on hand, so I had to turn to whatever materials I was left with at home.
Coding proficiency and availability of documentation.
Granted, the Sphero team has put up a (non-exhaustive) list documenting how to use some pre-built commands, but a lot more knowledge is needed to connect the dots between RVR and RPi / Arduino. Being a novice at Python myself, a lot of errors that popped up throughout the course of doing this review were foreign to me! (Stack Overflow is a big help)
First off, I had to setup VNC to use the RPi remotely, because the SSH as suggested on the SDK website only allows sending and receiving from the Terminal and no monitoring. Then, the problem that I found to be the most time-consuming was getting the serial communication between my Arduino UNO and RPi to work as intended, and then figuring out how the electronics all worked together with the RPi. Finally, I had to look briefly into Asynchronous programming as well to understand what was happening with the Sphero SDK library, though I won’t be touching on that here.
My (Mis)adventures with the Sphero RVR
My codes can be found here for anyone curious to look!
These are the projects I had in mind to try for this review! (With limited success)
Ultrasonic-sensor controlled RVR that moves autonomously in a confined space while avoiding obstacles!
The sample code can be found on the SDK site, however I couldn’t connect the Arduino nor the HC-SR04 sensors (both use 5V) directly to the RPi (3.3V) via I/O pins because that would damage the RPi. Since I didn’t have resistors on hand at the time such as in the suggested diagram, (but had many arduinos LOL) I had to learn how to interface the Arduino with the Raspberry pi via USB This tutorial was a good reference point for me, but instead of a simple LED “blink” I needed the Arduino to send turning commands over to the RVR.
Here’s how my setup looked like:
And here is a Video of a test run
As you can see I was far from turning the RVR into an autonomous vehicle😅
Issues I encountered
- Higher latency of serial communication (a result of interfacing RPi with Arduino) makes the turning “jerky”. This means that instead of the sensor data going directly to the RPi to tell the RVR to turn, it goes to the Arduino first which then sends the data over Serial Port to the RPi which then has to decode this data. This additional step introduces lag between each turning command and causes jerking.
- Didn’t have a way to mount sensors in front of the treaded wheels. The RVR collides with the red speaker @0:16 and pushes it out of the way because the wheels don’t “see” 👀 the obstacle. In hindsight, a cardboard mounting platform to position the sensor in front of the tread may be workable.
- Calibrating the threshold value for the sensor: Too low and the RVR will turn late (wheels get stuck) Too high and it will turn early as shown where instead of going straight it turns to avoid the box on the left, collides with red speaker. I had trouble finding the sweet-spot between low and high.
Controlling the RVR with Playstation Game Controller
What can be cooler than piloting your robot with a game controller? These guys have shown that it’s totally possible Unfortunately, there’s nothing much for me to show on this…I had tough luck trying to connect my wireless controller to the RPi via Bluetooth. After going through all the steps and googling all about Bluetooth my PS4 controller still wouldn’t stay connected.
So instead I settled for the Keyboard Control sample project on the Sphero SDK site, which went quite smoothly compared to the Ultrasonic one, save for 2 main issues:
1. I didn’t know the Python script MUST be run from the Terminal like so
otherwise it would throw an error “inappropriate ioctl for device” which was a total headache to debug because there are countless possibilities as to why such an error message would appear.
2. Understanding how imports work in Python was critical. The Keyboard Control script wasn’t able to access the files from the Sphero SDK library initially because I wasn’t using the right path. I wanted to see if this code could be adapted to do other things, such as sending commands to other external hardware (like motors). Which led me to the next idea…a robotic arm!!
Lego Robotic Arm
There were many DIY robotic arms out there that served as my inspiration. Most are 3D printed, but also there were some made of wood and cardboard, but I didn’t have access to a 3D printer or woodworking tools, and cardboard meant hot-gluing to the RVR and electrical components (I can’t have it be permanent, duh). All of them made use of servo motors which I had on hand, but I needed to source for other materials, so like any robotics budding hobbyist - I turned to Lego. Borrowing parts from a Lego Technic crane set, I made an arm that was able to rotate along the horizontal plane, and a pulley system of sorts that hoists an electromagnet (mimicking an actual crane like the kind in scrapyards)
Here’s how it looked like with 1 servo motor for rotation:
and a close up view on how the motor was attached to the Lego
My original intention was to make a robotic arm with the electromagnet right at the tip, but the magnet I had on hand was too heavy and doing so was likely to unfasten the arm from the RVR. So I decided to pivot and make a crane-arm instead which lowers the magnet instead of reaching out. (this kept the arm’s centre of gravity close to the RVR)
Here it is again but this time with the complete pulley system (2nd servo motor, gears and electromagnet)
Issues I encountered:
This project was the most challenging yet, because it involved structural considerations too on top of having to figure out how to program it. I had to design the Lego portion on the fly. On top of that the electromagnet was not performing up to expectations. Suspecting that it was because of the 12V rating (whilst the output voltage of the Arduino is only 5V) I tried to bump it up using a transistor, as shown in this excellent tutorial However, it didn’t work as expected, and the increase in magnetic force was negligibly stronger or possibly even worse than before. I later read in forums that it could have been due to the choice of transistor used (a BJT instead of MOSFET), though I didn’t have the latter on hand to try it out, so I dropped that altogether.
Albeit less than ideal magnetic power and precision in picking up stuff, it worked in the end (after much painstaking trial and error)!
Here is the final result:
- Introduction by Kristofer Maddigan 2017
- Steel Sting by Jeremy Wakefield 2001
- MC Hammer by Michael Keller, Louis K. Burrell, James Earley, Felton C. Pilate II, MC Hammer, Rick Ross & Gucci Mane 2010)
The code used here was built off the keyboard control script mentioned above in the PS4 controller section (where the RVR can be driven using WASD). Here’s a full list of the commands and associated keys to better understand what’s going on:
I had fun doing these projects, although I learnt that fairly simple ideas might still pose a significant challenge to the novice maker, so be prepared for lots of debugging! The RVR is indeed capable of being modified and expanded with other electronics, but the efficacy of my projects were dependent on my programming and hardware knowledge. If doing maker stuff with the RVR is your cup of tea, be sure to keep an eye out on the Sphero community forum for others to share their cool project ideas (and for you to share yours too!)
MISC links that may prove useful
- https://pinout.xyz to see the RPi pinout! (note that RVR TX connect to RPi RX and vice versa)
- Docs for connecting ps4 controller to RPi: https://pes.mundayweb.com/html/Using%20PS4%20Control%20Pads%20via%20Bluetooth.html
- And if your bluetooth connection is buggy like mine and disconnects after awhile, try: https://www.raspberrypi.org/forums/viewtoPIC .php?t=268915
This review was written by Daniel Tang, currently studying Engineering Product Design, Computer Engineering Track at Singapore University of Technology and Design.