Skip to content

Commit e454791

Browse files
livanov93jrgnichodestogl
authored
Backport: Allows setting initial joint positions for Generic system (#219)
Co-authored-by: Jorge Nicho <[email protected]> Co-authored-by: Denis Štogl <[email protected]>
1 parent b6f3787 commit e454791

File tree

6 files changed

+40
-9
lines changed

6 files changed

+40
-9
lines changed

.github/workflows/ci-format.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v2
1919
- uses: actions/setup-python@v2
20+
with:
21+
python-version: 3.9.7
2022
- name: Install system hooks
2123
run: sudo apt-get install clang-format-10 cppcheck
2224
- uses: pre-commit/[email protected]

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,20 @@ The most relevant arguments are the following:
111111
- `robot_ip` (*mandatory*) - IP address by which the root can be reached.
112112
- `use_fake_hardware` (default: *false*) - use simple hardware emulator from ros2_control.
113113
Useful for testing launch files, descriptions, etc. See explanation below.
114+
- `initial_positions` (default: dictionary with all joint values set to 0) - Allows passing a dictionary to set the initial joint values for the fake hardware from [ros2_control](http://control.ros.org/). It can also be set from a yaml file with the `load_yaml` commands as follows:
115+
```
116+
<xacro:property name="initial_positions" value="${load_yaml(initial_positions_file)}"/>
117+
```
118+
In this example, the **initial_positions_file** is a xacro argument that contains the absolute path to a yaml file. An example of the initial positions yaml file is as follows:
119+
```
120+
elbow_joint: 1.158
121+
shoulder_lift_joint: -0.953
122+
shoulder_pan_joint: 1.906
123+
wrist_1_joint: -1.912
124+
wrist_2_joint: -1.765
125+
wrist_3_joint: 0.0
126+
```
127+
114128
- `fake_sensor_commands` (default: *false*) - enables setting sensor values for the hardware emulators.
115129
Useful for offline testing of controllers.
116130
- `robot_controller` (default: *joint_trajectory_controller*) - controller for robot joints to be started.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
shoulder_pan_joint: 0.0
2+
shoulder_lift_joint: -1.57
3+
elbow_joint: 0.0
4+
wrist_1_joint: -1.57
5+
wrist_2_joint: 0.0
6+
wrist_3_joint: 0.0

ur_description/urdf/ur.ros2_control.xacro

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
<xacro:macro name="ur_ros2_control" params="name prefix
55
use_fake_hardware:=false fake_sensor_commands:=false
6+
initial_positions:=${dict(shoulder_pan_joint=0.0,shoulder_lift_joint=-1.57,elbow_joint=0.0,wrist_1_joint=-1.57,wrist_2_joint=0.0,wrist_3_joint=0.0)}
67
script_filename output_recipe_filename
78
input_recipe_filename tf_prefix
89
hash_kinematics robot_ip">
@@ -51,7 +52,7 @@
5152
<state_interface name="position"/>
5253
<state_interface name="velocity"/>
5354
<state_interface name="effort"/>
54-
<param name="initial_position">0.0</param> <!-- initial position for the FakeSystem -->
55+
<param name="initial_position">${initial_positions['shoulder_pan_joint']}</param> <!-- initial position for the FakeSystem -->
5556
</joint>
5657
<joint name="${prefix}shoulder_lift_joint">
5758
<command_interface name="position">
@@ -65,7 +66,7 @@
6566
<state_interface name="position"/>
6667
<state_interface name="velocity"/>
6768
<state_interface name="effort"/>
68-
<param name="initial_position">-1.57</param> <!-- initial position for the FakeSystem -->
69+
<param name="initial_position">${initial_positions['shoulder_lift_joint']}</param> <!-- initial position for the FakeSystem -->
6970
</joint>
7071
<joint name="${prefix}elbow_joint">
7172
<command_interface name="position">
@@ -79,7 +80,7 @@
7980
<state_interface name="position"/>
8081
<state_interface name="velocity"/>
8182
<state_interface name="effort"/>
82-
<param name="initial_position">0.0</param> <!-- initial position for the FakeSystem -->
83+
<param name="initial_position">${initial_positions['elbow_joint']}</param> <!-- initial position for the FakeSystem -->
8384
</joint>
8485
<joint name="${prefix}wrist_1_joint">
8586
<command_interface name="position">
@@ -93,7 +94,7 @@
9394
<state_interface name="position"/>
9495
<state_interface name="velocity"/>
9596
<state_interface name="effort"/>
96-
<param name="initial_position">-1.57</param> <!-- initial position for the FakeSystem -->
97+
<param name="initial_position">${initial_positions['wrist_1_joint']}</param> <!-- initial position for the FakeSystem -->
9798
</joint>
9899
<joint name="${prefix}wrist_2_joint">
99100
<command_interface name="position">
@@ -107,7 +108,7 @@
107108
<state_interface name="position"/>
108109
<state_interface name="velocity"/>
109110
<state_interface name="effort"/>
110-
<param name="initial_position">0.0</param> <!-- initial position for the FakeSystem -->
111+
<param name="initial_position">${initial_positions['wrist_2_joint']}</param> <!-- initial position for the FakeSystem -->
111112
</joint>
112113
<joint name="${prefix}wrist_3_joint">
113114
<command_interface name="position">
@@ -121,7 +122,7 @@
121122
<state_interface name="position"/>
122123
<state_interface name="velocity"/>
123124
<state_interface name="effort"/>
124-
<param name="initial_position">0.0</param> <!-- initial position for the FakeSystem -->
125+
<param name="initial_position">${initial_positions['wrist_3_joint']}</param> <!-- initial position for the FakeSystem -->
125126
</joint>
126127
<sensor name="tcp_fts_sensor">
127128
<state_interface name="force.x"/>

ur_description/urdf/ur.urdf.xacro

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
<xacro:arg name="use_fake_hardware" default="false" />
2020
<xacro:arg name="fake_sensor_commands" default="false" />
2121

22+
<!-- initial position -->
23+
<xacro:arg name="initial_positions_file" default="$(find ur_description)/config/initial_positions.yaml"/>
24+
<xacro:property name="initial_positions_file" default="$(arg initial_positions_file)"/>
25+
2226
<!-- arm -->
2327
<xacro:ur_robot
2428
prefix="$(arg prefix)"
@@ -31,5 +35,6 @@
3135
safety_pos_margin="$(arg safety_pos_margin)"
3236
safety_k_position="$(arg safety_k_position)"
3337
use_fake_hardware="$(arg use_fake_hardware)"
34-
fake_sensor_commands="$(arg fake_sensor_commands)" />
38+
fake_sensor_commands="$(arg fake_sensor_commands)"
39+
initial_positions="${load_yaml(initial_positions_file)}" />
3540
</robot>

ur_description/urdf/ur_macro.xacro

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@
6464
safety_pos_margin:=0.15
6565
safety_k_position:=20
6666
use_fake_hardware:=false
67-
fake_sensor_commands:=false"
68-
>
67+
fake_sensor_commands:=false
68+
initial_positions:=${dict(shoulder_pan_joint=0.0,shoulder_lift_joint=-1.57,elbow_joint=0.0,wrist_1_joint=-1.57,wrist_2_joint=0.0,wrist_3_joint=0.0)}">
6969
<!-- Load configuration data from the provided .yaml files -->
7070
<xacro:read_model_data
7171
joint_limits_parameters_file="${joint_limits_parameters_file}"
@@ -78,12 +78,15 @@
7878
<xacro:arg name="output_recipe_filename" default="$(find ur_robot_driver)/resources/rtde_output_recipe.txt"/>
7979
<xacro:arg name="input_recipe_filename" default="$(find ur_robot_driver)/resources/rtde_input_recipe.txt"/>
8080
<xacro:arg name="robot_ip" default="10.0.1.186"/>
81+
82+
8183
<!-- ros2 control include -->
8284
<xacro:include filename="$(find ur_description)/urdf/ur.ros2_control.xacro" />
8385
<!-- ros2 control instance -->
8486
<xacro:ur_ros2_control
8587
name="URPositionHardwareInterface" prefix="${prefix}"
8688
use_fake_hardware="$(arg use_fake_hardware)"
89+
initial_positions="${initial_positions}"
8790
fake_sensor_commands="$(arg fake_sensor_commands)"
8891
script_filename="$(arg script_filename)"
8992
output_recipe_filename="$(arg output_recipe_filename)"

0 commit comments

Comments
 (0)