Recently there has been an Arduino Robot competition organised by RobotChallenge. The best 10 ideas were rewarded with an Arduino Robot for building and presenting their project at the event (RobotChallenge 2014, Vienna, Austria). My team (Massimo, Riccardo, Ivan, Luca, Antonio, Roberto and me) in CREATE-NET submitted the RoboPet, which made it to the 10 finalists!. The idea is simple:
1) The Arduino Robot is equipped with a laser pointer that can be pointed to different directions using two servos.
2) An Android phone in interfaced with the Arduino Robot for allowing the remote control of the robot and the laser pointer.
3) The phone provides also live video feed of the robot.
We decided to use WebSockets for the communication between the Android phone and for making the video feed available in the user’s browser (through WebRTC).
This is how the architecture of the system looks like:
After a very short time we received the Arduino Robot:
The first thing we tried was check how to move the robot in different directions. It turned out this was the easiest part. The following Arduino code snippet demonstrates how to move the robot forward, left, right and backward:
//read the motor speed from the potentiometer on board: int val=map(Robot.knobRead(),0,1023,-255,255); Robot.motorsWrite(val,val); // move forward delay(2000); Robot.motorsStop(); // fast stop delay(1000); Robot.motorsWrite(-val,-val); // backward delay(1000); Robot.motorsWrite(0,0); // slow stop delay(1000); Robot.motorsWrite(-val,val); // turn left delay(2000); Robot.motorsStop(); // fast stop delay(1000); Robot.motorsWrite(val,-val); // turn right delay(2000);
Note on Arduino Robot wheels movement: Despite it being easy to program, after some time we noticed that the Arduino Robot has issues with the wheels, preventing it from moving properly. We have tried different surfaces, performed wheel calibration but the Robot in many cases fails to move properly (especially to turn left or right). Also, looking at the Arduino forum, the wheels movement issue does not seem very uncommon, see here and here.
Next step was to find ways to interface the Robot with the servo motors and the Bluetooth module for communication with the Android phone. This was the toughest part and one of the main reasons we had to ask for a delivery date extension from the competition organisers. The reasons:
a) serious lack of documentation on Arduino Robot (we even posted questions in the official Arduino forum but got no feedback until this day). The only online resources available for the Arduino Robot is this page, that contains generic info on what the Robot can do, but without proper documentation on how to do it! For example, there is a reference about 6 PWM pins available on the control board and 2 on the motor board, but there is no indication where to find these pins!
b) Although Arduino Robot in fact consists of two Arduino boards connected to each other, there is a lack of available pins for interfacing with networking modules, especially when it comes to serial communication. Many digital pins are available, but SoftSerial on Arduino Leonardo (same MCU chip with the Arduino Robot) operates (the Rx) only on specific pins, that on the Arduino Robot happen to be used by the TFT screen.
So the only way to proceed was to remove the screen and use the MOSI pin to connect it as Rx pin to the Bluetooth module. We used a BlueSMiRF module for the wireless communication between the Arduino Control board and the phone. Initially the SoftSerial library was throwing compilation errors when selecting the Arduino Control as a target device, so we had to tinker a bit with the library itself and some header files for the Arduino Robot.
In the meantime, Riccardo was preparing the laser pointer by disassembling an ordinary laser pointer, attaching wires to get power from the robot board and mounting it on top of 2 servos for pointing it at X and Y axis:
To keep the complexity low, Riccardo added a random laser movement function in the Arduino sketch. We then mounted the servos with the laser pointer on the Arduino Robot. We also added a metal holder for attaching the phone:
The phone runs a background service that connects to the Bluetooth module and sends commands that are received over a WebSocket connection. At the same time it runs a webpage connected to a WebRTC video streaming session that is transmits the video from the front phone camera to any client subscribed to that stream (a webpage or another smartphone device).
The Arduino receives the commands over the SoftSerial pins through the Bluetooth module and interprets them to move forward, backward, left, right and on/off for starting the laser pointer.
All source code for the Arduino, Android and the WebRTC/WebSockets part can be found here. A demo video will follow soon.