RobotGeek Snapper - Joystick Backhoe Demo - OLD for Reference Only

This firmware is not longer recommended or supported - all backhoe and playback function have been wrapped into the General RobotGeek Snapper Control Firmware. This page is for reference only.

snapper-joystick-backhoe.jpg

mt_ignore
PC Control (Setup Only)
mt_ignore
Direct Control
mt_ignore
Pose Control

This demo shows how to control the Snapper robot arm using joysticks for input in backhoe mode. Backhoe means that the servos are being controlled individually and there are no inverse kinematics being used. This is the most basic way of controlling a robotic arm and is good for learning basic input and output on an Arduino. The following tutorials after this one show more advanced arm control.

Project Parts List:

Arm Placement and Setup:

Whenever you program the Snapper arm, you should first manually position the servos in the sleep configuration. This will make the transition from off to on for the arm smoother.

When working with the arm, we recommend that you weigh it down / secure it to the surface you are working on. This will stop the arm from falling over due to sudden movements on startup.

The arm should never be powered by USB. Always connect the DC power before you connect in the USB cable, and disconnect the USB cable before you disconnect the power. If you want to power down the arm but leave the USB plugged in, remove the PWM power jumpers.

Download the Firmware

Snapper Arm Sketches Zip File

A .zip file with all of the Snapper Arm Sketches can be found here. Unzip the file and you will have a folder called SnapperArm-master We recommend that you create a folder RobotGeek Sketches in your Arduino user folder and put the SnapperArm-master in there. The rest of this guide will assume you've placed your sketches in the following folder.

Arduino -> RobotGeek Sketches -> SnapperArm-master	

Wiring

Device Sensor Shield Port
Servos
Base Rotation RobotGeek Servo Digital 3
Shoulder RobotGeek Servo Digital 5
Elbow RobotGeek Servo Digital 6
Wrist RobotGeek Servo Digital 9
Gripper 9G Servo Digital 10
Analog Sensors
Base Joystick (Horizontal) Analog 0
Shoulder Joystick (Vertical) Analog 1
Elbow Joystick (Vertical) Analog 2
Wrist Joystick (Vertical) Analog 3
Gripper Rotation Knob Analog 4
Digital Sensors
Capture Pushbutton Digital 2
Playback Pushbutton Digital 4
b_500_500_16777215_00__images_tutorials_rgSnapperArm_snapperArmBackhoeWiring.png

Upload the Firmware

Open the Arduino IDE and navigate to the following sketch:

File -> Sketchbook -> RobotGeek Sketches -> SnapperArm-master -> SnapperArmBackHoe	

Click the 'Verify' button . If you get any errors, make sure you've setup the RobotGeek Tools and Libraries in the Geekduino Getting Started Guide. If everything worked out then you should see a 'Done Compiling' message under the code.

Now click the Upload button to load the code onto your microcontroller.

Once the firmware is uploaded, the Snapper Arm will move to a 'home' position - each joint servo will center, causing the arm to make an 'L' pose.

It's normal to hear a buzzing noise coming from one or more of the servos.

Basic Control

b_500_500_16777215_00__images_tutorials_rgSnapperArm_backHoeControl.png

Each joint of the snapper arm can be controlled by a separate joystick. Moving the joystick to the left/right or up/down will adjust move the servo in that direction. When the joystick is centered at its home position, the servo will stay in its current position. Adjusting the rotational knob will absolutely adjust the gripper: that is the position of the knob corresponds to the position of the gripper servo.

Be mindful of how tight you close the gripper on objects. It is possible to burn the 9g Micro Servo out by closing too tightly on rigid objects.

Basic Pose Playback

b_500_500_16777215_00__images_tutorials_rgSnapperArm_backHoeControlButtons.png

The SnapperArmBackHoe sketch is capable of automatically playing back a sequence of pre-programmed servo positions.

  • First press the 'Capture' putton (attached to digital pin 2). This will put the arm in capture mode and get it ready for playback (we will learn more about capture mode on the next part)
  • Press the 'Pose button' (attached to digital pin 4)

The arm will now execute each pose with a delay between each.

It is also possible to initiate pose playback through the serial monitor. Send a '1' to the serial monitor to enter capture mode, then send a '2' to the monitor and you will initiate the pose playback.

Pose Reading

b_500_500_16777215_00__images_tutorials_rgSnapperArm_backHoeControlButtons.png

Before you can program your own sequences, you'll need to read the current servo values for various arm poses. This can be accomplished by connecting the arm to the serial monitor in the Arduino IDE.

Make sure your microcontroller is connected to your PC and that you have the correct serial port chosen from the Tools->Serial Port menu. Now click the magnifying glass in the upper right corner. This will open the Arduino Serial Monitor in a separate window. The Serial Monitor allows you to communicate wit the sketch

Every time you open/close the serial monitor, the Geekduino will reset. You can disable this behavior by setting the Geekduino's RST (reset) switch to M for manual reset. Just remember to set the switch back to AUTO before you program your board again. For the rest of this guide however, leave the RST switch set to AUTO.

The Serial Monitor should have the following default settings:

  • No line ending
  • 9600 baud

The snapper arm should now show the following text

Starting RobotGeek Analog BackHoe Demo
Backhoe Control Mode Active.
Send '1' or press the 'Capture' pushbutton to pause the joysticks and capture the current pose.	

Use the joysticks to move the snapper arm to a position you would like to capture. Once you are at that position, press the 'Capture' pushbutton attached to digital pin 2. This will pause the joystick control engine and output the current servo positions to the screen. You should see a code block that looks like the following (the actual values will vary)

Exiting Backhoe Control Mode.
Current Joint Position Values:
    Base Joint: 2400
    Shoulder Joint: 1471
    Elbow Joint: 2400
    Wrist Joint: 1657
    Gripper Joint: 2034

Sequence Control Code
    BackhoeSequencingControl(2400, 1471, 2400, 1657, 2034,2000,1000); 

The line:

BackhoeSequencingControl(2400, 1471, 2400, 1657, 2034,2000,1000); 

contains all of the data for each servo in one line of code. This line will later be put back into the sketch. For now, just copy this line to a text editor for later.

Once you have copied this value down, you can hit the 'Capture' pushbutton again to start the joystick control engine. Now move the arm to your next desired pose, and repeat the capture process. We recommend that you start with 5 different poses and move onto the next step before you start creating longer pose sequences.

It is also possible to initiate pose playback through the serial monitor. Send a '1' to the monitor. This will have the same affect as if you had pressed the pushbutton.

The poses displayed to the serial monitor are the servo positional values currently being sent to the arm servos. The current amount of load the arm is carrying may effect the actual position of the arm in real-space.

Custom Pose Playback

Once you have figured out the different servo values for each pose, you can put them back into the SnapperArmBackHoe sketch and play them back. Find the following code in the sketch

//###########################################################//
// SEQUENCE 1
//###########################################################// 
//SequencingControl(Base, Shoulder, Elbow, Wrist, Gripper, Interpolation, Delay)
Serial.println("Moving to Sequence Position 1");   
BackhoeSequencingControl(1500, 1500, 1500, 1500, 1500, 2000, 1000);
//###########################################################//

For this example, assume we captured the following poses in the last step

BackhoeSequencingControl(2400, 1471, 2400, 1657, 2034,2000,1000); 

Now overwrite the original BackhoeSequencingControl line with our new BackhoeSequencingControl line.

//###########################################################//
// SEQUENCE 1
//###########################################################// 
//SequencingControl(Base, Shoulder, Elbow, Wrist, Gripper, Interpolation, Delay)
Serial.println("Moving to Sequence Position 1");   
BackhoeSequencingControl(2400, 1471, 2400, 1657, 2034,2000,1000); 
//###########################################################//

You can repeat the process to replace all 5 of the original poses, or mix and match your poses with the pre-set ones. Once you've re-written the code, upload the sketch to your microcontroller. Now you can use the 'Play' pushbutton to play back your custom pose.

Extra Poses, Speed and Pause Time

More Poses

To add more poses in the sequence, simply copy the block of pose code and add it after the last pose. For example, to add a sixth pose after the 5th pose your code would look like this:

//###########################################################//
// SEQUENCE 5
//###########################################################//
Serial.println("Moving to Sequence Position 5");  
BackhoeSequencingControl(1200, 1500, 1200, 1500, 1500, 2000, 1000);
//###########################################################//

//###########################################################//
// SEQUENCE 6
//###########################################################// 
Serial.println("Moving to Sequence Position 6");   
BackhoeSequencingControl(2400, 1471, 2400, 1657, 2034,2000,1000); 
//###########################################################//

Any line starting with a // is a comment, and not necessary for the actual program. However commenting can help to see where each pose is at a glance.
The line starting with Serial.println is used to help you see when each pose is being activated, but it does not effect the pose itself.

Speed / Interpolate

The BackhoeSequencingControl() function has several parameters:

BackhoeSequencingControl(Base Servo, Shoulder Servo, Elbo Servo, Wrist Servo, Gripper Servo,Interpolate,Pause Time)

The second-to-last value, Interpolate Time defines the time it takes to go from one pose to the next. This time is defined in milliseconds, to the default 2000 milliseconds is 2 seconds. By decreasing this time (for example by lowering the value from 2000 to 500)

BackhoeSequencingControl(2400, 1471, 2400, 1657, 2034,500,1000); 

you will cause the movements between each pose to go faster.

If you increase the time (for example by increasing it from 2000 to 5000)

BackhoeSequencingControl(2400, 1471, 2400, 1657, 2034,2000,1000); 

you will cause the movements between each pose to go faster.

It is possible to send signals to the servos faster than they can physically move. We find that for some longer poses, anything under 500ms may not allow the pose to be fully executed. You may need to test multiple different values depending on your target speed and poses.

Pause Time

After moving to a new pose, the arm will stop and pause. The amount of time it pauses is defined by the final value in the BackhoeSequencingControl() function. This time is defined in milliseconds, to the default 1000 milliseconds is 1 seconds.

By decreasing this time (for example by lowering the value from 1000 to 0)

BackhoeSequencingControl(2400, 1471, 2400, 1657, 2034,2000,0); 

you will cause the pause to be less (in this case, the arm will not pause at all).

If you increase the time (for example by increasing it from 1000 to 5000)

BackhoeSequencingControl(2400, 1471, 2400, 1657, 2034,,2000,5000); 

the pause after each movement will be longer.

Disabling Playback

Removing the pushbuttons from the setup without modifying the code will cause erratic behavior. The two digital pins will still expect an input, and if they are left disconnected/ 'floating', the microcontroller may initiate capture/pose modes.

A quick way to disable this behavior is to remove the following code

 buttonState2 = digitalRead(BUTTON2);	

This will stop the digital pins from reading, stopping any 'floating' inputs. Further code modifications would be required to fully remove the pose/capture functionality, but this modification will stop any erratic behavior if you wish to remove the pushbuttons.

b_500_500_16777215_00__images_tutorials_rgSnapperArm_backHoeControlButtons.png

×

PC Control These demos and projects allow the robot to be controlled via a computer.

ArbotiX Commander Control - These demos and projects control the Robot using the ArbotiX Commander, the handheld Arduino based remote control.

Direct Control - These demos and projects control the Robot directly from sensors connected directly to the Robot's control board.

Pose Control - These demos and projects allow you to create and playback a sequence of poses.

Serial Control - These demos and projects control the robot using a serial packet protocol.

Standalone - These demos and projects are deisgned to let your robot function without a computer or additional microcontroller.

Wireless Control - These demos and projects allow you to control the robot wirelessly - usually by replacing the Serial Connection with XBee modules.

Reference - These articles have technical details regarding the control and operation of the robot.

×

More info here

Feedback Form


Search