Snake Project/Snake 1 Control Code

From DellinWiki
Jump to: navigation, search

« Back to the Snake Project home page

The snake is controlled on a per servo basis from the host computer. Commands to set servo position and velocity are sent via a USB request to the PIC using libusb, which then translates each request to its corresponding I2C request. The SD-21 Servo Controller then forwards the parameters to the servos themselves.

Simplistic Serpentine Gait

The Phase One and Phase Two snake use a very simplistic serpentine gait algorithm. The simplest form of serpentine motion in a snake a that of a sine wave. Since servos are position-controlled, we update each servo on the snake with a sine wave, changing in time with a phase shift between each servo. The net result is a ripple effect in the snake, much like what you see in a Slinky.

Theory

This motion is not a pure serpentine gait, especially since the sine wave we are feeding the snake with exists in the frame of reference of the servo and not the frame of reference of the snake. In fact, a true serpentine gait is not actually a pure sine wave. Since phases One and Two were prototype models, an inaccurate representation for serpentine motion was acceptable, even useful in debugging our mechanical designs.

Continuous-Spine Serpentine Gait

The control algorithm for snake phases Phase Three and Phase Four is best viewed as a type of brute-force algorithm for the computation of joint angles. In software, a path is laid out on the ground in front of the snake, and for each head position along that path, the software computes the joint angles needed to keep each node on the path. In this way, the snake can follow the path on the ground (in "world-space") while each node only moves tangential to the path. Theory

It is this reliance on tangential motion that allows the snake to move forward; since each node has very little friction in its direction of motion but a large amount of friction perpendicular to its direction of motion, the entire snake tends to move forward. The physics is not unlike that of sailboat with its keel pointed at some angle to the wind; while the wind force may not be in the direction of motion, the boat is only allowed to move along its keel axis. In the snake system, each servo is controlled so that the only way the entire snake can travel in its low-friction mode (tangential to each link) is by following the path on the ground laid out in software (each node's "keel" direction).

Personal tools