Tuesday, February 15, 2011

AVC Bot: A Deadline


The AVC bot is coming together slowly.  I am farther along than the blog posts would indicate because they lag the actual work by a few weeks.  Even so I've simply not made enough progress.

To give myself a kick in the butt, I've invited some friends over to witness the maiden voyage (and/or catastrophic failure) of the AVC bot on Saturday, February 26.

Crap, I gotta get busy now!

I owe Sparkfun a video of the robot driving forward and turning left on its own but if that's all the robot can do on April 1, I'm screwed.

But, if I have that functionality in two weeks, that gives me several more weeks to refine and build upon it so I'll have a functional robot come April 23, competition day.

The path ahead to the maiden voyage:
  • Port GPS NMEA parsing software to mbed
  • Port data logging software to mbed
  • Finish software for Kalman Filtering of gyro data
  • Build "motherboard" for mbed MCU to interface with the goodies
  • Implement 5V ADC to adapt IR rangers and gyro to 3.3V MCU
  • Software to calculate bearing and distance to waypoint
  • Software to manage the precise timing of sensor polling and navigation
  • Software to adjust steering and speed based on actual vs. desired heading
Even after I get all that done I'm still only about halfway home.

Friday, February 11, 2011

AVC Bot: First Data Captures

I still don't have a name for my AVC Robot. Got any ideas? Post them in the comments!

With the gyro, GPS, and SD card integrated with the Arduino, all the electronics stuck to a platform bolted to the RC chassis, and with code to grab the data and log it, all that was left was to strap down the GPS and take the truck out for a spin.

And that's just what I did. Even though it was 10:00pm...


You can see the GPS strapped to the back, the SD card up front, and the Arduino in the middle. I strapped the cheap LED flashlight I used in the picture above onto the front of the truck so I could see it in the dark.

I'm happy to report that I successfully collected logs that evening!  I repeated the experiment the following day around noon.  I wrote some simple perl scripts to parse the CSV files off of the robot's MicroSD card.

Here's the track plot from the next day (via GPS Visualizer and Google Earth). The GPS was reporting 15-25 feet accuracy. I have to say, the tracks are actually fairly close to reality.


But not close enough that the robot can rely on the GPS alone. You can see below that the tracks generated during bad GPS fixes are too far off for the kind of precision navigation required to circumnavigate the Sparkfun building. 



After this real world experience, it's even more abundantly clear to me why the AVC was hard for so many robots.

Incidentally, the GPS only updates at a 2 Hz rate instead of a more normal 1Hz rate. That's because it takes more than one second to send all the NMEA-0183 strings at 4800 baud. I can't change the baud rate, either.

Meanwhile, here's a plot of the speed as reported by the GPS during one of the daytime runs. If it's to be believed, the little RC truck can do about 18mph on a fresh battery. Cool!

The plot below shows mph on the y-axis and milliseconds on the X axis.


Here's the heading data from the GPS from one of the four daytime runs. Looks about right: I did a number of north-south runs, with quick turns in between. Note that the two outliers near 360 degrees are only a few degrees off from their neighboring points in the 0-10 degree range.


This is a plot of gyro data from another of the day runs. Wow. That is really noisy. I doubt I can use that kind of data for precision navigation!


The x axis plots time in seconds. The y axis is the gyro data, captured every 20-30ms and converted to degrees per second in this plot. The data looks like a mess.

You can see the truck was pointing in one, static direction up until about 6 seconds, then the heading rate change bounced all over the place, probably at the same time I started accelerating the vehicle.

Is the noise caused by mechanical vibration?  Electromagnetic noise?  Both?  Something else?

Yup, it's another cliffhanger!  You'll have to tune in next time to find out.

Friday, February 4, 2011

Robotifying an RC Truck

I've spent plenty of time playi-- err... experimenting with the RC truck I bought for the Sparkfun AVC.

And, I'd gotten an Arduino to control the steering and throttle, prototyped interfaces to a gyro, GPS, and SD card, and was ready to capture data, but before I could do so, it was time to modify the RC Truck and mount the control electronics more permanently.

I didn't want to drill a bunch of holes in the truck if I didn't have to and I wanted to keep a plastic body shell on the truck to protect the electronics from rollovers and weather.

I decided to use a sheet of Lexan® (polycarbonate) I had laying around as the base for the electronics, mounted to the RC truck chassis in a solid but non-destructive manner.

In the front of the truck, there is a plastic frame screwed into the top of the chassis, encapsulating the servo steering mechanism. I decided to use two of this frame's mounting holes as attachment points.

Luckily I happened to find a couple of longer screws of the exact size and thread pitch.  I needed longer screws to accommodate PCB spacers under the polycarbonate sheet.


As for the rear, I built a bracket out of sheet brass to fit over the rear body studs. These studs have two clip holes so I can clip down the bracket then clip the body on top of the bracket.


I have a tabletop sized Harbor Freight sheet metal brake that I used to get nice clean bends on the bracket.  I drilled the required 5 holes in the plastic using a step drill (I can no longer live without one!). Four holes for mounting, and one hole for the antenna.

I used the step drill for the brass bracket, too. Two holes for the studs, two for mounting to the plastic.

I stuck my breadboard to the plastic sheet and started working on protoyping.

I wanted a way to tie the microcontroller to the ESC / BEC and steering servo.  The Electronic Speed Control is the throttle. The Battery Elimination Circuit puts out a regulated 5V that can power the microcontroller and sensors.

I made a simple servo connector adapter using a Radio Shack copper clad perfboard, pin headers, and wire. Now I can plug the steering and throttle connectors into the microcontroller with ease. You can see it in the picture above, just left of center, in the foreground.

It's the gizmo with a bunch of orange and yellow wires and a black and red wire pair for power.  The black, red, and white servo wires are plugged into it.

A side project: The RC truck travels about 15mph and I already know from experience with Pokey that my robots have a penchant for crashing into things.  The RC truck robot won't be stuck in a maze so it might run into cars, cats, dogs, people...

To provide a remote kill switch, I wanted the robot to halt itself if I turn on the RC transmitter. I added one more 3-wire connector: from the microcontroller INT0 pin to the radio receiver.  That's the black, red, and yellow wire set are plugged into the receiver, which is the blue device in the center foreground.

I coded the microcontroller to interrupt if it sees a high signal from the radio receiver. When it does, it disables the throttle and steering and aborts operation.

With the electronics mounted securely, it was time for a test run to capture some data...