RobotGeek Snapper - Joystick Inverse Kinematics 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

In the last demo you learned how to control each individual servo on the Snapper Arm. In this demo you will harness the power of Inverse Kinematics to move the servos in tandem to reach a specific point in space.

For example, let's say you want to move the gripper on the Snapper Arm directly down along the Z-Axis. To do this you would need to move the shoulder, elbow and wrist servos to specific positions until the gripper moved directly down relative to it's original position. Inverse Kinematics (or IK) uses a series of kinematic equations to determine the position for each joint so that the gripper (generally called the 'end effector') will move to a specific position in X/Y/Z space. Using IK, you an issue a single X/Y/Z position you would like the arm to move to, instead of manually moving each joint on the arm.

The SnapperArmIK firmware contains a fully functional IK engine. You do not need to be able to write or understand the kinematic equations in order to use the firmware (though it is a great place to start when you want to learn about the inner workings of kinematics)

You can use the SnapperArmIK firmware to set the X/Y/Z position of the arm using the joystick control panel, and playback pre-programmed X/Y/Z.

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

If you already downloaded the Snapper Arm Sketches in the last example, you can skip this step.

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
X Joystick (Horizontal) Analog 0
Y Joystick (Vertical) Analog 1
Z Joystick (Vertical) Analog 2
Wrist Angle 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 -> SnapperArmIK	

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.

Basic Control

b_500_500_16777215_00__images_tutorials_rgSnapperArm_IKControl.png

Each x/y/z coordinate 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 coordinate in that direction. When the joystick is centered at its home position, the coordinate 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_IKControlButtons.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_IKControlButtons.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 IK Demo
Analog IK 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 Analog IK Control Mode.

Current Arm Coordinate Values:
    X Axis: 0.00
    Y Axis: 82.61
    Z Axis: 224.52
    Wrist Angle: 0
    Gripper: 1631


Sequence Control Code
    IKSequencingControl(0.00, 82.61, 224.52, 0.00, 1631, 2000, 1000); 

The line:

IKSequencingControl(0.00, 82.61, 224.52, 0.00, 1631, 2000, 1000);; 

contains all of the data for each position 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
//###########################################################// 
//IKSequencingControl(X-axis, Y-Axis, Z-axis, Wrist Angle, Gripper, Interpolation, Delay)
Serial.println("Moving to Sequence Position 1");   
IKSequencingControl(0, 150, 150, 0, 1500, 2000, 1000);
//###########################################################//

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

IKSequencingControl(0.00, 82.61, 224.52, 0.00, 1631,2000,1000);

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

//###########################################################//
// SEQUENCE 1
//###########################################################// 
//IKSequencingControl(X-axis, Y-Axis, Z-axis, Wrist Angle, Gripper, Interpolation, Delay)
Serial.println("Moving to Sequence Position 1");   
IKSequencingControl(0.00, 82.61, 224.52, 0.00, 1631,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");  
IKSequencingControl(0, 100, 100, -15, 1500, 2000, 1000);
//###########################################################//

//###########################################################//
// SEQUENCE 6
//###########################################################// 
Serial.println("Moving to Sequence Position 6");   
IKSequencingControl(0.00, 82.61, 224.52, 0.00, 1631,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 IKSequencingControl() function has several parameters:

IKSequencingControl(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)

IKSequencingControl(0.00, 82.61, 224.52, 0.00, 1631,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)

IKSequencingControl(0.00, 82.61, 224.52, 0.00, 1631,5000,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)

IKSequencingControl(0.00, 82.61, 224.52, 0.00, 1631,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)

IKSequencingControl(0.00, 82.61, 224.52, 0.00, 1631,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

Next:Serial Control Mode

×

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