Entering the Well… Duh Zone: Refrigerator Magnet(ism)

My vehicle originally relied solely on odometry for dead reckoning, with rather poor precision for turns, which quickly leads to large errors. So I added an electronic compass for determining the heading. This didn’t improve things as much as I thought, with the vehicle often heading off in what was clearly the wrong direction. I determined that at least once source of the problem was sensor lag. When the vehicle pivoted in place to turn to it’s next heading, it turns fairly quickly, and the compass lags a fair bit. So the vehicle would overshoot the desired heading without realizing it. The technical term for this lag is rate dependent hysteresis.

To address this problem, I added a rough check on the heading, and if in the right ballpark, the vehicle stops, waits a bit for the compass to settle, then redetermines it’s heading. If not pointed in the right direction, it slowly turns by small increments, with pauses in between, until it is on the correct heading. This isn’t fast, but it seemed to work fine in preliminary tests in in my finished basement, which is carpeted. However the tracks didn’t get great traction when moving, while at the same time, had a lot of friction during turns. So, set the waypoints further apart and move to a wood laminate floor in the kitchen where the robot runs great. The result: worse then when using just odometry! The vehicle kept thinking it was veering well off course when it was traveling almost in a straight line, and the bearings were way off reality.

As you might guess from the title of this post, the problem is obvious in retrospect: lots of large metal objects in the kitchen, including the fridge about 18″ from where I was starting the vehicle. This threw the compass off by a fair bit. Once I realized this and retested outside, all worked fine.

Now that the compass is finally working, here are my plans:

  1. 1) Add PID control as the vehicle travels. Right now, it determines a heading, and drives off with equal power to both motors. It just runs open loop until either reaching the waypoint, traveling the calculated distance to the waypoint, or traveling a preset max. distance. At that point it checks its own location versus the waypoint and re-orients. This isn’t bad if running on an even surface, although it still tends to turn a bit. But if one tread slides or has different traction, it heads off in the wrong direction for some time. I want to close the loop with PID control.
  2. 2) Once that works, switch over or add a GPS for heading as an option, just to checkout the GPS unit and programming to interface to it. The main use of the GPS will be for a faster, outdoor autonomous vehicle to be developed after this.

An unseasonal post: Automating Halloween Props

This post is more suited to Halloween then the coming Yule, but I finally got around to writing it, and besides, as I write this, there’s only 327 days left to next Halloween!  There are several options for controlling animated props, including prop controllers specifically designed for this purpose.  A recent addition to the market is the MonsterShield, an Arduino-based prop controller with open source code you can modify.  I haven’t tried one out, but thought it was work a mention.  In my props, I just use a handy micro-controllers, such as an Arduino, along with sensors such as a PIR.  The PIR (or pressure mat, or whatever sensor you choose) sends a signal to the microcontroller when it detects someone, and then your microcontroller can trigger a whole sequence of pre-programmed actions.  I had two such props in my Halloween display this year.  The first is a classic “Monster in a Box“.  I use a PIR sensor to detect when someone comes near.  When this happens,a Teensy sends out an output to a Power Switch Tail to turn on the power to a wall wart that delivers 12V power to the windshield wiper motor, as well as to a green light inside the box.  I use a Power Switch Tail so that I don’t have to worry about any safety issues dealing with house current directly.  The motor sequence has several stops and stop in it, of differing lengths, so that the action is more natural.  After it triggers, there’s a dead time, so that it doesn’t keep restarting while trick-or-treaters are standing in front watching it.

Closed Monster in a box, showing the box with the PIR and Arduino that triggers the box.

Inside view of the Monster in a Box, showing the wiper motor and irregular cam.

 

The other prop where I use a PIR and an Arduino is my scarecrow skeletons, who do a little talking and singing routine when triggered.  Here, an Arduino controls two Cowlacious audio boards that in turn drive the servo boards that control the jaw servo and lights in the skulls (also from Cowlacious).  I’ve had the audio boards for some time.  They work fine, and have a wide host of control options (including the ability to be triggered directly from a PIR).  However if I was remaking this prop, I’d probably just wire up some really cheap mp3 players. The video shows the two skeletons doing their routine. Sorry for the quality, my video editor is refusing to save the edited version.