Saturday, December 29, 2012

BugBot

This project was based off a chapter in Arduino Robotics (click here for Amazon link).  The bugbot sports five touch sensors, two antennae on the front and three bumpers on the back.  All of these sensors are momentary switches which drop low (digital zero) when pressed and remain high (digital one) when unpressed.  I also added a switch which allows the robot to switch between an autonomous mode utilizing the five sensors, and a joystick operated mode which reads data from a Processing sketch and passing this along to the Arduino.  A serial connection using Xbees passes the data from a computer with the joystick attached to the robot itself.



A big focus of this project for me was learning some basic CAD.  I used SolidWorks to create all the relevant parts including the Arduino, two continuous motion servos, a battery box from an old VEX kit, two wheels from the VEX kit, two casters bought from Home Depot, and various hardware (switches and screws).



When all the parts were created separately, I added them to an assembly along with a base I had created.  Then I used Solidworks to help me locate holes on the base so that all the pieces would be in the right places.  I was able to figure out how to export the CAD file for the base as a DXF file (you can download the DXF file for the base here) which could then be easily imported into Corel Draw and sent to our laser cutter.




The base turned out great and all the components were easily assembled onto it.  It was cool for me to be able to see the robot conceptualized first digitally and then realized in the real world.

All the CAD files I used or created can be downloaded by clicking here.



I also used Eagle to layout a simple PCB board for all the electronics.  This board is super clunky because we only had a 0.1" mill bit at the time, and so I was not able to space the lines as close as they would have needed to be in order to mount headers to match the Arduino inputs/outputs.

The electronics schematics for this project are shown below.  The Eagle schematic may be confusing because I used random parts, such as a SPST switch, to represent other parts, such as a servo.  Resistors actually represent the sensors.  The Eagle PCB files can be downloaded by clicking here.




The antennae are just copper wires wrapped around a pen.  One end is shaped into an antennae, and the other end is first soldered to a wire, then epoxied to the base.  The other end of that sensor is a bolt which has a wire soldered to it.  When the antenna is pushed, the copper wire shorts to the bolt.  When the antennae is released, it springs away from the bolt again.



The bumpers on the back are momentary switches from Radio Shack.  I took a lot of care to fashion simple metal brackets in order to securely mount the momentary switches.  Then I made bumpers by shaping aluminum with handtools, making two tabs at each end of the bumper.  The tabs have a through hole for a thin steel rod which also goes through two laser cut pieces affixed to the base and through the top of the momentary switch.  The rod holds the bracket at the perfect distance from the momentary switch so that any contact with the bumper at any point along its length presses the momentary switch.


The continuous rotation servos were epoxied to the bottom of the base in spots that were precisely located by etching done by the laser.  This ensures that the two wheels are directly across from each other and exactly parallel to each other.  The VEX wheels were affixed by drilling holes through the wheels and servo hubs, attaching the servo hubs to the wheels, then attaching the servo hub to the servo with the servo screw.


The code has two parts, only one of which executes at any time depending on the position of a mode switch.  The autonomous code stops when any sensor is tripped, backs up for a short time period, turns for a short time period, then continues forward.  It turns away from the side of the sensor that was tripped.  Once a certain number of trips has happened, it reverses its "front" and begins using the set of sensors that were previously on the back.  In other words, the bugbot switches between using the antennae or the bumpers.  Check out the video to see it in action.

The joystick controlled code reads values passed by an associated Processing sketch.  The Processing sketch connects to the Arduino via Xbees, reads a Logitech Controller, maps the joystick values to servo pulses  (between 1000 and 2000 microseconds), then passes to the Xbees.  The values are passed as strings, then processed by the Arduino to separate the joystick value itself from a header ($R or $L for right or left) and a footer (Z).  Both code files can be downloaded by clicking here.

You can view the Arduino code file by clicking here.
You can view the Processing code file by clicking here.

The video below shows the joystick controlled BugBot in action.

No comments:

Post a Comment