Step 20: Programming

To climb up a tree, the robot goes through a simple series of motions.  First, the top segment grips the tree and the bottom segment releases form the tree (if necessary).  Then the spine contracts, pulling the bottom segment up towards the top segment.  Next the bottom segment grips the tree, and afterwards the top segment releases from the tree.  Finally, the spine extends, pushing the top segment upwards, and the cycle can start over again.  For ease of programming, I wrote a function corresponding to each basic motion.  These are as follows:
  • closeTop
  • closeBottom
  • openTop
  • openBottom
  • Lift
  • Push
By combining these functions in the proper order, the robot can be made to ascend or descend trees.  

Opening the legs is very simple.  The legs turn outwards from the tree until their rotation sensors reach a point set in the program.  Then power is cut off to the motors.  Closing the legs on the tree, however, is a little bit more complex.  Since trees vary in diameter, the legs need to be able to grip a wide variety of diameters without reprogramming the robot for each size.  To figure out when to cut off power to the motors, the controller first calculates the speed at which the legs are moving towards the tree.  It does this by sampling the position of the legs' potentiometers every .05 seconds.  It subtracts the previous value of the potentiometer from the current value to find the distance traveled by the legs over the  time period.  When the distance travels becomes close to zero (I used 1 in my program), it means that the legs have gripped into the tree and are beginning to slow down.  Then the controller cuts of power to the motors, to prevent them from stalling out, or damaging themselves, the motor controller or the gearboxes.

The last piece to the programming puzzle is the method of controlling the robot's actions.  If you look at the above movement cycle, you will notice that the robot is gripping the tree at all times.  This makes it difficult to remove the robot, so I programmed the control switch to manually control the behavior of the robot.  While the switch is off (circuit open), the robot keeps its legs open.  Once the switch is turned on, the robot begins its climbing cycle.  To remove the robot from the tree, the switch is turned back to the off position, and both sets of legs release.

If you liked this project, please vote for me in the Epilog contest!  What would I do with a laser cutter?  Well, I could use it to make parts for even more robots and machines (after I finished etching every electronic device I own, of course).  Not having to manually cut, file, bend, and grind every component of my robots would let me significantly increase the complexity and variety of what I can build, and would also significantly cut down on construction time, so that I would be able to build even more interesting things.

This project was featured on Hack A Day!  Thanks for the great article.