roboplus tutorial

71
http://support.robotis.com/ Screen Output [ Learning Goal ] Print 1 and 2 on screen. [ STEP 1 ] Write Task Code 1. Execute RoboPlus Task Program As seen in the picture below, select "Start >> All Programs >> ROBOTIS >> RoboPlus >> Software >> RoboPlus Task" to execute RoboPlus Task. - RoboPlus Task Initial Screen

Upload: roni-nepology

Post on 27-Apr-2015

1.826 views

Category:

Documents


10 download

TRANSCRIPT

Page 1: Roboplus Tutorial

http://support.robotis.com/

Screen Output

[ Learning Goal ] Print 1 and 2 on screen.

[ STEP 1 ] Write Task Code

1. Execute RoboPlus Task Program As seen in the picture below, select "Start >> All Programs >> ROBOTIS >> RoboPlus >>

Software >> RoboPlus Task" to execute RoboPlus Task.

- RoboPlus Task Initial Screen

Roni Setiawan
Top Secret
Page 2: Roboplus Tutorial

http://support.robotis.com/

2. Select a Controller Double click an empty line or press "Enter", In the <Select Controller> window, select the

controller to use, then press the <OK> button.

3. Generating "Start Program" Select "Start program" from the <Select Instruction Type> window, "Start Program" will be

automatically generated in RoboPlus Task.

Page 3: Roboplus Tutorial

http://support.robotis.com/

4. Input "Endless Loop" command To print the numbers on the screen endlessly, use the "Endless Loop" command. (Create a

command line)

Double click or press "Enter" on an empty line between "{ "and" }" of Start Program to invoke

the "Select Instruction Type" window. Select "Loop >> Endless Loop(while(1))" from the

list..

5. Input "Load" command Use "Load" command to input a "Print" command, which is needed to print numbers on the

screen.

Insert "Execute >> Load (Assignment value)" into an empty line between "{"and" }" of

"endless loop".

6. Load "1" into "Print" Choose the left parameter ( ? ) among the "Load" parameters. (Explanation on the parameter)

The left parameter receives input from the right parameter.

Double click the left parameter ( ? ), or press "Enter" key after clicking it once to invoke the

"Select Parameter Window".

Select "Controller >> Print" then press "OK".

Page 4: Roboplus Tutorial

http://support.robotis.com/

Select "Constant Numbers >> Number >> 1" for the right parameter ( ? ) in the same way.

When both parameters of the "Load" command have been set, it should look like below.

Page 5: Roboplus Tutorial

http://support.robotis.com/

7. Load "2" into "Print with Line" Select "}" under 'Print' command (at the end of the endless loop section), and add new lines by

pressing the "Space" key. Repeat Steps 5 and 6 to input the "Load" command and to input

"controller >> Print with Line" and "2." The final task code is shown below.

Page 6: Roboplus Tutorial

http://support.robotis.com/

8. Save Task Code

Press Ctrl + S or the Save( ) icon.

[ STEP 2 ] Download Task Code

Download the task code created in [STEP 1].(How to Download Task Code)

[ STEP 3 ] Execute Task Code

1. Open the Program Output Monitor To see the output of the program, you must open the Program Output Monitor BEFORE

executing the program.

There are three ways to open the Program Output Monitor.

1. Click on the View Print of Program in the Download Program window

2. Click on the View Print of Program( ) button in TOOLS.

3. Press F5 or click on View Print of Program (V) menu under Program (P).

2. Executing the Program When you turn on the controller, the LED will blink, showing it is in standby mode. Press the

MODE button to move it to PLAY, then press START to execute the downloaded task code.

You should see "1" and "2" being printed on the Program Output Monitor.

Page 7: Roboplus Tutorial

http://support.robotis.com/

Button & LED

[ Learning Goal ] Program the U button to turn the AUX LED on and the D button to turn it off.

Pressing the START button will end the program.

1. Create Task Code

2. Download Task Code

Download the task code you created to your controller. (How to Download Task Code)

3. Execute Task Code

Execute the program and check whether the AUX LED turns on when you press the U button

Page 8: Roboplus Tutorial

http://support.robotis.com/

and turns off when you press the D button. Press START to end.

walking motions in this motion file.

Walking Motion File : BIO_PRM_WalkingMachineExam_EN.mtn

Task Code : BIO_PRM_WalkingMachineExam_EN.tsk

Let’s use the <Walking Machine> to learn about how walking motions are converted smoothly.

[ STEP 1 ] Walking Motion File Overview

※ Walking Motion File

The walking motion files used in the Walking Machine can be found on pages 31~224. Several motion

pages are gathered and repeatedly played to make up one walking pattern (forward, backward, etc). Each

page is made to be conveniently converted to the next walking pattern’s motion page.

※ The walking patterns written in the Walking Motion File

The walking motion files used in the Walking Machine contain 16 different walking patterns shown

below.

Forward Backward Left Turn Right Turn

Page 9: Roboplus Tutorial

http://support.robotis.com/

Walk Sideways + Left Walk Sideways + Right Turn Left + Forward Turn Right + Forward

Backward + Left Backward + Right Avoid Left Avoid Right

Forward + Left

Diagonally

Forward + Right

Diagonally

Backward + Left

Diagonally

Backward + Right

Diagonally

[ STEP 2 ] Walking Machine Task Code Overview

The walking machine task code includes a "InitializationWalk” Function and a "WalkExecute" function.

There are samples that use these 2 functions to control the robot with a remote controller.

※ [InitializationWalk] Function

The "InitializationWalk" function initializes the variables and brings the robot to its default position.

Page 10: Roboplus Tutorial

http://support.robotis.com/

※ [WalkExecute] Function

The "WalkExecute" function executes each walking pattern and smoothly joins the walking pattern.

※ Walk Command No.

No. Walking Pattern No. Walking Pattern No. Walking Pattern No. Walking Pattern

1 Forward 2 Backward 3 Left Turn 4 Right Turn

5 Walk Sideways +

Left 6

Walk Sideways +

Right 7 Turn Left + Forward 8

Turn Right +

Forward

9 Backward + Left 10 Backward + Right 11 Avoid Left 12 Avoid Right

13 Forward + Left

Diagonally 14

Forward + Right

Diagonally 15

Backward + Left

Diagonally 16

Backward + Right

Diagonally

Page 11: Roboplus Tutorial

http://support.robotis.com/

※ Start Program

Let’s try writing a simple “Start Program” sample using the "InitializationWalk" function and

"WalkExecute" functions to smoothly connect walking patterns.

1. First, call the "InitializationWalk" function to initialize the variable and to bring the robot to its

default position.

2. Select and input a walking pattern between 0 and 16 for the "WalkCommand" variable, then call

the "WalkExecute" function to run the selected walking pattern.

3. When you input a different number in the "WalkCommand" variable and call the "WalkExecute"

function, it will convert to the new walking pattern as naturally as possible.

There are 16 different walking pattern sample codes to control via remote control in the walking

machine's task code file. Change the "Start Program" function in the sample codes to suit your needs.

Adjustment Using the Gyro Sensor

Prerequisite : Walking Machine Code to control the gyro sensor will be added to the task code used in the "Walking Machine" section.

Review the “Walking Machine" section before getting started.

[ Learning Goal ] Learn how to adjust a humanoid’s posture using a gyro sensor.

Page 12: Roboplus Tutorial

http://support.robotis.com/

A Gyro sensor is used to determine angular velocity (angular variation per second). When the robot tilts

and angular velocity increases in a specific direction, the servo motor's value can be adjusted in the

opposite direction to straighten the robot.

TASK CODE : BIO_PRM_GyroSensorExam_EN.tsk

[ THINGS TO PREPARE ]

The gyro sensor’s X-axis value should be connected to port #3, and Y-axis value should be

connected to port #4.

Other than that, modify the task code to suit your robot.

[ STEP 1 ] Concept

Callback function A humanoid with a gyro uses the "callback function " to determin the posture adjustment value.

The callback function is a function that runs independently of the main program routine and is

automatically executed at fixed intervals. Therefore, by calculating the adjustment value and

using the value in a callback function to adjust the posture at regular intervals, the robot can

adjust its posture automatically.

Joint Offset The joint off set is added to the adjustment value from the gyro sensor before being used to adjust

the humanoid’s posture. (More information on Joint Offset) This is a parameter that gives an

offset to the specific actuator’s joint position value. Thus, the actuator with joint offset execute

their motions using the position value + joint offset value, which are designated in the motion file.

[ STEP 3 ] Task Code Overview

1. <InitializationGyro> Call Function

2. Execute "BalancePage" to Apply Joint Offset

In order to apply the joint offset a motion must be executed. When no motion is being played, the joint

offset will not be applied even if a value is input by the gyro sensor. A BalancePage is used to apply

the joint when no motion is being executed.

Page 13: Roboplus Tutorial

http://support.robotis.com/

3. <InitializationGyro> Function

The "InitializeGyro" function reads the gyro sensor value 10 times in a 0.128 second intervals and

saves the average value as a gyro sensor standard value. (The standard value is Approximate 250

degrees.) If the gyro sensor value is less than 230 or greater than 270, it assumes there is no gyro

sensor and does not use adjustment (when there is no gyro sensor or the robot has moved during

initialization).

4. Calculating the adjustment value in the Callback function

At regular intervals, the callback function reads the current gyro sensor value and compares it to the

standard value to calculate the adjustment value.

If the "UseGyro" variable is false, the robot it will not adjust itself. Thus, set the “UseGyro” variable

to false where you do not wish to use the gyro adjustment.

Page 14: Roboplus Tutorial

http://support.robotis.com/

Apply the calculated adjustment value to the joint offset and adjust the robot’s posture. To adjust the

front/back tilt, you must use the joints in the knees and ankle, which are actuators 13-16. To adjust

the left/right tilt, you must use the joints in the ankle and waist, which are actuators 9-10 and 17-18.

[ STEP 4 ] Adjustment Test

Download the task code to your robot.

In order to initialize the gyro, you must leave your robot on flat ground for at least 1.5 seconds

after executing the task code. If the gyro sensor is not connected or if there is movement while

initializing the gyro, the gyro will not make any adjustments.

Check whether the robot attempts to adjust itself when its posture is changed by a strong outside

force while standing straight.

Compare the robot's actions when it uses and does not use a gyro while stanind on a slope.

Page 15: Roboplus Tutorial

http://support.robotis.com/

Callback Function

Callback function is a function that runs independently of the main program routine and is automatically

executed at fixed intervals. Therefore, a callback function cannot include code that requires much time. Use of

loops, variables, and function calls are limited.

Usage

The callback function cannot exist inside another function or program body. There can be only one callback function. A callback function does not have a name and cannot be called.

Example

This example shows how periodically receive wireless data and to save it in a variable.

Joint Offset

To apply the joint offset to a robot, a motion must be performed after the "Joint Offset" parameter is set.

Page 16: Roboplus Tutorial

http://support.robotis.com/

This parameter can be applied to each joint separately.

Compatible Controller

CM-5 CM-510 CM-700

Characteristics

-255 ~ 255 : The offset will be applied to the selected joint's location value. Ex) If the location value of the joint with ID #3 is set as 300 → 400 → 500 in the motion data, and the joint offset is -100, the actual location value of the joint will be adjusted to 200 → 300 → 400.

1024 : If the joint offset is set to 1024, the selected joint will not be affected by the motion data during operation. Ex) This function can be used to control the location values directly, instead of the motion. A primary example is the Gripper, which should not move when a motion is being performed.

Example

Set an offset value to a specific joint While motion page #3 is being performed, set the offset of the joint with ID 4 as -100, and wait for the motion to finish.

Keep a joint from being affected by motion data Set up joint ID #4 to be unaffected while a motion is being executed.

User-defined Motions 1 : Create Motion

Prerequisite : Walking Machine Motions will be added to the motion file used in the "Walking Machine" section. Review the "Walking

Machine" section before getting started.

[ Learning Goal ] Add a new motion using RoboPlus Motion

Let’s learn how to add the follwing 4 motions using the RoboPlus Motion program.

Motion Page No Movement Description Motion Page No Movement Description

14 Block ball on the right 27 Get up while lying on stomach

16 Block ball on the left 28 Get up while lying on back

Motion File : BIO_PRM_UserMotionExam_EN.mtn

Page 17: Roboplus Tutorial

http://support.robotis.com/

[ STEP 1 ] Make a motion to block a ball on the right

1. Execute RoboPlus Motion, then connect it to the controller. (Please refer to Connect Robot)

2. To add the “Block Ball” motion in page 14, input a name and step.

3. Turn off all motors, then set the robot’s pose. The "Block ball on the right" pose is shown below.

Page 18: Roboplus Tutorial

http://support.robotis.com/

4. Set the robot’s pose as above. When you press the "torque on" button, the robot’s current actuator

values will automatically be saved. When you press the left arrow button, you can read the robot’s

current input actuator values into Step’s Pose column.

5. You can adjust the pause and play durations. (Click here for more information on STEP

STOP/PLAY)

Page 19: Roboplus Tutorial

http://support.robotis.com/

6. Designating the NEXT page as itself(14) will cause the robot to enter an infinite loop and

maintain its pose. Also designate an EXIT page for the robot to smoothly transiton into when it

exits the infinite loop.

7. Make a motion to return to the standard position on the page designated as the Exit page (15).

Add the following 3 steps and poses to page 15.

8. Additional settings (Number of Repeats, Play Speed, etc…)

You can also set the number of repeats, entire speed, etc. for each page.

Page 20: Roboplus Tutorial

http://support.robotis.com/

[ STEP 2 ] Make a motion to block a ball on the left

Repeat STEP 1 to make a motion to block a ball on the left on pages16 and 17.

[ STEP 3 ] Make motions to get up when the robot lying on its back and chest.

Add the following steps in motion page 27 and 28 to make a "Get up while lying on stomach" and

"Get up while lying on back" motions.

[ Get up while lying on stomach ]

Page 21: Roboplus Tutorial

http://support.robotis.com/

[ Get up while lying on back ]

Page 22: Roboplus Tutorial

http://support.robotis.com/

[ STEP 4 ] Save

Use the "Save (S)" command to save your work in the robot or use “Save As (A)" to save as an

.mtn file in your PC.

User-defined Motions 2 : Task Code

Prerequisite : Adjustment using the Gyro Sensor, User-defined Motions 1 : Create Motion Code to execute user-defined motions will be added to the task code used in the "Adjustment using the

Page 23: Roboplus Tutorial

http://support.robotis.com/

Gyro Sensor" section. The motion file is from the " User-defined Motions 1 : Create Motion” section.

Review the two sections before getting started.

[ Learning Goal ] Write task code to execute user-defined motions.

Let’s learn how to run the motion added on " User-defined Motions 1 : Create Motion " with the RC-100.

Motion File : BIO_PRM_UserMotionExam_KR.mtn

Task Code : BIO_PRM_UserMotionExam_KR.tsk

[ STEP 1 ] Task Code Overview

Code to execute user-defined motions has been added to the task code written in "Adjusting using

the Gyro Sensor."

Page 24: Roboplus Tutorial

http://support.robotis.com/

1. Set "WalkCommand" as 0 to make the robot stop.

2. If the motion added by the user does not require the gyro sensor to maintain posture, you

must turn off the gyro sensor adjustment to prevent motion variation due to the offset. Set

the "UseGyro" variable as FALSE. Then call the "EXITPageWaitMotion" function and

wait for the robot to come to a complete stop.

3. The “Getting Up” motions added in motion pages 27 and 28 can be played just once.

Thus, execute the motion, and wait for the motion to finish before executing another

motion.

4. The “Block Ball” motions added in motion page 14 and 16 are endlessly repeating

motions. Thus, in order to end the motion, an EXIT page is needed. Using the "WAIT

WHILE" command so that if the button is not pressed and held, the

"EXITPageWaitMotion" function will execute the EXIT to end the motion.

(Click here to see more information on the “Motion Page” parameter.)

Page 25: Roboplus Tutorial

http://support.robotis.com/

5. After the user's motion ends, set the "UseGyro" variable back to TRUE to restore gyro

adjustment.

Page 26: Roboplus Tutorial

http://support.robotis.com/

Dynamixel Management

Dynamixels used as robot actuators possess many functions. This section explains how to change the

dynamixel's settings.

Changing the ID

Here’s how you can change the ID.

1. Select the port the controller is connected to.

2. Click “Connect”.

3. A list of connected dynamixels is shown on the left. Click on the dynamixel you wish to change the

ID of.

4. Click on the ID row in the Control Table.

5. Click on the ID List combo box to see a list of possible ID's. Select the ID, then click Apply.

[Precautions when changing the ID ]

To use in RoboPlus Motion and RoboPlus Task, the ID must be within the following ranges.

Page 27: Roboplus Tutorial

http://support.robotis.com/

o The Dynamixel’s ID must be between 0 and 25.

o The ID for AX-S1 should be set between 100 and 109.

Changing the Movement Mode

The dynamixel can operate in 2 different modes.

Wheel Mode : Rotates 360 degrees like a regular motor. Joint Mode : Moves at a set angle with normal servo motors.

The mode can be changed using RoboPlus Manager. Once the mode is set, it will be maintained, even when

turned off.

Select the port the controller is connected to.

1. Click “Connect”.

2. A list of connected Dynamixels is shown on the left. Click on the Dynamixel you wish to change the

mode of. Then, click on the CW/CCW Angle Limit line in the Control Table.

3. To set to Wheel Mode, change the CW/CCW Angle Limit value to “0.” Or, simply click on the "Wheel

Mode" button.

4. To set to Joint Mode again, set the CW/CCW Angle Limit value to any number other than "0".

The initial values for Joint Mode are "0" for CW Angle Limit, and "1023" for CCW Angle Limit.

Page 28: Roboplus Tutorial

http://support.robotis.com/

Troubleshooting

If you cannot find the dynamixel you are looking for using RoboPlus Manager, try the following :

1. Connect just 1 Dynamixel and check if there are any duplicate IDs. If you see a Dynamixel on the left even though only 1 Dynamixel is connected, there is a high probability of a duplicate ID. Change the ID immediately.

2. If you are unable to find any Dynamixels as in the image below, click on "Dynamixel Search". If the communication speed is not set to 1Mbps, the "Dynamixel Search" function automatically resets the controller’s communication speed to 1Mbps to enable it to be recognized.

If the problem persists, your dynamixel may need repair. Please contact the service department of the company

you purchased from.

Make your own sensor

You can make your own sensor with simple control functions using the ADC port and OUT port on CM-510.

[ WARNING ] Connecting poorly designed circuits may damage the controller. Please be sure to acquire

sufficient knowledge about circuits beforehand.

Page 29: Roboplus Tutorial

http://support.robotis.com/

PIN Information

Below is a pin diagram of CM-510’s external port.

(You should change the resistor if you use high flux LED.)

1. OUT : 5V Output 2. VCC (5V) 3. ADC : Can read analog signals made by users. 4. GND 5. NC : Not used

NOTE : Please use the 5P Cable when using other sensors. The 5P cable can be purchased

from ROBOTIS

Controlling User’s Device

[ External Output Control ]

Below is an example of an LED circuit to turn the LED on and off using the OUT port (pin 1) .

A high signal can be sent to the OUT port using RoboPlus Task.

1. Select the user's device in the writable parameter such as LOAD and CALCULATE, then select the port

on which the device is connected.

2. Then, set the high signal to the readable parameter using a constant.

Page 30: Roboplus Tutorial

http://support.robotis.com/

When the code above is executed, 5V signal will be sent to the OUT port of the device connected to

PORT 3, and the LED will turn on.

[Reading the ADC Value]

Most of the sensors used in robots, such as IR sensors and distance sensors, support analog output. The CM-510

can use its external ports to read the sensor’s analog output signals. These sensors may be designed by the user

or bought from a store.

Below is an image of a tilt sensor. It receives 5V and outputs analog signals in between 0V and 5V depending

on how much it tilts.

The left pin of the tilt sensor is 5V VCC. The center is an analog signal output pin, and the right pin is GND. This sensor can be used by connecting its pins to the corresponding pins on CM-510’s external port. To try for yourself, please refer to the pin information for CM-510’s external ports.

Page 31: Roboplus Tutorial

http://support.robotis.com/

You can incorporate the sensor’s analog output to your robot's movements as in the example below.

Gyro Sensor

Part Photo

[ Gyro Sensor ]

Product Usage

Measures angular velocity. Calculates which side the robot is tilted or is getting more power. Maintains the robot’s balance and can be used for other movement applications.

Page 32: Roboplus Tutorial

http://support.robotis.com/

Pin Layout Information

[ X Axis Pin ]

1. ADC : Outputs the angular velocity into analog signals. 2. GND 3. VCC ( 5V )

[ Y Axis Pin ]

4. VCC ( 5V ) 5. GND 6. ADC : Outputs the angular velocity value into analog signals.

Analog Signal Output in Regards to Sensor’s Environment

Output Value 455

250

45

Angular Velocity +300 ˚/s 0 ˚/s -300 ˚/s

Voltage Value 2.23 V 1.23 V 0.23 V

(Standard VCC Voltage Value is 5V.)

When the angular velocity is 0 (when still), the output value is approximately 250. When it suddenly turns to one axis, the max value output is 455 and the minimum 45, showing a 300 ˚/s angular velocity. Here the mark or sign represents direction.

Depending on the temperature, there may be 1% difference. There may be a difference in value depending on the standard VCC voltage value and circuit noise. Thus, we

recommend to average several values before use. (When sampling, the robot must not be moving.)

You can READ the value using the User’s Device Parameter in RoboPlus Task.

You may sample it out like below. It reads 10 values per 0.1 sec and makes an average. This value can be used as the standard value.

Page 33: Roboplus Tutorial

http://support.robotis.com/

H/W Specification

Weight : 2.8 g Size : 23mm * 23mm* 10mm Working Temperature : -40℃ ~ 85℃ Angular Velocity Calculation Range : -300˚/s ~ 300˚/s

Recommended Voltage Supply : 4.5 ~ 5.5 V

Compatible Controllers

CM-510 CM-700

RoboPlus Task Supports

Refer to the RoboPlus Task directions.

User's Devices

This parameter is used to set or read the values of user's devices.

(Please refer here to see more information on developing your own sensor.)

Page 34: Roboplus Tutorial

http://support.robotis.com/

Compatible Controller

CM-510 CM-700

Characteristics

Although the same address is used to read & write values, the actual port pins are different. (Check user's port pin information)

The value read from the user's device is the voltage level of the input port. The value read is a number between 0 and 1023. When the user's device is set as 1, It will deliver 5V to the output port. Setting the user's device as 1 does not guarantee that the value read from the user's device will be 1. The output of the user's device can be set using port value constants.

Example

After setting the user's device at Port 3 as 1 (high), if the value read value from Port 3 is less than 500, the output port is set as 0 (low).

Page 35: Roboplus Tutorial

http://support.robotis.com/

PROGRAMMING

Start Program

"Start Program" designates the beginning of a program. Regardless of the line number, the program will always

start at this point. "Start Program" is like the "main" function in the C language.

Usage

"Start Program" is executed regardless of its line number. A program cannot have more than one "Start Program" command. The body of the command must be enclosed by brackets. The program will end when the closing bracket( } ) is reached.

Example

Start a program with the "Start Program" command.

End Program

If this command is called during program execution, the program exits immediately.

There are 2 ways to end a programme.

When the end of "Start Program" is reached (Natural Close)

When "End Program" is called (Forced Exit)

Page 36: Roboplus Tutorial

http://support.robotis.com/

Usage

Call the command at the point in the program where you want it to end.

Example

In this sample code, the program will end when the touch connected to Port3 is pressed.

Start/End of Block or Section

A block or a section (identified by "{" and "}") is a group of commands. All commands in a block have the

same scope. The concept of a block is the same as in the C language.

Usage

Each block has an opening bracket ({) and a closing bracket (}). RoboPlus Task performs automatic indentation to show whether the brackets have been paired properly. If there are missing brackets, they must be added before the program can run indentation. If they were not arranged properly, you have to revise them by yourself,

Each block must be "owned" by a command. Blocks cannot be used independently with commands.

The followings are the most commonly used commands that are followed by a block.

1 Start Program

2 If / Else if / Else

3 Endless Loop

4 Loop For

5 Loop While

Page 37: Roboplus Tutorial

http://support.robotis.com/

6 Callback Function

7 Function

If a command is made by one line, it is possible to skip the block brackets.

Example

The "Start Program" and "Endless Loop" commands must be followed by blocks, as shown in the

example below.

Calculate

"Calculate" is a command to perform an arithmetic operation on two numbers.

"Calculate" can perform the following operations:

Basic Operations (supports negative numbers) Addition(+): Add two values.

Subtraction(-): Subtract the second number from the first number.

Multiplication(*): Multiply two numbers.

Division(/): Divide the first number by the second number (Remainders are discarded.)

Bit Operations (Means 2 decimal operation.)

AND(&): Perform a logical AND operation.

OR(|): Perform a logical OR operation.

Page 38: Roboplus Tutorial

http://support.robotis.com/

Usage

You can choose an operator by double clicking a mouse or by pressing the Enter key.

Choose the appropriate 3 parameters (result, operand1, operand2) necessary for the command.

Example

This example shows how to add 10 and 20 and to display the result on the screen.

Load

"'Load" is defined as "to place into an appropriate device." In RoboPlus Task, "Load" places a value in a

device.

"Load" is used to mean the following:

Execute a device's function.

Move a value.

Usage

Choose the appropriate 2 parameters (destination, source) necessary for the command.

Page 39: Roboplus Tutorial

http://support.robotis.com/

Example

To execute a device (Set the timer to 1.024 seconds.)

To set a value (Insert 10 into the variable)

Label/Jump

"Label" and "Jump" are used to branch a program. Branching is used to change the order commands in a

program are executed.

"Jump" branches the program and "Label" designates where to branch to.

It is the same function as "Label" and "Goto"' in the C language.

Usage

Label names must abide by the following rules: There cannot be duplicate label names. Label must exist within a program or function body. A jump to a label in another function is not possible. Spaces and Special characters(!, @, #, $, etc.) are not allowed in label names. Labels cannot start with a number.

While inputting the label name, Press Esc to cancel. Otherwise, press Enter to save While selecting the label to jump to, Press Esc to cancel.

Page 40: Roboplus Tutorial

http://support.robotis.com/

Otherwise, click the appropriate label or press Enter while the label is highlighted to save.

A jump can only be made to an existing label.

The label must be in the same function block as the jump command.

Example

In this sample code, the program jumps to "JumpPoint" as soon as it starts and executes"'Routine 2."

If/Else if/Else

These commands will branch the flow of the program depending on whether the condition is true or false.

If : Execute if the clause is true. This is the equivalent of the "if" statement in C language.

Else If: Execute if the clause is true and previous clause ("if" or "else if" clause) is false. This is the

equivalent of the "else if" statement in C language.

Page 41: Roboplus Tutorial

http://support.robotis.com/

Else: Execute if none of the conditions are true. This is the equivalent of the "else" statement in C

language.

What's a Conditional Clause?

Conditional clause is a feature to perform different actions depending on whether the condition evaluates to true

(condition is met) or false (condition is not met).

Conditional clause is composed of the following 3 parts: parameter 1, relational operator, and parameter 2 in

order.

These are 6 types of relational operators.

== : True if the two parameters are equal.

!= : True if the two parameters are not equal.

>= : True if parameter 1 is greater than or equal to parameter 2.

> : True if parameter 1 is greater than parameter 2.

<= : True parameter 1 is less than or equal to parameter 2.

< : True if parameter 1 is less than parameter 2.

Conditional clause can be combined into a complex conditional clause using conditional operators.

A complex conditional clause is composed of the following 3 parts: conditional clause 1, conditional operator,

conditional clause 2.

There are 3 types of conditional operators.

then : Does not link any clauses.

AND(&&): True if both conditional clauses are true.

OR(||): True if one of the conditional clauses is true.

There is no limit to how many conditional clauses can be combined into one complex conditional clause. Each

conditional clause is evaluated in order, and the final value will be either "true" or "false."

Page 42: Roboplus Tutorial

http://support.robotis.com/

Usage

An 'IF' command must always precede an "Else if" or an "Else" command.

A block, designated by brackets, needs to follow each clause. (However, if the block consists of only

one line, the block need not be enclosed with brackets.)

Example

The examples below shows how to program the following conditions.

o When the variable is greater than or equal to 90.

o When the variable is greater than or equal to 50 and less than 90.

o Other cases

Endless Loop

This command is used to repeat the command lines in the block without end.

Page 43: Roboplus Tutorial

http://support.robotis.com/

Usage

A block is always required. (However, if the block consists of only one, the block need not be enclosed with brackets.)

Use the "Break Loop" command to exit the loop.

Example

Continuously prints "10" on the Program Output Monitor.

Loop While

This command is used to repeat the command lines in the block while the clause is true.

It is the equivalent of the "while"function in C language..

What is a conditional clause?

Conditional clause is a feature to perform different actions depending on whether the condition evaluates to true

(condition is met) or false (condition is not met).

Conditional clause is composed of the following 3 parts: parameter 1, relational operator, and parameter 2 in

order.

These are 6 types of relational operators.

Page 44: Roboplus Tutorial

http://support.robotis.com/

== : True if the two parameters are equal.

!= : True if the two parameters are not equal.

>= : True if parameter 1 is greater than or equal to parameter 2.

> : True if parameter 1 is greater than parameter 2.

<= : True parameter 1 is less than or equal to parameter 2.

< : True if parameter 1 is less than parameter 2.

Conditional clause can be combined into a complex conditional clause using conditional operators.

A complex conditional clause is composed of the following 3 parts: conditional clause 1, conditional operator,

conditional clause 2.

There are 3 types of conditional operators.

then : Does not link any clauses.

AND(&&): True if both conditional clauses are true.

OR(||): True if one of the conditional clauses is true.

There is no limit to how many conditional clauses can be combined into one complex conditional clause. Each

conditional clause is evaluated in order, and the final value will be either "true" or "false."

Usage

A block is always required. (However, if the block consists of only one line, the block need not be enclosed with brackets.)

Use the Break Loop command to exit the loop.

Example

Continuously prints the value of on the Program Output Monitor until the variable reaches 30.

Page 45: Roboplus Tutorial

http://support.robotis.com/

Loop For

This command is used to repeat the command lines in the block for the specified number of times. Given an

initial value and a terminal value, the loop will repeat while increasing the variable by 1.

The number of executions can be calculated as:

o Number to Executions = Terminal Value - Initial Value + 1

This is the equivalent of the "for" function in C language.

Usage

Choose the appropriate 3 parameters (variable, Start value, End value) necessary for the command.

The initial value must be less than the terminal value. If the initial value is greater than the terminal value, the loop will not be executed.

A block is always required. (However, if the block consists of only one line, the block need not be enclosed with brackets.)

Use the Break Loop command to exit the loop.

Example

This example will repeat the loop as many as the detected sound quantity.

Page 46: Roboplus Tutorial

http://support.robotis.com/

Break Loop

This command is used to exit the loop while it is being executed.

It is the equivalent of the "break" function in C language.

Usage

The command must always be used in the block being repeated.

Example

Continuously prints the number "10" on the screen until the value of the center IR sensor becomes

bigger than 400, in which case it exits the loop and prints "30" on the screen.

Wait While

This command is used to pause execution when a conditional clause is true.

It is the equivalent of the "while" function in C language.

Page 47: Roboplus Tutorial

http://support.robotis.com/

What is a conditional clause?

Conditional clause is a feature to perform different actions depending on whether the condition evaluates to true

(condition is met) or false (condition is not met).

Conditional clause is composed of the following 3 parts: parameter 1, relational operator, and parameter 2 in

order.

These are 6 types of relational operators.

== : True if the two parameters are equal.

!= : True if the two parameters are not equal.

>= : True if parameter 1 is greater than or equal to parameter 2.

> : True if parameter 1 is greater than parameter 2.

<= : True parameter 1 is less than or equal to parameter 2.

< : True if parameter 1 is less than parameter 2.

Conditional clause can be combined into a complex conditional clause using conditional operators.

A complex conditional clause is composed of the following 3 parts: conditional clause 1, conditional operator,

conditional clause 2.

There are 3 types of conditional operators.

then : Does not link any clauses.

AND(&&): True if both conditional clauses are true.

OR(||): True if one of the conditional clauses is true.

There is no limit to how many conditional clauses can be combined into one complex conditional clause. Each

conditional clause is evaluated in order, and the final value will be either "true" or "false."

Page 48: Roboplus Tutorial

http://support.robotis.com/

Usage

Set the appropriate conditions without the use of blocks.

Example

The program will wait for the timer.

Return Function

When this command is executed, it will end the operating function immediately even if not every command

line was executed yet , and will return to the function called position.

It is the equivalent of the "return" statement in C language.

Usage

Can be used only within a general function or a callback function.

Page 49: Roboplus Tutorial

http://support.robotis.com/

Example

In the following example, UserFunction is called repeatedly. Because of the Return command in UserFunction, the last 3 lines will never be executed.

If the same code need to be repeated multiple times, or if the code needs to be distinguished according to its

role, you can make the code as a function, and can all the function whenever necessary. This is similar to the

concept of a function in C language. The only difference is that there are no return values and input parameters.

When used properly, you can easily figure out the flows of the program, and can avoid to write the same

command lines again and again. Functions are executed by calling them. After a called function ends,

execution will be returned to the point of the calling and started from the next command line.

Page 50: Roboplus Tutorial

http://support.robotis.com/

Usage

The following rules apply when making a function: There cannot be duplicate function names. A function must exist outside another function or program body. Spaces and special characters(!, @, #, $ etc.) are not allowed in function names. Function names cannot start with numbers.

While inputting function names, press Esc to cancel. Otherwise, press Enter to save. While selecting the function to call, press ESC to cancel. Otherwise, click the appropriate function or press Enter while the function is highlighted to save.

A function cannot call itself.

Example

The program will continuously call the functions to move forward, backward, right and left.

Callback Function

Callback function is a function that runs independently of the main program routine and is automatically

executed at fixed intervals. Therefore, a callback function cannot include code that requires much time. Use of

loops, variables, and function calls are limited.

Page 51: Roboplus Tutorial

http://support.robotis.com/

Usage

The callback function cannot exist inside another function or program body. There can be only one callback function. A callback function does not have a name and cannot be called.

Example

This example shows how periodically receive wireless data and to save it in a variable.

Page 52: Roboplus Tutorial

http://support.robotis.com/

PARAMMETER

Remocon TXD

This parameter is used to transmit data via a wireless communication module (IR, zigbee module).

Compatible Controller

CM-100 CM-5 CM-510 CM-700

Characteristics

The data must be a number/value between 0 & 65535 transmitted or sent, wirelessly (IR or Zigbee).

When the "Remocon TXD" parameter is set, the data is immediately sent wirelessly.

Example

In the example below, the program waits for data, and when the data arrives, the received data is

transmitted wirelessly.

Tip

It is commonly used to send a response to the control program on a PC connected using ZIG2Serial.

Page 53: Roboplus Tutorial

http://support.robotis.com/

Remocon RXD

This parameter is used to read the received data received via the wireless communication module (IR, zigbee

module).

Compatible Controller

CM-100 CM-5 CM-510 CM-700

Characteristic

The data is a number between 0 and 65535.

The "Remocon Arrived" parameter can be used check for new data.

You can save up to maximum 2 wireless data by using a receiving buffer.

When 2 data are saved in the receiving buffer, firstly received data will be read at first, and the

remaining data will be read at second according to the received order. If there is only 1 data value in

the buffer, when READ is executed, the latest data will be retrieved.

Example

The code below shows how to control movement direction using the RC-100.

Page 54: Roboplus Tutorial

http://support.robotis.com/

Remocon Arrived

This parameter is used to check whether there are any new data received via the wireless communication

module(IR, zigbee module).

Compatible Controller

CM-100 CM-5 CM-510 CM-700

Characteristics

Is either TRUE or FALSE

TRUE ( No. 1 ) : There is new data in the input buffer.

FALSE, ( No. 0 ) : All data in the input buffer have been retrieved.

Example

The code below shows how to control movement direction using RC-100.

Page 55: Roboplus Tutorial

http://support.robotis.com/

Tip

Normally used to check whether new data has been received to process.

Aux LED

This parameter is used to read and set the controller's Aux LED status.

Compatible Controller

CM-5 CM-510 CM-700

Characteristics

Is either TRUE or FALSE.

TRUE (1) : When the Aux LED parameter is set to TRUE, the LED will turn on. When the Aux LED parameter is read, a value of TRUE signifies that the LED is on.

FALSE (0) : When the Aux LED parameter is set to FALSE, the LED will turn off. When the Aux LED parameter is read, a value of FALSE signifies that the LED is off. False means that the input buffer

Page 56: Roboplus Tutorial

http://support.robotis.com/

is empty. i.e either no data has been received or all data has been retrieved

Example

In this example, the Aux LED is turned on and off for 1 second 3 times.

Button

This parameter is used to read the controller's button status.

Compatible Controller

CM-5 CM-510

Characteristics

Each button is assigned a unique value as follows. R button : 1, L button : 2, D button : 4, U button : 8, START button : 16 When several buttons are pressed, the value assigned to the pressed buttons are added and read. Even if you do not know the buttons' code values, you can easily determine which buttons have been pressed

by using the buttons' constant values.

Page 57: Roboplus Tutorial

http://support.robotis.com/

Example

This example shows how to perform different motions depending on which button is pressed.

Timer

This parameter is used read the timer's current value or to set the timer, which begins to count down

automatically. The timer is located in the controller.

Compatible Controller

CM-100 CM-5 CM-510 CM-700

Characteristics

You can use "Timer value" constant to set the timer's value.

When a decimal number is entered, it will automatically be converted to the corresponding timer value.

The actual timer value is between 0 and 255. Each timer value is 0.128 seconds. If you set a value greater than 0 in the timer parameter, the timer will start to count down every 0.128 seconds.

Page 58: Roboplus Tutorial

http://support.robotis.com/

Example

The code below will print the value from the Center IR sensor every second.

Remocon ID

This parameter is used to set or read the currently set remote control ID. Please note that the controller will not

receive any data if this parameter does not match the ID of the transmitting remote.

Compatible Controller

CM-5 CM-510 CM-700

Characteristics

The ID is a number between 0 and 65535. When the opponent's ID is set to 65535(0xFFFF, in hexadecimal), it will send data to all Zigbee modules,

regardless of ID.(Broadcasting Mode)

Example

This example sets the opponent's wireless ID to "123", reads the value, and prints it on the screen.

Page 59: Roboplus Tutorial

http://support.robotis.com/

Tip

For seamless Zigbee communication, the opponent's wireless ID must be set to the correct value. Using the broadcasting mode improperly may cause unforeseen problems.

My ID

CM-100 : This parameter is used to determine whether or not a module ZIG-110 module has been installed.

Other Controllers : This parameter is used to read the ID of the Zigbee module installed in the robot.

Compatible Controller

CM-100 CM-5 CM-510 CM-700

Characteristics

CM-100 : If a ZIG-110 wireless communication module is installed, TRUE(1) is returned. Otherwise, FALSE(2), is returned.

Other Controllers : If a ZigBee module is installed, its ID is read (a number between 0 and 65534). If not, 65535 (0xFFFF in hexadecimal) is returned..

Example

This example checks whether a ZIG-110 module is installed in the CM-100 controller. If the module is not installed, it sets the RC-100 channel according to the number of times the start button is pressed.

Page 60: Roboplus Tutorial

http://support.robotis.com/

This example prints the ZigBee module's ID. This code can be used with controllers other than CM-100.

My ID

CM-100 : This parameter is used to determine whether or not a module ZIG-110 module has been installed.

Other Controllers : This parameter is used to read the ID of the Zigbee module installed in the robot.

Compatible Controller

CM-100 CM-5 CM-510 CM-700

Characteristics

CM-100 : If a ZIG-110 wireless communication module is installed, TRUE(1) is returned. Otherwise, FALSE(2), is returned.

Other Controllers : If a ZigBee module is installed, its ID is read (a number between 0 and 65534). If not, 65535 (0xFFFF in hexadecimal) is returned..

Page 61: Roboplus Tutorial

http://support.robotis.com/

Example

This example checks whether a ZIG-110 module is installed in the CM-100 controller. If the module is not installed, it sets the RC-100 channel according to the number of times the start button is pressed.

This example prints the ZigBee module's ID. This code can be used with controllers other than CM-100.

Print Program Output

Controllers usually do not have display devices the way a PC has a monitor, so it is hard to keep track of what

goes on in a controller. Therefore, a "terminal" is used to "borrow" the PC's monitor.

Page 62: Roboplus Tutorial

http://support.robotis.com/

RoboPlus Task includes a terminal program to display the status of the controller.

Open the Program Output Monitor

To see the output of the program, you must open the Program Output Monitor BEFORE executing the

program.

There are three ways to open the Program Output Monitor.

1. Click the 'View Print of Program' on the Download Program window.

2. Click the "View Print of Program" button in the tool bar. 3. Press F5 or Click on "View Print of Program (V)" menu under Program (P).

Print / Print with carriage return

o Use the "Print" parameter in your task code to see desired values on the screen.

Page 63: Roboplus Tutorial

http://support.robotis.com/

o Print : Print the value, then move the cursor to next line.

o Print with New Line: Print out the value, and move the cursor to next line.

Error : Please check the following

o Values from the controller o o A welcome screen is shown when the program starts

o Error messages during program operation ( See types of error messages )

Page 64: Roboplus Tutorial

http://support.robotis.com/

o Values from task code All decimal numbers between -32767 and +32767 can be displayed. (Printing characters or custom messages is not possible.)

o o To print numbers

o To print values from sensors

Clear Screen

You may erase everything on the screen.

Button Count

This parameter is used to read how many times the START button was pressed when the controller was first

turned on.

Compatible Controller

CM-100

Characteristic

"Button Counts" uses numbers between 0 and 255. As a result, only up to 255 button presses can be counted .

Page 65: Roboplus Tutorial

http://support.robotis.com/

Example

The example executes different motions according to how many times the START button was pressed - once, twice, or more.

Powersave Timer

The controller has a hibernate function to conserve battery. If no commands are received for a set period, the

controller can turn itself off. This parameter is used to set how long the controller will wait or how much time

is left.

Compatible Controller

CM-100

Characteristics

"Powersave timer" can be set using powersave constants.

"Powersave timer" uses numbers between 0 and 255. The unit is minutes (i.e., a value of 1 equals 1 minute) The default value is 5 minutes. Setting the "Powersave timer" to 0 will turn it off.

Page 66: Roboplus Tutorial

http://support.robotis.com/

The time remaining on the timer is always in minutes. For example, when 50 seconds remain, the timer will say that 1 minute remains .

Example

The controller will be turned off if no data is received for 2 minutes. If data is received, the timer is reset to 2 minutes.

Tip

To keep the controller from turning itself off even when certain actions are performed, you must manually reset "Powersave timer."

Motion Status

This parameter is used to check the status of the motion.

Compatible Controller

CM-5 CM-510 CM-700

Page 67: Roboplus Tutorial

http://support.robotis.com/

Characteristics

If a motion is being performed, 1 is returned. Otherwise, 0 is returned. True/False can also be used.

True: Motion is being performed. False: Motion is not being performed.

Example

Executes motion page #3 and waits until it is completed.

Joint Offset

To apply the joint offset to a robot, a motion must be performed after the "Joint Offset" parameter is set.

This parameter can be applied to each joint separately.

Compatible Controller

CM-5 CM-510 CM-700

Characteristics

-255 ~ 255 : The offset will be applied to the selected joint's location value. Ex) If the location value of the joint with ID #3 is set as 300 → 400 → 500 in the motion data, and the joint offset is -100, the actual location value of the joint will be adjusted to 200 → 300 → 400.

1024 : If the joint offset is set to 1024, the selected joint will not be affected by the motion data during operation. Ex) This function can be used to control the location values directly, instead of the motion. A primary example is the Gripper, which should not move when a motion is being performed.

Example

Set an offset value to a specific joint While motion page #3 is being performed, set the offset of the joint with ID 4 as -100, and wait for the motion

Page 68: Roboplus Tutorial

http://support.robotis.com/

to finish.

Keep a joint from being affected by motion data

Set up joint ID #4 to be unaffected while a motion is being executed.

Geared Motor

This parameter is used to control the reduction motor's direction and power (Speed).

(Click here to see more information on the reduction motor's parts.)

Compatible Controller

CM-100

Characteristics

The reduction motor's control values can be set using motor control constants. The direction and power must be set together.

CW (Clockwise) CCW (Counterclockwise) : CCW:0 ~ CCW:1023 : Decimal numbers between 0 and 1023 CW:0 ~ CW:1023 : Decimal numbers between 1024 and 2047

The control values are numbers between 0 and 2047.

Example

In this example, the reduction motor connected to Port 1 will rotate in the clockwise direction for 1 second at maximum speed, before rotating in the counterclockwise direction for 1 second. These motions will repeat without end.

Page 69: Roboplus Tutorial

http://support.robotis.com/

Tip

Make sure the motor is connected to the correct port . Speed and direction can be controlled separately using motor control constants. In this example, the motor in Port 1 is set as "CCW:700",and the motor in Port 2 is set as "CW:700."

Servo Motor

This parameter is used to set the movements of servo motors. This parameter consists of 3 sub-parameters

(move mode, speed, location), it helps to set up the movement of servo motor in more detailed way.

(Please refer here to see the explanation about Servo Motor Parts.)

Compatible Controller

CM-100

Page 70: Roboplus Tutorial

http://support.robotis.com/

Characteristics

Movement mode is set as either True or False.

TRUE (1) : Operate in joint mode. In joint mode, the speed parameter is used to configure power output, and the location parameter is used to configure angular movement.

False (0) :Operate in rotation mode. In rotation mode, the servo motor operates like a reduction motor, so only the speed parameter is used. The location parameter is ignored.

Motor control constants can be used to set the speed (power).

CW (Clockwise) CCW (Counterclockwise) CCW:0 ~ CCW:1023 : Decimal numbers between 0 and 1023 CW:0 ~ CW:1023 : Decimal numbers between 1024 and 2047

Location value constants can be used to set the location in joint mode.

Uses decimal numbers between 0 and 1023. The red circle indicates the current values. The value can be set by dragging the jog

dial with your mouse to the appropriate value. The maximum controllable angle is 300 degrees. Thus, the minimum controllable

angle, indicated by the location value of 1, is 0.29 degrees.(300 degrees / 1024 = 0.29 degrees)

For detailed information about controllable angles, refer to the Servo Motor Parts page.

Page 71: Roboplus Tutorial

http://support.robotis.com/

Example

Set the servo motor at Port 3 in rotation mode and turn it clockwise with 600 outputs.

Set the servo motor at Port 3 in joint mode and move it to location 500 with maximum speed.

Tip

Make sure the motor is connected to the correct port. If a program that controls servo motors is executed while another module (LED module, IR module, etc) is

connected to the port, the module may be damaged. The servo motor is not suitable for detailed control, as it lacks the precision and torque of a Dynamixel motor.

.