Close

Processing Library Download and Instructions

A project log for Stubby the (Teaching) Hexapod

100% open source robot platform with accessability and affordability in mind: teaching children of all ages about robots & programming

the-big-oneThe Big One 09/13/2014 at 22:550 Comments

For those who want to try controlling Stubby from the computer in Processing, I have attached the current build of the Processing library.  All planned features are not yet completed, but it is a good start, and is plenty to verify connectivity; Princess Sparkle is having a blast playing with the different options.

You can download the library from my web site.  Once downloaded, unzip it to the Processing libraries folder, within the Sketchbook. (By default this is C:\My Documents\Processing on Windows, and ~/Documents/Processing on the Mac).  Within the sketchbook folder there should be one called "libraries".  Unzip stubby.zip to that location; you should see a folder structure similar to this:

<sketchbook>/libraries/stubby.zip
<sketchbook>/libraries/stubby (folder)
<sketchbook>/libraries/stubby/library (folder)
<sketchbook>/libraries/stubby/library/stubby.jar
<sketchbook>/libraries/stubby/library.properties

Restart Processing, and you should see the Stubby Control Interface library in the Libraries list:

Go ahead and add it to your sketch, along with the Serial library:

A basic program can include all commands in the setup() method, and can exit as soon as Setup is completed:

All currently supported commands are listed below.  More are coming soon; you can always get the latest release of this library by downloading the Git repository, navigating to 'projects/stubby/processing', and typing 'ant' to build the library.

/**
* Turn the servos on
*/
public boolean turnOn();


/**
* Turn the servos off
*/
public boolean turnOff();


/**
* Move the specified distance in the indicated direction at the given speed
* 
* @param linearAngle Angle to move.  0 is straight forward, negative angles are right, and positive angles are left.  Angle in degrees.
* @param rotationalAngle Rotational angle to turn.  Measured the same as linear angle.
* @param linearVelocity Speed to move; unsigned 8 bit integer value between 255 (fastest) and 0 (slowest).
* @param rotationalVelocity Speed to turn; same range as linearVelocity.
* @param distance Distance to move (in mm).
* @return
*/
public boolean move(int linearAngle, int rotationalAngle, int linearVelocity, int rotationalVelocity, int distance);


/**
* Convenience method to walk in the specified direction for the specified distance.  See above for parameter descriptions.
*/
public boolean move(int linearAngle, int distance);


/**
* Convenience method to walk forward.
*/
public boolean moveForward(int distance);


/**
* Convenience method to walk backward.
*/
public boolean moveBackward(int distance);


/**
* Convenience method to walk right.
*/
public boolean moveRight(int distance);


/**
* Convenience method to walk left.
*/
public boolean moveLeft(int distance);


/**
* Rotates to the specified angle.  Positive values rotate clockwise, negative rotate counter clockwise.
* @param angle In degrees, with 0 being the direction the robot is currently facing.  Negative angles are to the right (clockwise), positive to the right (counter clockwise)
* @param rotationalVelocity Speed to turn, between 0 and 255
*/
public boolean turn(int angle, int rotationalVelocity);


/**
* Convenience method to turn right
*/
public boolean turnRight();


/**
* Convenience method to turn left
*/
public boolean turnLeft();


/**
* Convenience method to turn around 180 degrees (counter clockwise)
*/
public boolean turnAround();


/**
* Convenience method to turn around 180 degrees (clockwise)
*/
public boolean turnAroundClockwise();

Cheers

Discussions