17.3.1 Quick connection of control test module to RCML

The test control module is used to imitate obtaining axis values from the control devices.

To enable the test module, you need to add the property module and set its value to "test" in section [control_modules] in the configuration RCML file according to Section "Installation and Configuration of RCML Compiler and Interpreter". The test control module does not require additional configuration.

The following is an example of using a test control module in interaction with test robot:

function main() {
	@lr = robot_test; 
	system.hand_control(@lr,"test","X","X");
}

In running this program for 10 seconds, a random value is sent along the X-axis once per second. For functioning of the program, the test robot module should be connected. More detail about connecting is available in section "Quick connection of robot test module to RCML".

The test control module has the following axes available:

Name

The upper limit

The lower limit

Note

X

100

-100

 

Y

1

0

Binary

Z

100

0

 

The values of axes that are transmitted every second:

Name

1

2

3

4

5

6

7

8

9

10

X

100

-30.1

-2.58

48.9

99.01

-100

12.0

-36.9

0.25

0

Y

0

0

0

1

1

0.5

0.25

0.1

0.75

0.35

Z

4.56

0

78.9

100

50

48.8

66.7

32.4

40

20

17.3.2 Quick connection of the keyboard module to RCML

The keyboard control module is used to manually control the robot with the use of a keyboard.

  1. To activate a keyboard module, add entry "property module" to section [control_modules] to the RCML configuration file, and set it equal to keyboard in accordance with section "Installation and Configuration of RCML Compiler and Interpreter".
  2. In the folder of the keyboard module in the control_modules directory, create the config.ini module configuration file. 
  3. The configuration file of the keyboard module describes which axes are available to the programmer for interaction with the robot in the manual mode. To add a new axis, adhere to the following rules of describing it:

3.1. In case of adding a new axis, add axis name property to section [mapped_axis] and set it equal to the value of the keyboard key in HEX format; there may be several keyboard button values for one axis. In general, an entry in the [mapped_axis] section will look as follows:

axis_name = keyboard_button_value_in_HEX_format

3.2. You should set the maximum and the minimum values that the axis may take. To do so, add to the config.ini configuration file a section named as the name of the axis, and set the upper_value and lower_value properties for passing the values of the axis' maximum and minimum. In general, the section looks as follows:

[axis_name]
upper_value = the_max_axis_value
lower_value = the_min_axis_value

3.3. Next, you should determine what value the axis will have after a previously defined button on the keyboard is pressed. The values are defined by creating a section with the name consisting of the axis name and the value of keyboard button in Hex format, separated by underscores. To set the default (not pressed) and pressed state values, unpressed_value and pressed_value are used, where the values are passed. In general, the section in this case will look as follows: 

[axis_name_keyboard_button_value_in_HEX_format]
pressed_value = axis_value_with_pressed_button
unpressed_value = axis_value_with_released_button
 

For clarity, here is an example of configuration for the keyboard module with comments

;Section for Linux
[options]
input_path = /dev/input/event2; Path to the input stream file

;Mandatory section
[mapped_axis]
;axis_name = key_code (in HEX format)
go = 0x26; up_arrow
go = 0x28;down_arrow

;Description of the go axis, should always have both keys
[go]
upper_value = 1 ;Upper limit of axis values
lower_value = -1 ;Lower limit of axis values

;Description of the go axis behavior for the *up_arrow* key (0x26)
[go_0x26]
pressed_value = 1 ;If *up_arrow* is pressed, the axis value to be set to 1
unpressed_value = 0 ;If *up_arrow* is released, the axis value to be set to 0

;Description of the go axis behavior for the *down_arrow* key (0x28)
[go_0x28]
pressed_value = -1 ;If *down_arrow* is pressed, the axis value to be set to 1
unpressed_value = 0 ;If *down_arrow* is released, the axis value to be set to 0

An example of a module configuration description includes one go axle, which will return the maximum value of 1 when up arrow is pressed, and 0 when it is released, or -1 when the down arrow is pressed, and 0 when it is released. More detailed information about the axes and manual control is available in section "General Information".

As an example, an advanced configuration file of the keyboard module is provided, where the following axes are initialized:

  • [go] – up and down arrows are used as control buttons;
  • [rotate] – the axis is controlled by left and right arrows;
  • [locked] – used to lock the robot by pressing the "A" button on the keyboard.

The following is a listing of the configuration file of the keyboard module with three axes:

[mapped_axis]
go = 0x26
go = 0x28
rotate = 0x25
rotate = 0x27
locked = 0x41

[go]
upper_value = 1
lower_value = -1

[rotate]
upper_value = 1
lower_value = -1

[locked]
upper_value = 1
lower_value = 0

[locked_0x41]
pressed_value = 1
unpressed_value = 0

[go_0x26]
pressed_value = 1
unpressed_value = 0
	
[go_0x28]
pressed_value = -1
unpressed_value = 0

[rotate_0x25]
pressed_value = 1
unpressed_value = 0

[rotate_0x27]
pressed_value = -1
unpressed_value = 0

The following is an example text of a program in the RCML. The program invokes the test robot, which had been connected according to section "Quick start" and looks as follows:

function main() {
	@tr = robot_test; 
	system.hand_control(@tr,"keyboard","X","go");
}

The first line of code creates a variable that is attached to the test robot; information about what a test robot is, and how to connect to it is available in Section "Quick connection of robot test module to RCML".

The second line switches the test robot to manual control mode. As previously described, the go axis takes its value depending on pressed up and down arrows, and has the maximum value 1 and the minimum value -1, which translates their X-axis of the robot. However, during the program execution, the value of the axis of the control device will not be equal to the value of the axis of the robot. The axis is automatically scaled, i.e., the maximum value of the key is converted into the maximum axis value of the robot. A similar situation is observed when the down arrow button is pressed. The keyboard control module gets the minimum value of the keypad axis, and converts it to the minimum value of the robot axis. Thus, when the up arrow is pressed, the test robot will announce that it will move to the maximum position 100, and when the down arrow is pressed, it will move to -100.

The test robot has two extra axes - Y, Z. Using the configuration file of the keyboard module described in step 3, let us add one more robot control axis. Let there be the "rotate" axis value passed along the existing values to the Z-axis of the test robot. The program code in this case will be as follows:

function main() {
	@tr = robot_test; 
	system.hand_control(@tr,"keyboard","X","go","Y","rotate");
}

During the program execution, pressing the up or down arrows will call a test message from the robot, stating that a command has been received to change the values on the X-axis and Y-axis, when the left or right buttons are pressed. With that, the values received by the robot will be the maximum for these axes.

More information about manual control is available in Section "Hand Control Mode".

17.3.3 Quick connection of gamepad module to RCML

The gamepad control module ensures manual robot control with the use of a gamepad.

The number of the used axes depends on the contents of the config.ini module configuration file. The maximum number of axes that can be defined in the configuration file is 18, including:

  • 11 binary axes corresponding to buttons;
  • 4 axes for the sticks;
  • 2 axes for the D-pad;
  • 1 axis named "Exit" assigns the manual completion function to a button.
  1. To activate a gamepad module, add entry "property module" to section [control_modules] to the RCML configuration file, and set it equal to «gamepad» in accordance with Section "Installation and Configuration of RCML Compiler and Interpreter".
  2. Next, go into the RCML modules folder where control modules (control_modules) are located, then go to the «gamepad» folder.
  3. Create an empty config.ini file in the «gamepad» folder. Later, this file will be used for joystick configuration.
  4. Next, configure the config.ini configuration file of the module. It is proposed to use one of the two ready module configurations that are suitable for most gamepads:

4.1. The universal module configuration file for interaction with gamepad No. 1

[axis]
Exit = 9
B1 = 1
B2 = 2
B3 = 3
B4 = 4
L1 = 7
L2 = 5
R1 = 8
R2 = 6
start = 10
T1 = 11
T2 = 12
RTUD = 13
RTLR = 16
LTUD = 15
LTLR = 14
arrowsUD = 17
arrowsLR = 18

[B1]
upper_value = 1
lower_value = 0
	
[B2]
upper_value = 1
lower_value = 0
	
[B3]
upper_value = 1
lower_value = 0
	
[B4]
upper_value = 1
lower_value = 0
	
[L1]
upper_value = 1
lower_value = 0
	
[L2]
upper_value = 1
lower_value = 0
	
[R1]
upper_value = 1
lower_value = 0
	
[R2]
upper_value = 1
lower_value = 0
	
[start]
upper_value = 1
lower_value = 0
	
[T1]
upper_value = 1
lower_value = 0
	
[T2]
upper_value = 1
lower_value = 0
	
[RTUD]
upper_value = 0
lower_value = 65535
	
[RTLR]
upper_value = 0
lower_value = 65535
	
[LTUD]
upper_value = 0
lower_value = 65535

[LTLR]
upper_value = 0
lower_value = 65535
	
[arrowsUD]
upper_value = 1
lower_value = -1
	
[arrowsLR]
upper_value = 1
lower_value = -1
4.2. The universal module configuration file for interaction with gamepad No. 2:
[axis]
Exit = 9
B1 = 4
B2 = 2
B3 = 1
B4 = 3
L1 = 5
L2 = 7
R1 = 6
R2 = 8
start = 10
T1 = 11
T2 = 12
RTUD = 16
RTLR = 13
LTUD = 15
LTLR = 14
arrowsUD = 17
arrowsLR = 18
	
[B1]
upper_value = 1
lower_value = 0
	
[B2]
upper_value = 1
lower_value = 0
	
[B3]
upper_value = 1
lower_value = 0
	
[B4]
upper_value = 1
lower_value = 0

[L1]
upper_value = 1
lower_value = 0

[L2]
upper_value = 1
lower_value = 0

[R1]
upper_value = 1
lower_value = 0
	
[R2]
upper_value = 1
lower_value = 0
	
[start]
upper_value = 1
lower_value = 0

[T1]
upper_value = 1
lower_value = 0

[T2]
upper_value = 1
lower_value = 0

[RTUD]
upper_value = 0
lower_value = 65535

[RTLR]
upper_value = 0
lower_value = 65535
	
[LTUD]
upper_value = 0
lower_value = 65535

[LTLR]
upper_value = 0
lower_value = 65535

[arrowsUD]
upper_value = 1
lower_value = -1
	
[stick_zero_positions]
axis_1 = 31487
axis_2 = 31487
axis_3 = 31487
axis_4 = 31487
arrows = 4294967295

[options]
input_path = /dev/input/js1

[arrowsLR]
upper_value = 1
lower_value = -1

If ready module configuration files are used, steps 5 through 8 should be skipped. If the configuration files do not provide the desired level of control, it is necessary to additionally perform the skipped steps.

Before proceeding to controlling a real physical robot, it is recommended to validate the configuration of «gamepad» on a test robot, the methods of connecting the test robot to RCML is available in Section "Quick connection of robot test module to RCML".

5. Make sure the gamepad is connected to the computer. Otherwise, when the 'calibrator.exe' is executed further, a ‘cant CreateDevice’ error will be generated.

6. To fill the configuration file, run the 'calibrator.exe' file.
This console application will start the calibration wizard. The instructions of this wizard are to be followed to fill the config.ini file.
To skip assigning a button, it is enough to wait for the time specified as the parameter. (5 seconds by default)

7. If pressing a button was skipped, or a wrong button has been pressed, close the window, restart 'calibrator.exe', and follow the instructions more carefully.

8. Thus, the gamepad module configuration will be created. If this file is opened, it will contain the names of the axes and their threshold values.

9. The following is the table with transcript of each available axis of the gamepad:

Name

The upper limit

The lower limit

Note

B1

1

0

Binary axis. Corresponds to any button from the ABXY group of buttons of the x-box gamepad.

B2

1

0

Binary axis. Corresponds to any button from the ABXY group of buttons of the x-box gamepad.

B3

1

0

Binary axis. Corresponds to any button from the ABXY group of buttons of the x-box gamepad.

B4

1

0

Binary axis. Corresponds to any button from the ABXY group of buttons of the x-box gamepad.

L1

1

0

Binary axis. Corresponds to the button with the same name of the x-box gamepad

L2

1

0

Binary axis. Corresponds to the button with the same name of the x-box gamepad

R1

1

0

Binary axis. Corresponds to the button with the same name of the x-box gamepad

R2

1

0

Binary axis. Corresponds to the button with the same name of the x-box gamepad

start

1

0

Binary axis. Corresponds to the button with the same name of the x-box gamepad

T1

1

0

Binary axis. Corresponds to the button with the same name of the x-box gamepad

T2

1

0

Binary axis. Corresponds to the button with the same name of the x-box gamepad

RTUD

Assigned

Assigned

Discrete axis. Corresponding to the right stick.

RTLR

Assigned

Assigned

Discrete axis. Corresponding to the right stick.

LTUD

Assigned

Assigned

Discrete axis. Corresponds to the left stick.

LTLR

Assigned

Assigned

Discrete axis. Corresponds to the left stick.

arrowsUD

1

-1

Discrete axis. Corresponds to the D-pad of the gamepad.

arrowsLR

1

-1

Discrete axis. Corresponds to the D-pad of the gamepad.

The following is an example text of a program in the RCML language. The program invokes the test robot, which had been connected according to Section "Quick start" and looks as follows:

function main() {
	@tr = robot_test; 
	system.hand_control(@tr,"gamepad","X","RTUD");
}

The first line of code creates a variable that the test robot is assigned to.

The second line switches the test robot to manual control mode from the gamepad.

During the program execution, using the right stick in the up-down direction will pass value of the X-axis to the test robot. Each time the position of the stick changes, the window will display a message stating that the test robot has received a change of the value along the X-axis.

More information about manual control is available in Section "Hand Control Mode".

17.3.4 Quick connection of Myo to RCML

Myo is an armband that allows using various gestures to control a PC, a smartphone or a tablet.

More information is available from the official website of the device:

The myo control module is used for manual control of the robot using the Myo device, which detects gestures and position of the hand in space.

  1. First, you have to run "install and configure Myo" on your computer, as shown in Setting up the Myo armband with your Windows PC.
  2. Next, configure the following settings for Myo Connect.

2.1. Configure General settings in accordance with the Figure.

2.2. Configure Presentation Mode as shown in the Figure.

2.3. Moreover, it is necessary to disconnect Connector and Presentation Mode in accordance with Figure.

2.4. You should also configure Myo Keyboard Mapper as shown in the Figure.

  • To activate a myo module, add entry "property module" to section [control_modules] to the RCML configuration file, and set it equal to myo in accordance with Section "Installation and Configuration of RCML Compiler and Interpreter".
    The module does not require additional configuration, and will by default connect to the first armband in the system.
function main() {
	@r = robot_test;
	system.hand_control(@r,"myo","X","fist");
}

The first line of the program creates a variable that is attached to the test robot; information about how to connect the test robot is available in Section "Quick connection of robot test module to RCML".

The second line of the program specifies that the robots will be operated in manual mode. That is, the value of the fist axis of the Myo control device will be passed to the X-axis of the @r test robot. More information about what manual control function means is available in Section "Hand Control Mode".

During the program execution, make the "fist" gesture (double your fist), the gesture will be recognized by Myo and via the myo control module, and the new value of the X-axis will be passed to the test robot. Since 1 is the maximum value of the "fist" axis for Myo, and for the test robot the maximum value of the X-axis is 100, the upper limit of the fist axis value will be converted to the upper limit of the X-axis. Thus, the robot will change the value of the X-axis to the maximum possible value – 100.

The Myo armband can recognize the following gestures:

  • fist;
  • fingers spread;
  • double tap;
  • wave out;
  • wave in;
  • rest (no gesture, relaxed hand).

All these gestures are available to the programmer by default.

In addition, the following axes in the module are available for the programmer:

Name

The upper limit

The lower limit

Note

locked

1

0

Binary axis. Shows the status of the Myo bracelet: blocked - 1, unblocked - 0.

fist

1

0

Binary axis. If the fist gesture is observed, 1, otherwise - 0.

left_or_right

1

-1

Discrete axis. Convenient for specifying the direction of movement or rotation. It is based on the wave out and wave in gestures. Automatically determines rightward or leftward hand direction in these gestures (no matter which arm the armband is worn on) and takes the following values: -1 for leftward, 0 - no gesture, and 1 for rightward.

fingers_spread

1

0

Binary axis. 1 if the "fingers spread" gesture is detected, otherwise - 0.

double_tap

1

0

Binary axis. 1 if the "double tap" gesture is detected, otherwise - 0.

fist_pitch_angle

18

0

Continuous axis. Detects the pitch of the armband relative to the earth, in case of the "fist" gesture.

fist_roll_angle

18

0

Continuous axis. Detects the roll of the armband relative to the earth, in case of the "fist" gesture.

fist_yaw_angle

18

0

Continuous axis. Detects the yaw of the armband relative to the earth, in case of the "fist" gesture.

fingers_spread_pitch_angle

18

0

Continuous axis. Detects the pitch of the armband relative to the earth, in case of the "fingers spread" gesture.

fingers_spread_roll_angle

18

0

Continuous axis. Detects the roll of the armband relative to the earth, in case of the "fingers spread" gesture.

fingers_spread_yaw_angle

18

0

Continuous axis. Detects the yaw of the armband relative to the earth, in case of the "fingers spread" gesture.

Notes to the table:

  1. The values of all axes are transmitted 20 times per second.
  2. The values of the axes with suffix "angle" are changed and transmitted only after detecting the corresponding gesture.
  3. If the armband is blocked, the values of all gestures axes, except for the axis "locked" and the axes with suffix "angle", will be equal to 0.
  4. The armband is blocked automatically if for some short time (1-2 seconds) the sensors detect an unknown gesture, or the "rest" gesture is detected, as well as in case shift of the armband on the arm is detected, or if the armband is taken off the arm.
  5. The armband in unblocked by the "double tap" gesture, same as in many Myo-compatible applications.
  6. It is recommended to use caution when using simultaneously the "fist" or "fingers_spread" axes, and the axes with names containing the same "fist" or "fingers_spread" prefixes, respectively, for controlling the robot. The reason is that the axes of gestures take value 1 when there is an attempt to change the values of axes that are active after the corresponding gesture, since it requires detection of this gesture.

Beside the test robot, another RCML-compatible robot may be connected to the RCML system.