Friday, June 1, 2018

Hello World!

"Hello World" is the ubiquitous start to all things technical! It is the classic program that beginners write to understand what the most 'basic' program is. For the maker working with physical computing, "Blinky light" is stated as the "Hello World" equivalent. Now that we have makers by the droves jumping into Robotics and Mechatronics, what would be the bench mark for "Hello World"? Perhaps, it should be the ever popular "RC Car with Camera Rover".

Here is my "Hello World!" in Robotics.  "Polybot" - the Rover:

It is comprised of fairly standard components for this type of build:
  • Chassis of an old RC car. Removed all of the existing controller components. Kept the physical chassis, wheels, struts, drive motor, steering motor, and awesome bumper.
  • Raspberry PI for the brains.  Command, control, communications, video, etc.
  • Off-the-Shelf USB webcam
  • Double H-Bridge for motor control
  • Portable power: 4XAA battery pack for the motors, USB Power bank for the RPI
  • 3D printed frame to attach the RPI, Camera, and stow away the power bank
For hardware, this is a pretty basic set up. It does not get much simpler. One of the challenges for a beginner is how power is managed. In this case, by having a separate power source for the motors, separate from the RPI, solves the issue of having to use a Buck Converter to reduce the voltage for the RPI.

Of course, its the control of the Rover that makes it a Robot vs. a RC car. I used Python as the base language to set up the code to drive my Rover.  Python's control of the GPIO of the PI is simple enough to control the car. The drive software takes a simple command of forward/reverse, left/right/straight combinations. 

To add my own twist to the Polybot Rover, I decided to use MQTT as a protocol to communicate with the Rover and provide it with commands. This would allow me to create different clients that can provide the command signals to the rover.  By nature that would mean that the rover could be controlled by humans - or a massive Totally Not Evil Robot Army Controller, mewha ha ha. But, I digress.

To use MQTT, I created a 'Base Station' that hosted a Mosquito Broker. The Rover's command software is a MQTT Listener written in Python. And I wrote a Flask Web App, that uses Socket IO and MQTT Client to input the commands and publish them to the broker. 

The Flask, Socket IO, and MQTT are all Python libraries and easy to program. The interface used a simple 6 quadrant set of buttons for Left Forward, Forward, Right Forward, Left Reverse, Reverse, and Right Reverse. It also contained an input field to designate the 'distance/time' to be traveling. The MQTT messages were a very simple LF3 - Left Forward Three, command protocol.

One advantage of using Flask for the Web App is that it is immediately viable for use on a mobile device. The device just needs to be on the same Wifi Network as the Rover, and then connect to the Web App.

Web cam streaming, was provided by using FFMPEG to capture video from the camera and pipe it to stdout. This allows for the ability to create a lifestream on YouTube. This streaming ability has a significant lag, but it really cool to see your Rover on YouTube.  Cool, but not quite FPV! :)

The best part of doing a "Hello World" is that is gets you actually started 'doing it'!  Once you get comfortable with the very most basic, then you can start making your really cool ideas become reality.

There are lots of ways to take the Polybot Rover forward.
  • Add better portable power, with more energy for the motors
  • integrated streaming on the Web App
  • Status messages, Sensor feedback
  • Commands, servos, and actuators on the Rover.  Grippers!!
  • Autonomous control, AI
  • make 10k more rovers, and create a Totally Not Evil Robot Army (ma haha)!!
its only limited by imagination! :)

No comments:

Post a Comment