Snapper Arm Sequence Playback

rg-snapper-e.jpg
mt_ignore
Pose Control
mt_ignore
Standalone

This article will show you how to use the poses you recorded in earlier demos to change and arrange a sequence of poses. You can then save that sequence to a new stand-alone firmware. This sequence can be integrated into your own custom projects.

Before you start this project, make sure you've assembled, programed, and tested your robotic arm by going through the Snapper Arm Getting Started Guide as well as having gone through one of the joystick control demos - 1.Backhoe, Cartesian IK or 3. Cylindrical IK

Project Parts List

This demo will use the hardware you setup in the previous joystick control guide. The analog controls are not needed, but will not impede this demo if you leave them connected.

Wiring

Note that if you have the original 9G Mini Servo Gripper, you should follow the original wiring diagram. The only difference is that you will attach the 9g servo to pin 10 instead of attaching a RobotGeek Servo

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. Make sure there is plenty of room around the arm so that it will not hit anything.

If you're arm shows movement during programming, you can remove the shield or remover the power jumpers during programming.

The arm should never be powered by USB alone. 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 power jumpers.

Durign operation, if your arm contorts, collides or otherwise curls in on itself, remove power and usb immediately.

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

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 RobotGeek Servo Digital 10
Analog Sensors
Digital Sensors
Playback Pushbutton Digital 2
b_500_500_16777215_00__images_tutorials_rgSnapperArm_snapperarmsequenceplayback_bb.png

Step 3: Open the Stand Alone Firmware

In the Snapper Arm Getting Started Guide you should have downloaded the Snapper Arm Demo Code and added it to your RobotGeek sketches folder. This file included the SnapperArmPlayback code. You can open the SnapperArmPlayback sketch into your Arduino IDE. In the Arduino IDE, you can find the sketch under:

File -> Sketchbook -> RobotGeek sketches -> Snapper Arm -> SnapperArmPlayback  

Setting Gripper Type

Before you can load the code onto your Robot Arm, you'll need to adjust your code to match your gripper type. In the Arduino IDE, click on the tab GlobalArm.h Around line 16 you should see the following code block

//#define GRIPPER_TYPE ROBOT_GEEK_9G_GRIPPER
//#define GRIPPER_TYPE ROBOT_GEEK_PARALLEL_GRIPPER

If you are using the RobotGeek Parallel Gripper, uncomment the second line. Your code should look like

//#define GRIPPER_TYPE ROBOT_GEEK_9G_GRIPPER
#define GRIPPER_TYPE ROBOT_GEEK_PARALLEL_GRIPPER

If you are using the RobotGeek 9G Gripper, uncomment the first line. Your code should look like

#define GRIPPER_TYPE ROBOT_GEEK_9G_GRIPPER
//#define GRIPPER_TYPE ROBOT_GEEK_PARALLEL_GRIPPER

Now that the gripper type is defined, the code will take care of correctly processing your gripper type. If you are having problems finding these lines, click on the Compile button in the Arduino IDE and it will show an error near the lines you need to change.

Editing armSequence.h

Open the armSequence.h tab in the Arduino IDE. At line 19 you should see

 g_bIKMode = IKM_IK3D_CARTESIAN;

Change this to match the line that you received from your joystick control demo.

At line 23, you should see

 IKSequencingControl(0 , 150 , 150 , 0 , 0 , 256 , 2000 , 0, playState);

Change this to match the first IKSequencingControl line that you got from your joystick control demo. Continue to replace IKSequencingControl lines with your own lines. If there are more IKSequencingControl in the firware than you recorded, delete any extra IKSequencingControl lines fro the code.

Now you can load the sketch onto your Geekduino. The arm should go to its home position while it waits for the sequence to start. You can activate the sequence by pressing the button you have attached to the arm, or by opening the serial monitor (38400 baud) and sending a 1.

Your arm will now play the sequence you designed. The arm will play the sequence once and then stop on the last pose. The actions should be the same as they were in the Arm Link Software. You can start the pose again by pressing the pushbutton/entering the serial command again.

If you press the button a second time, the arm will stop when it finishes its current pose. If you send a '1' over the serial terminal, the arm will complete its entire sequence and then stop.

Advanced Usage

Minimal Code

The folder SnapperArmPlaybackMinimal contains a sketch with the minimum amount of code to play the arm sequence one time. This code may assist you if you wish to integrate the arm playback code into existing projects/code. If you want to add your own sequence into this file, add the contents of the do loop in armSequence.h into the setup loop in SnapperArmPlaybackMinimal.ino

IKSequencingControl() Overview

The armSequence.h file works by making several calls to the IKSequencingControl() function. This function allows you to easily move the arm to a specific position.

The IKSequencingControl() function takes parameters.The snapper arm only uses 8 of these parameters. The 'Wrist Roate' parameter should be set to a '0' value.

Parameter # Cartesian Mode Cylindrical Mode Backhoe Mode
1 X-Axis Base Servo Rotation
2 Y-Axis Coordinate Shoulder Servo Rotation
3 Z-Axis Coordinate Elbow Servo Rotation
4 Wrist Angle ° Wrist Servo Rotation
5 Wrist Rotate
6 Griper Servo Rotation
7 Delta Value (milliseconds)
8 Pause Value (Milliseconds)
9 Enable

For example, in cartesian mode, the following line will move the arm to (0,150,150) (X,Y,Z) with a 0° wrist angle, and the gripper closed. It will move over a period of 2 seconds and wait for one second after pose completion.

IKSequencingControl(0 , 150 , 150 , 0 , 0 , 0 , 2000 , 1000, 1);

Adjusting Timing

You can fine tune each pose by adjusting the 7th and 8th parameters in the IKSequencingControl() function. Changing the 7th parameter, the delta value will effect the time it takes for the arm to move from its current position to the next position. The previous examples has the arm moving over 2000 milliseconds. If you want the arm to move over 5000 milliseconds, change the code to

IKSequencingControl(0 , 150 , 150 , 0 , 512 , 0 , 5000 , 1000, 1);

Changing the 8th parameter, the pause value will effect the time the arm waits after the pose is completed. The previous examples has the arm waiting for 1000 milliseconds. If you want the arm to move to the next position immediately, change the code to

IKSequencingControl(0 , 150 , 150 , 0 , 512 , 0 , 2000 , 0, 1);

Manually Adjusting Values

Using the Arm Link Software is the best way to generate values for the arms, as it will check limits and let you try out the arm. However it is possible to manually create your own poses from scratch. See the Arm Limits tables to see the ranges of values you can use for each arm/parameter. NOTE:The delta value listed in the previous tables does not apply to the IKSequencingControl() function. See 'Adjusting Timing' above for instructions on adjusting the delta value.

Interrupting Sequences

Once you have sent an command for the arm to move and it has begun moving, the individual pose cannot be interrupted - it will always complete the pose.

The SnapperArmPlayback code can stop a sequence after any pose via the pushbutton. This is because the pushbutton is attached to an interrupt pin. When a change is made to this pin (such as the pushbutton being activated), the currently running code is paused and special interrupt code is executed. This code sets the playState variable to 0. Any further IKSequencingControl() calls do not execute arm movements because this enable is turned off.

It is also possible to insert additional code in the IKSequencingControl() function to check for additional conditions. This will allow you to interrupt the sequence based on other conditions (like serial events, analog data, and other non-interrupt digital pins).


Advanced Pushbutton Options

If you are NOT using a pushbutton (and instead are relying on the serial terminal or automated sequences) you will need to change line 41 from

#define USE_BUTTON true

to

#define USE_BUTTON false

This will disable the code from trying to read the digital pin (and possible reading noise/activating the arm)

If you are using a Pushbutton with Jumper Wires or any other 2-wire momentary switch, change line 45 should be

#define BUTTON_TRUE LOW

Changing this #define will set the logic up and the pull up resistor for your pushbutton.

If you are using a RobotGeek Pushbutton or a pushbutton with a built in pull-down resistor, you can leave the define as-is.

#define BUTTON_TRUE HIGH

×

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