HUL-10, Version 2

[Update: we won third place!]

Introduction

HUL-10 is a robot the Super Joiner Bros. and I are building for the Make: Robot Build contest. We built version 1 to get something working in a short amount of time. This post describes the changes in version 2, which improves on version 1 and will be our final submission for the contest. The changes in version 2 include a new chassis, improved obstacle avoidance, and phototropic behavior.

Be sure to check my Flickr stream for more photos and video.

Component List

The majority of the components are the same as version 1. The new components are emphasized in italics.

  • 10 CDs
  • 2 rubber bands
  • Small caster wheel
  • ShapeLock plastic
  • Stiff wire (10 gauge aluminum, I think)
  • 3/8″ plastic conduit
  • Miscellaneous hardware (screws, nuts, standoffs, etc.)
  • Arduino Nano v3
  • Half-size protoboard and jumper wires
  • 2 GWS S35 STD continuous rotation servos
  • 2 Sharp GP2D120 IR sensors
  • 2 photoresistors
  • High-intensity green LED
  • 4 AA NiMH rechargeable batteries and battery holder
  • Dimension Engineering AnyVolt Micro switching DC-DC converter
  • Passive components (100 Ω resistor, 3.3 kΩ resistor, 10 kΩ trim pot, 2200 μF capacitor)

Design Changes

Chassis

The version 1 chassis was functional and had some style, but for version 2 we wanted something really cool. The new chassis is a slatted cage that contains the electronics, topped with a small dome and antennae supporting the IR sensors. The whole thing is backlit from the inside with the Arduino’s blue LED and a high-intensity green LED. We scratched a HUL-10 logo on the top CD so that it is also backlit from the LEDs.

The cage is made from the outer rings leftover from cutting the wheels. The dome was made from ShapeLock, and the antennae are made from stiff wire and corrugated plastic tubing.

We wanted to make version 2 a little faster than version 1, so we fabricated larger wheels. I used the same CD spindle jig from version 1 and drilled a new hole in the base for cutting the larger wheels.

We replaced the ShapeLock servo mounts with a wood brace (painted black). This is a simpler solution, and also solves the problem we were having with the base CD sagging. We mounted the batteries and a small power switch on the bottom of the base CD as well.

Electronics

User eckern on the Make: Robot Build forum let me know that the L293 driver was not necessary since the servos have built-in drivers. This made sense, and I confirmed it by measuring the current on the servo input signal (very tiny) and power (~100 mA). Version 2 drives the servo input signal directly from the Arduino digital pins and provides power to the servo through a direct connection to the batteries (not through the 5 V regulator). Removing the L293 freed up a lot of room on the protoboard.

We added two photoresistors for phototropic behavior. I soldered long protoboard wires to the leads and used heatshrink tubing for insulation and strain relief. Each photoresistor is connected as the pull-up side of a voltage divider. The right photoresistor has a 3.3 kΩ pull-down. This value was chosen to maximize the voltage range at the A/D under typical lighting conditions. The left photoresistor has a 10 kΩ trim pot as the pull down. The trim pot allows us to compensate for the manufacturing variation that is present in photoresistors. To perform the one-time calibration, we subjected both photoresistors to the same light level and adjusted the trim pot until both voltage dividers had the same reading. We also verified that they remained in sync as the lighting conditions changed.

Software

If anyone is interested, I have released the source code for HUL-10, version 2.

The obstacle avoidance algorithm in version 1 used the IR sensor readings to independently adjust the speed of the servos; the basic idea was: the closer an object is, the sharper we turn away from it. This works very well, but could occasionally get stuck in corners when the distance to each IR sensor was such that both wheels would stop turning. I addressed this by only allowing one wheel (determined by the closest detected object) to slow down. Thus, in the same situation where the version 1 algorithm would stop both wheels, the version 2 algorithm always keeps one wheel turning.

This fix worked well, but accentuated a second problem: when in a corner, the robot would oscillate left and right, unable to figure out which way to go. I solved this problem by implementing a “hard turn” mode. If an object is closer than the “enter hard turn” threshold, we do not allow turning in the other direction until both sensors detect that no object is within the “exit hard turn” threshold. The exit threshold is farther away than the enter threshold in order to provide some hysteresis and guarantee that we’ve avoided the obstacle. The effect of this algorithm change is that instead of being confused, the robot commits to a turn direction until it has successfully navigated the corner.

New in version 2 is a phototropic algorithm that uses the photoresistors to make the robot navigate toward light. The algorithm is based on a few simple principles. First, obstacle avoidance takes priority over phototropism. Second, the phototropism is based on the difference between the readings of the photoresistors; this allows the algorithm to perform consistently under different light conditions. Finally, the motors are adjusted based on the principle: the larger the brightness difference, the sharper we steer toward the light.

Results

This little robot is a lot of fun. We like to switch him on and run around putting things in his way or build mazes for him. The obstacle avoidance is pretty good, and the only time he gets stuck now is when he runs into objects in the sensor blind spots.

The phototropic behavior works well too. You can use a flashlight to guide him around, but even without a flashlight he detects shadows and bright spots on the ground and navigates around them. I wrote and tested a random motion algorithm to make him wander, but the phototropic algorithm makes it unnecessary: there are enough shadows and bright spots in a typical room to make him appear to wander from phototropism alone.

One interesting effect we observed has to do with HUL-10′s shadow. When driving away from a bright overhead light or window, he casts a shadow that sometimes falls on one photoresistor but not the other. This causes him to gradually turn back toward the light source (assuming there are no obstacles in the way).

Improvements

One thing was clear to us as we were finishing HUL-10 version 2: we’re going to have to build version 3. We still have several ideas we want to experiment with; plus, we’re already seeing ideas on other people’s coasterbots that we want to try.

  • Add a speaker and some sounds to give him even more personality.
  • Modify the chassis or build a new one, borrowing ideas from simplebot’s Crepton (low profile, wheels inside CD perimeter, spindle case).
  • Add bump sensor(s) to get out of situations when the obstacle avoidance algorithm fails.
  • Experiment with monitoring servo current as a bump sensor.
  • Experiment with ultrasonic sensors.
  • Experiment with using more distance sensors or maybe a rotating sensor.

Power Budget

The following table of current draw was completed using the component datasheets and measurements made during operation. Conversion from the switching supply to the batteries assumes 75% efficiency.

Component Switcher Current (mA) Battery Current (mA)
Typical Max Typical Max
Arduino Nano 25 30 33 40
2 IR Sensors 54 54 72 72
2 Photoresistors 0 4 0 5
Green LED 20 20
2 Servos 200 300
AnyVolt Micro (quiescent) 15 32
Total 340 469

Our rechargeable batteries are rated for 1850 mAH, so we can expect 4-5 hours of run time from a full charge.

Posted in Uncategorized | Tagged , , , , | Leave a comment

HUL-10, Version 1

Introduction

Just because I don’t have enough hobbies and projects, the Super Joiner Bros. and I have entered the Make: Robot Build contest. The goals of the contest are:

Build a “CoasterBot,” a mini robot development platform using CD/DVD media as the main body components. Create a robot that has the ability to navigate a space on its own, avoiding obstacles, and that has the ability to have additional sensor systems (proximity, heat, light, sound, etc.) added “on top” of this base behavior.

Our goals for this project are:

  • Participate in the contest
  • Learn about robots
  • Build a platform that we can use for future robot experiments
  • Have fun

We are building our robot in two versions. The goal of the first version is to get something simple working quickly. In the second version, we will improve our design. This article describes the first version.

Be sure to check my Flickr stream for more photos and video.

Design

Our robot is named HUL-10 (pronounced Julio). It has two wheels with independent servo motors, a microcontroller, and two infrared sensors for detecting obstacles.

Component List

  • 10 CDs
  • 2 rubber bands
  • Pair of dice
  • Miscellaneous hardware (screws, nuts, nylon spacers, etc.)
  • 4 AA NiMH rechargeable batteries and battery holder
  • Dimension Engineering AnyVolt Micro switching DC-DC converter
  • 2 GWS S35 STD continuous rotation servos
  • ShapeLock plastic
  • Small caster wheel
  • Arduino Nano v3
  • L293 driver
  • 2 Sharp GP2D120 IR sensors
  • Half-size protoboard

Chassis and Drive Train

The chassis is two CDs (RedHat 7.1 for extra geek cred) connected with machine screws and nylon spacers. The servos are mounted underneath the bottom CD using mounts we made from ShapeLock plastic. A caster (purchased at a home improvement store) is also mounted underneath the bottom CD.

We used a CD spindle as a jig to cut wheels from old CDs with a rotary tool (plastic shavings everywhere!). Four CDs were cut down and glued together with model glue to make each wheel. Rubber bands from supermarket broccoli fit perfectly over the wheels and made good tires. A little more model glue keeps the tires from coming off the wheels. The wheels are fastened with machine screws to the hubs that came with the servos.

Electronics

HUL-10 is powered by four rechargeable AA batteries, providing 4.8 – 6 V. The raw battery voltage is used to power the servos through the L293 driver. The switching power supply is used to convert the battery voltage to 5 V for the other electronics. The 5 V supply is connected to the Arduino Nano”s 5 V pin, bypassing the on-board voltage regulator.

The Arduino Nano reads the IR sensors and controls the speed and direction of the servo motors.

See the end of this article for a power budget and run time calculation.

Software

If anyone is interested, I have uploaded the source code for HUL-10 version 1.

HUL-10 avoids obstacles using a simple algorithm: the closer an object is, the sharper we turn away from it. This is implemented with the following steps.

  1. Read the analog voltage from the IR sensor.
  2. Convert the voltage to distance (in cm).
  3. Map the min/max distance on a sensor to reverse/forward of the servo on the opposite side.

If the IR sensor detects that no object is within the maximum distance (~40 cm), then the opposite servo runs full forward. As an object gets closer to one side, the servo on the other side starts to slow down. This causes HUL-10 to gently turn away from the object. As the object gets closer, the opposite servo slows down more and more, eventually starting to turn backwards, and finally turning backwards at full speed when an object is at the minimum detection distance (~4 cm).

To reduce the computation load on the microcontroller, the conversion of voltage to distance and then distance to servo speed is accomplished with a pre-generated look-up table.

Results

To say we are happy with version 1 is a bit of an understatement. There was jumping and woo-hooing when HUL-10 avoided his first object.

We are pleased with the stability and performance of the chassis, especially the wheels. They were easy to construct and perform very well. The servos work well too, but we wish the robot moved a little faster.

Although our algorithm is simple, it performs very well. The analog/nervous nature of the algorithm makes HUL-10 navigate smoothly around objects without sudden changes of direction or speed.

HUL-10 can occasionally get into some “stuck” situations, where the algorithm causes both servos to stop turning. Also HUL-10 will fail to avoid some obstacles if they are in the sensor blind spots — the sides of the robot and very short objects.

Improvements

Here is a list of improvements we would like to make. We expect to implement some of them in version 2.

  • Add a power switch.
  • New chassis and skin; make it look cool.
  • Use larger wheels to increase speed.
  • Fix “stuck” problems and blind spots.
  • Add a random component to his direction, making him appear to wander and explore.
  • Give him a face and some personality.
  • Give him a voice.
  • Use photocells to make him follow a flashlight beam.
  • Amplify the IR sensors to improve resolution and performance in varying light conditions.
  • Look at the 5 V power supply on a ‘scope and add filtering where necessary to reduce noise.
  • Solder L293 driver to its own breadboard and mount it underneath the chassis with the servos. This will free up some room on the protoboard for future experiments.
  • Refine power and run time data with actual measurements.

Power Budget

Just for fun and to show the kids some practical math, we did a rough power budget. We could not find power data on the servos, so we made a rough estimate. The Arduino Nano power is also a rough estimate including the AVR and the yellow and blue LEDs. In the power calculations, we are using 5.0 V for our battery voltage, because that is what they seem to deliver most of the time.

5 V Supply

Component Typical Current (mA) Maximum Current (mA)
Arduino Nano 40 60
2 IR sensors 66 100
Total 106 160

AnyVolt Micro efficiency = 75%

Typical output power = 106 mA * 5 V = 530 mW

Typical input power = 530 mW / 0.75 = 707 mW

Typical input current = 707 mW / 5 V = 141 mA

Maximum output power = 160 mA * 5 V = 800 mW

Maximum input power = 800 mW / 0.75 = 1067 mW

Maximum input current = 1067 mW / 5 V = 213 mA

Direct Battery Power

Component Typical Current (mA) Maximum Current (mA)
L293 driver (quiescent, 2 channels) 32 48
2 servos 500 1000
AnyVolt Micro (quiescent) 15 32
5 V Supply (input) 141 213
Total 688 1293

Our batteries are rated at 2500 mAH, which gives us a run time of 1.9 – 3.6 hours.

The servo and Arduino Nano estimates could be significantly off. In version 2, we will do some actual power measurements to refine the numbers.

Posted in Uncategorized | Tagged , , , , | 1 Comment

Pointing Equations for the Alt-Alt-Az Mount

The alt-alt-az mount is a three-axis telescope mount that has two altitude bearings and one azimuth bearing. The extra axis allows the mount to control field rotation independently from its pointing location. This has many applications, including satellite tracking and photography.

The coordinate frames and some of the notations used here are described in a separate post. The method used for deriving the pointing equations is to equate two different, but equivalent, rotation sequences. The terms in the resulting matrices are used to solve for the variables of interest. This method is described in Quaternions and Rotation Sequences, by Jack Kuipers.

Alt-Alt-Az Mount

Figure 1 shows an alt-alt-az mount (courtesy of Tracy Wilson). It has two orthogonal altitude axes and one azimuth axis. The a_1 coordinate is the first altitude coordinate and ranges from 0° (pointing horizontally) to 180° (pointing vertically). The a_2 coordinate is the second altitude coordinate and ranges from -90° (rotated to the right) to 90° (rotated to the left). The a_3 coordinate is the azimuth coordinate and is measured in the same way as the altazimuth mount: 0° north, increasing toward the east.

Alt-Alt-Az Mount

Figure 1: Alt-Alt-Az Mount

Field Rotation

The design of the alt-alt-az mount is such that it can rotate its tube on the optical axis while pointed at a given point. One way to think of this is to imagine an equatorially mounted telescope that is also able to rotate its tube on its optical axis. This rotation of the tube is called the field rotation, f. The field rotation is defined relative to an equatorially mounted telescope. Thus, an equatorial telescope always has a field rotation of 0°, and an altazimuth telescope has a field rotation given by the parallactic angle.

Alt-Alt-Az to Equatorial

The equations for computing the equatorial coordinates (h, \delta, f) from the alt-alt-az coordinates (a_1, a_2, a_3) are found by equating two different rotation sequences that transform from the equatorial to the telescope coordinate system. These are shown below.

\mathbb{R}^x_{f} \mathbb{R}^y_{-\delta} \mathbb{R}^z_{-h} = \mathbb{R}^y_{-a_1} \mathbb{R}^x_{-a_2} \mathbb{R}^z_{\pi-a_3} \mathbb{R}^y_{\frac{\pi}{2}-\phi}

The rotation sequence on the left is the standard transformation from the equatorial to the telescope system followed by an additional rotation of f about the x-axis, which accounts for the field rotation. The rotation sequence on the right is the transformation from the equatorial to the horizontal coordinate system followed by the transformation from the horizontal to the telescope coordinate system in terms of the mount coordinates a_1, a_2, and a_3.

The (1, 3) terms of the matrices yield the equation for declination.

\begin{array}{rcl} \sin \delta & = & \cos \phi \sin a_1 \sin a_2 \sin a_3 + \sin \phi \sin a_1 \cos a_2 \\ & & + \cos \phi \cos a_1 \cos a_3 \end{array}

The (1, 2) and (1, 1) terms of the matrices yield the following equations, which can be used to solve for the hour angle.

\sin h \cos \delta = \sin a_1 \sin a_2 \cos a_3 - \cos a_1 \sin a_3

\begin{array}{rcl} \cos h \cos \delta & = & \cos \phi \sin a_1 \cos a_2 - \sin \phi \sin a_1 \sin a_2 \sin a_3 \\ & & - \sin \phi \cos a_1 \cos a_3 \end{array}

The (2, 3) and (3, 3) terms of the matrices yield the following equations, which can be used to solve for the field rotation.

\cos \delta \sin f = \cos \phi \cos a_2 \sin a_3 - \sin \phi \sin a_2

\begin{array}{rcl} \cos \delta \cos f & = & \cos \phi \cos a_1 \sin a_2 \sin a_3 + \sin \phi \cos a_1 \cos a_2 \\ & & - \cos \phi \sin a_1 \cos a_3 \end{array}

Equatorial to Alt-Alt-Az

The equations for computing the alt-alt-az coordinates from the equatorial coordinates are found by equating two different rotation sequences that transform from the horizontal to the telescope coordinate system. These are shown below.

\mathbb{R}^y_{-a_1} \mathbb{R}^x_{-a_2} \mathbb{R}^z_{\pi-a_3} = \mathbb{R}^x_{f} \mathbb{R}^y_{-\delta} \mathbb{R}^z_{-h} \mathbb{R}^y_{\phi-\frac{\pi}{2}}

The rotation sequence on the left is the transformation from the horizontal to the telescope system in terms of the mount coordinates. The rotation sequence on the right is the transformation from the horizontal to the equatorial system followed by the transformation from the equatorial to the telescope system.

The (1, 3) and (3, 3) terms of the matrices yield the following equations, which can be used to solve for a_1.

\sin a_1 \cos a_2 = \cos \phi \cos h \cos \delta + \sin \phi \sin \delta

\begin{array}{rcl} \cos a_1 \cos a_2 & = & \sin \phi \cos \delta \cos f - \cos \phi \cos h \sin \delta \cos f \\ & & - \cos \phi \sin h \sin f \end{array}

The (2, 3) terms of the matrices yield the equation for a_2.

\begin{array}{rcl} \sin a_2 & = & \cos \phi \sin \delta \cos h \sin f - \sin \phi \cos \delta \sin f \\ & & - \cos \phi \sin h \cos f \end{array}

The (2, 1) and (2, 2) terms of the matrices yield the following equations, which can be used to solve for $a_3$.

\begin{array}{rcl} \cos a_2 \sin a_3 & = & \cos \phi \cos \delta \sin f + \sin \phi \cos h \sin \delta \sin f \\ & & - \sin \phi \sin h \cos f \end{array}

\cos a_2 \cos a_3 = -\cos h \cos f - \sin h \sin \delta \sin f

Alt-Alt-Az to Horizontal

The equations for computing the horizontal (A, a) coordinates from the alt-alt-az coordinates are found by equating two different rotation sequences that transform from the horizontal to the telescope system. These are shown below.

\mathbb{R}^x_{f} \mathbb{R}^y_{-a} \mathbb{R}^z_{\pi-A} = \mathbb{R}^y_{-a_1} \mathbb{R}^x_{-a_2} \mathbb{R}^z_{\pi-a_3}

The rotation sequence on the left is the transformation from the horizontal to the telescope system followed by an additional rotation of f about the x-axis, which accounts for the field rotation. The rotation sequence on the right is the transformation from the horizontal to the telescope system in terms of the mount coordinates.

The (1, 3) terms of the matrices yield the equation for altitude.

\sin a = \sin a_1 \cos a_2

The (1, 2) and (1, 1) terms of the matrices yield the following equations, which can be used to solve for azimuth.

\sin A \cos a = \cos a_1 \sin a_3 - \sin a_1 \sin a_2 \cos a_3

\cos A \cos a = \sin a_1 \sin a_2 \sin a_3 + \cos a_1 \cos a_3

The (2, 3) and (3, 3) terms of the matrices yield the following equations, which can be used to solve for field rotation.

\cos a \sin f = -\sin a_2

\cos a \cos f = \cos a_1 \cos a_2

Horizontal to Alt-Alt-Az

The rotation matrices used above also provide the equations for computing the alt-alt-az coordinates from the horizontal coordinates. The (1, 3) and (3, 3) terms of the matrices yield the following equations, which can be used to solve for a_1.

\sin a_1 \cos a_2 = \sin a

\cos a_1 \cos a_2 = \cos a \cos f

The (2, 3) terms of the matrices yield the equation for a_2.

\sin a_2 = -\cos a \sin f

The (2, 1) and (2, 2) terms of the matrices yield the following equations, which can be used to solve for a_3.

\cos a_2 \sin a_3 = \sin A \cos f - \cos A \sin a \sin f

\cos a_2 \cos a_3 = \sin A \sin a \sin f + \cos A \cos f

Posted in Uncategorized | Tagged , , , , | Leave a comment

Astronomical Coordinate Systems

Here are descriptions of some commonly-used astronomical coordinate systems. This is pretty standard material, but I”m posting it as a reference for the conventions and notations I”ll be using in future posts.

Telescope Coordinate System

The telescope coordinate system is shown in Figure 1. It is simply the reference coordinate system of the telescope. A t subscript is used to indicate coordinates referenced to this system. The positive x_t-axis coincides with the optical axis of the telescope and points to the celestial object being observed. The positive z_t-axis indicates the top of the telescope tube. The positive and negative y_t-axes indicate the left and right of the tube, respectively.

Telescope Coordinate System

Figure 1: Telescope Coordinate System

Horizontal Coordinate System

The horizontal coordinate system is shown in Figure 2. It is referenced to the observer”s horizon and local meridian. An h subscript is used to indicate coordinates referenced to this system. The positive and negative x_h-axes point south and north, respectively. The positive and negative y_h-axes point east and west, respectively. The positive z_h-axis points to the zenith.

Horizontal Coordinate System

Figure 2: Horizontal Coordinate System

The altitude, a, and azimuth, A, are used as coordinates in this system. The altitude is measured normal to the x_h-y_h plane and is positive above the horizon. The azimuth is measured in the x_h-y_h plane starting at 0° due north and increasing toward the east (i.e., east = 90°, south = 180°, and west = 270°).

Equatorial Coordinate System

The equatorial coordinate system is shown in Figure 3. It is referenced to the celestial equator and the local meridian. An e subscript is used to indicate coordinates referenced to this system. The positive x_e-axis points to the local meridian, the positive y_e-axis points east, and the positive z_e axis points to the celestial north pole.

Equatorial Coordinate System

Figure 3: Equatorial Coordinate System

The declination, \delta, and hour angle, h, are used as coordinates in this system. The declination is measured normal to the x_e-y_e plane and is positive above the celestial equator. The hour angle is measured in the x_e-y_e plane starting at 0° at the local meridian, positive to the west and negative to the east.

The right ascension, \alpha, of an object is related to the hour angle, h, by the following formula:

h = \theta - \alpha

where \theta is the local sidereal time.

Transformations Between Coordinate Systems

All of the coordinate systems mentioned above are related by simple transformations involving one or two rotations. Figure 4 illustrates the relationship between the horizontal and equatorial coordinate systems.

Relationship between Horizontal and Equatorial Coordinate Systems

Figure 4: Relationship between Horizontal and Equatorial Coordinate Systems

The celestial north pole and the zenith are separated by an angle of \frac{\pi}{2} - \phi, where \phi is the observer’s latitude. Thus, the two coordinate systems are related by a rotation of this angle about the y axis. The transformation equations are shown below.

\mathbb{T}_{e \rightarrow h} = \mathbb{R}^y_{\frac{\pi}{2} - \phi}

\mathbb{T}_{h \rightarrow e} = \mathbb{R}^y_{\phi - \frac{\pi}{2}}

The transformations between the horizontal and telescope coordinate systems are accomplished by rotations of the azimuth and altitude about the z-axis and y-axis. The transformation equations are shown below.

\mathbb{T}_{h \rightarrow t} = \mathbb{R}^y_{-a} \mathbb{R}^z_{\pi - A}

\mathbb{T}_{t \rightarrow h} = \mathbb{R}^z_{A - \pi} \mathbb{R}^y_{a}

The transformations between the equatorial and telescope coordinate systems are accomplished by rotations of the hour angle and declination about the z-axis and y-axis. The transformation equations are shown below.

\mathbb{T}_{e \rightarrow t} = \mathbb{R}^y_{-\delta} \mathbb{R}^z_{-h}

\mathbb{T}_{t \rightarrow e} = \mathbb{R}^z_{h} \mathbb{R}^y_{\delta}

Posted in Uncategorized | Tagged , , , , | 1 Comment