ArduSnake: Arduino Modular Snake Robots Library

De WikiRobotics
Revisión del 03:07 14 abr 2012 de Obijuan (Discusión | contribuciones) (Example 3: Oscillation of two servos)

Saltar a: navegación, buscar

Ardusnake-logo.png

Introduction

Ardusnake is an Arduino Library for generating easily the locomotion of modular snake robots or other modular robots. It is based on sinusoidal oscillators which drive the servos.

Architecture

ArduSnake Architecture (click para ampliar)

The ArduSnake library comprises the following layers:

  • Oscillators: This layer is in charge of oscillating the servos sinusoidally. Just with these oscillations the locomotion of worm, snakes and other modular robots can be achieved.
  • Worm: It offers an easy API for the locomotion of worm robots (locomotion in 1D) (alpha stage)
  • Snake: Locomotion of snake modular robots (in 2D) (Future work, not yet implemented)
  • User Application: The user can use the previous layers for the locomotion of the robot.

Tutorial

Figure 1: How to connect the servo to the Skymega board for running the "hello world" example

The first step is to install the ArduSnake library. Please follow these instructions .

Oscillators Layer

Example 1: Hello world

This example just makes a servo oscillate, using the default parameters

  • Open the example oscillator_test1 from File/examples/ArduSnake.
  • Attach the servo
    • If using Arduino connect the servo to pin 8
    • If using skymega, connect the servo number 2 (see figure 1)
  • Upload the example to the board. The servo will oscillate, as shown in the video
300|250</youtube> DSC04907.JPG

The source code of the example is show below. An oscillator is declared, then it is assigned to an output (were the servo is connected). In the main loop the method refresh() is called. It just recalculates the servo position when necessary. The servo will oscillate with the default parameters.

#include <Servo.h>
#include <Oscillator.h>
#include "skymega.h"
//-- Declare an oscillator Oscillator osc;
void setup() { //-- Attach the oscillator to the servo //-- For arduino, you can use the pin number instead of SERVO2 (for example 8) osc.attach(SERVO2); }
void loop() { osc.refresh(); }

Example 2: Setting the oscillator parameters

In this example the oscillator parameters are set by the user. For generating the locomotion of robots, is quite important to fully understand the 4 parameters that determines the oscillation. These parameters are:

  • Amplitude (A): How far the servo moves from the mean angle (in degrees)
  • Offset (O): The mean angle (in degrees). The servo will oscillate symmetrically around this angle.
  • Period (T): The oscillation period (in ms)
  • Initial phase (Ph): It determines in which part of the cycle the servo starts (degrees): in one end, in the other end, in the middle....

The servo position <math>\varphi(t)</math> is calculated by means of this equation:

<math>\varphi(t) = A\sin\left(\frac{2\pi}{T}t + \phi_0 \right)+O</math>

In this example, the oscillators parameters are set to: Amplitud: 40, offset: 40, Period: 1 sec, Initial phase: -90. You can see how the servo moves in the following video (compare this oscillation with that of the hello world example)

300|250</youtube> DSC04923.JPG

Changing the oscillation parameters is very easy by calling the methods: SetO(), SetA(), SetT() and SetPh()

#include <Servo.h>
#include <Oscillator.h>
#include "skymega.h" 
//-- Declare an oscillator Oscillator osc;
void setup() { //-- Attach the oscillator to the servo //-- For arduino, you can use the pin number instead of SERVO2 (for example 8) osc.attach(SERVO2); //-------- Set the oscillator parameters //-- Offset: 40 deg, Amplitude: 40 deg, Period: 1 sec, Initial phasa: -90 deg osc.SetO(40); osc.SetA(40); osc.SetT(1000); osc.SetPh(DEG2RAD(-90)); }
void loop() { //-- Refresh the oscillator osc.refresh(); }

Example 3: Oscillation of two servos

300|250</youtube> [[|300px|]]

Example 4: A mini-wave

Download

ArduSnake-001.zip ArduSnake sources. Version 001

Installation

The current version is being developed under Arduino 22 IDE. It may work with newer version, but I have not tried it.

  • Download the library: ArduSnake-001.zip
  • Uncompress it in your working directory
  • Copy the ArduSnake and skymega folders under the sketchbook/libraries arduino folder (In linux, it is in /home/username/sketchbook/libraries). It does not matters if you do not have a skymega board, copy the folder skymega anyway.
  • Launch the Arduino 22 IDE
  • The menu Ardusnake containing some example should be accesible now from the File/Examples menu

Changelog

Ardusnake 001:

  • Initial version
  • The oscillator layer is working
  • Some examples on how to use the oscillator layer written
  • The worm layer is still in alpha stage (Do not use it yet)
  • The snake layer has no been started

Authors

License

150px This library is under the GPL v3.0 license

Git repository

Publications

More information

News

  • 15/Feb/2012: This page is created