yarpActionsPlayer
is an executable designed to control a robot (real or simulated) by sending timestamped position commands to its joints, enabling it to replicate specified trajectories.
At the startup, the executable receives in input a set of files, each of them describing a trajectory for one or more joints. Each trajectory is called action
and is identified by a name. The trajectory files have the following format:
Here is an example of a trajectory file for two joints, with positions sampled at a period of 10ms:
This format is consistent with the output of the state port of a controlBoard_nws_yarp
. The following command can be used to record the trajectory of a moving robot and obtain a trajectory file that can reproduced with yarpActionsPlayer
.
The joints commands are assigned to the robot by using a remoteControlBoardremapper
device. In this way, the user can select to work with joints also belonging to different parts of the robot and synchronize the movements between them. The following file, configuration.ini (see the example
folder) creates two different controllers, controller1
and controller2
. The first one will control the joints called hjoint1
and hjoint2
of the robot part /robot/head
. The second one will attach to two different parts of the robot, i.e. /robot/head
/robot/arm
and control the jointshjoint1
,ajoint1
,ajoint3
which belong to these parts. Please note that the number of joints described in the controller (and their order) must match the number of joints indicated in the trajectory file. As shown in the following example, user has to associate a controller for each action file to correctly map the trajectories described in the file with the joints to actuate.
After starting yarpActionsPlayer
by providing the above mentioned configuration files, the module will wait to received user commands via rpc port, e.g. /yarpActionsPlayer/rpc
Use the help
command to list all possible commands. The command show_actions
will display the names of the actions loaded at startup. The command play <action_name>
will play an action once. The command choose <action_name>
will allow to select an action to perform more advanced commands, such as changing its playback speed, pausing it during execution or setting it to loop continuously.
yarpActionsPlayer
uses a periodic thread to schedule the execution of the commanded position at the correct time. The option --period
allows to set the period of this thread: small values allows to schedule the command with more accuracy. The suggested value is 0.005 seconds.
Another important parameter to consider is the trajectory sampling period. By default, the application does not internally resample loaded trajectories, allowing files with variable sampling rates to be used. However, users may choose to resample a trajectory to a specific rate using the --resample
option. When this option is enabled, all trajectories are resampled at the specified frequency using linear interpolation. This feature can help compensate for nonlinearities in the joint position controller’s response and reduce vibrations caused by overshoots (*) It is generally recommended to keep this sampling period small, in the 0.005 - 0.0010 seconds range to avoid overshoots of the controller when performing a direct position control of the joint. Small values will also guarantee that the difference in position between two subsequent frames is small.
(*) The response of the controller for the following two set of trajectories is generally different, event if the final position is reached in the same amount of time:
In the first case, a large movement (1 degree) might cause overshoot, while in the second case, the phenomena is mitigated by keeping limited the reference delta to a small value.
yarpActionsPlayer controls the robot using positionDirect
control mode (see https://www.yarp.it/latest/classyarp_1_1dev_1_1IPositionDirect.html). In this mode, the target is provided as a step reference and the joints are commanded to reach the final position with no limitations in the the movement speed. This control mode is thus intrinsically unsafe, especially if the difference between the current and the commanded position is large. For this reason a number of safety checks are included in the control module.
pos_tolerance
(default value: 2 degrees).pos_strict_check
is enabled (default value: false) the system will halt if the tolerance threshold is not reached, otherwise it will continue with normal operation afterwards, switching to position direct mode. The timeout is defined by the parameter pos_timeout
(default value: 2seconds)execute
.The example
folder contains the configuration.ini
and some test trajectories for a fake robot. To try the the example, you must instantiate a fakerobot using the following commands:
You can then observe the movement of the joints using yarpmotorgui
or yarpscope
executables.