Skip to content

Commit 1131e9c

Browse files
Split example/README.md into C++ and Python version; updated content (PickNikRobotics#138)
Signed-off-by: Christian Eichmann <eichmann@fzi.de>
1 parent 325b438 commit 1131e9c

File tree

2 files changed

+161
-11
lines changed

2 files changed

+161
-11
lines changed

example/README.md

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,7 @@
1515

1616
```
1717
source install/setup.bash
18-
ros2 run generate_parameter_library_example test_node --ros-args --params-file src/generate_parameter_library/examples/cpp/config/implementation.yaml
19-
20-
```
21-
## Or run the Python node
22-
23-
```
24-
source install/setup.bash
25-
ros2 run generate_parameter_module_example test_node --ros-args --params-file src/generate_parameter_library/examples/python/config/implementation.yaml
18+
ros2 run generate_parameter_library_example test_node --ros-args --params-file src/generate_parameter_library/example/config/implementation.yaml
2619
```
2720

2821
You should see an output like this:
@@ -106,7 +99,7 @@ All parameter are automatically declared and callbacks are setup by default. You
10699

107100
You should see:
108101

109-
`[INFO] [1656019001.515820371] [admittance_controller]: Control frame is: 'new_frame'`
102+
`[INFO] [1656019001.515820371] [admittance_controller]: New control frame parameter is: 'new_frame'`
110103

111104
Congratulations, you updated the parameter!
112105

@@ -139,15 +132,15 @@ If you try to set a value out of the specified bounds,
139132

140133
you will get the error
141134

142-
`Setting parameter failed: Invalid value '-10' for parameter 'admittance.damping_ratio'. Required bounds: [0.1, 10]`
135+
`Setting parameter failed: Value -10.0 in parameter 'admittance.damping_ratio' must be within bounds [0.1, 10.0]`
143136

144137
If you try to set a vector parameter with the wrong length,
145138

146139
`ros2 param set /admittance_controller admittance.damping_ratio [1.0,1.0,1.0]`
147140

148141
you will get the error
149142

150-
`Setting parameter failed: Invalid length '3' for parameter 'admittance.damping_ratio'. Required equal to: 6`
143+
`Setting parameter failed: Length of parameter 'admittance.damping_ratio' is 3 but must be equal to 6`
151144

152145
If you try to load a yaml file with missing required parameters
153146

example_python/README.md

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# Example:
2+
3+
## Build the node
4+
5+
```
6+
mkdir colcon_ws
7+
mkdir colcon_ws/src
8+
cd colcon_ws/src
9+
git clone https://github.com/picknikrobotics/generate_parameter_library.git
10+
cd ..
11+
colcon build
12+
```
13+
14+
## Run the Python node
15+
16+
```
17+
source install/setup.bash
18+
ros2 run generate_parameter_module_example test_node --ros-args --params-file src/generate_parameter_library/example_python/config/implementation.yaml
19+
```
20+
21+
You should see an output like this:
22+
`[INFO] [1656018676.015816509] [admittance_controller]: Initial control frame parameter is: 'ee_link'`
23+
24+
25+
## ROS 2 CLI
26+
27+
Run the following:
28+
29+
`ros2 param list`
30+
31+
You should see:
32+
33+
```
34+
/admittance_controller:
35+
admittance.damping_ratio
36+
admittance.mass
37+
admittance.selected_axes
38+
admittance.stiffness
39+
chainable_command_interfaces
40+
command_interfaces
41+
control.frame.external
42+
control.frame.id
43+
enable_parameter_update_without_reactivation
44+
fixed_array
45+
fixed_string
46+
fixed_string_no_default
47+
fixed_world_frame.frame.external
48+
fixed_world_frame.frame.id
49+
ft_sensor.filter_coefficient
50+
ft_sensor.frame.external
51+
ft_sensor.frame.id
52+
ft_sensor.name
53+
gravity_compensation.CoG.force
54+
gravity_compensation.CoG.pos
55+
gravity_compensation.frame.external
56+
gravity_compensation.frame.id
57+
interpolation_mode
58+
joints
59+
kinematics.alpha
60+
kinematics.base
61+
kinematics.group_name
62+
kinematics.plugin_name
63+
kinematics.plugin_package
64+
kinematics.tip
65+
one_number
66+
pid.elbow_joint.d
67+
pid.elbow_joint.i
68+
pid.elbow_joint.p
69+
pid.rate
70+
pid.shoulder_lift_joint.d
71+
pid.shoulder_lift_joint.i
72+
pid.shoulder_lift_joint.p
73+
pid.shoulder_pan_joint.d
74+
pid.shoulder_pan_joint.i
75+
pid.shoulder_pan_joint.p
76+
pid.wrist_1_joint.d
77+
pid.wrist_1_joint.i
78+
pid.wrist_1_joint.p
79+
pid.wrist_2_joint.d
80+
pid.wrist_2_joint.i
81+
pid.wrist_2_joint.p
82+
pid.wrist_3_joint.d
83+
pid.wrist_3_joint.i
84+
pid.wrist_3_joint.p
85+
qos_overrides./parameter_events.publisher.depth
86+
qos_overrides./parameter_events.publisher.durability
87+
qos_overrides./parameter_events.publisher.history
88+
qos_overrides./parameter_events.publisher.reliability
89+
scientific_notation_num
90+
state_interfaces
91+
three_numbers
92+
three_numbers_of_five
93+
use_feedforward_commanded_input
94+
use_sim_time
95+
```
96+
97+
All parameter are automatically declared and callbacks are setup by default. You can set a parameter by typing:
98+
99+
`ros2 param set /admittance_controller control.frame.id new_frame`
100+
101+
You should see:
102+
103+
`[INFO] [1656019001.515820371] [admittance_controller]: New control frame parameter is: 'new_frame'`
104+
105+
Congratulations, you updated the parameter!
106+
107+
If you try to set a parameter that is read only, you will get an error. Running the following
108+
109+
`ros2 param set /admittance_controller command_interfaces ["velocity"]`
110+
111+
will result in the error
112+
113+
`Setting parameter failed: Trying to set a read-only parameter: command_interfaces.`
114+
115+
Running the following
116+
117+
`ros2 param describe /admittance_controller admittance.damping_ratio`
118+
119+
will show a parameter's description
120+
121+
```
122+
Parameter name: admittance.damping_ratio
123+
Type: double array
124+
Description: specifies damping ratio values for x, y, z, rx, ry, and rz used in the admittance calculation. The values are calculated as damping can be used instead: zeta = D / (2 * sqrt( M * S ))
125+
Constraints:
126+
Min value: 0.1
127+
Max value: 10.0
128+
```
129+
130+
If you try to set a value out of the specified bounds,
131+
132+
`ros2 param set /admittance_controller admittance.damping_ratio [-10.0,-10.0,-10.0,-10.0,-10.0,-10.0]`
133+
134+
you will get the error
135+
136+
`Setting parameter failed: Value array('d', [-10.0, -10.0, -10.0, -10.0, -10.0, -10.0]) in parameter 'admittance.damping_ratio' must be within bounds [0.1, 10.0]`
137+
138+
If you try to set a vector parameter with the wrong length,
139+
140+
`ros2 param set /admittance_controller admittance.damping_ratio [1.0,1.0,1.0]`
141+
142+
you will get the error
143+
144+
`Setting parameter failed: Length of parameter 'admittance.damping_ratio' is '3' but must be equal to 6`
145+
146+
If you try to load a yaml file with missing required parameters
147+
148+
`ros2 run generate_parameter_module_example test_node --ros-args --params-file src/generate_parameter_library/example_python/config/missing_required.yaml`
149+
150+
you will get the error
151+
152+
```
153+
Traceback (most recent call last):
154+
[...]
155+
rclpy.exceptions.ParameterUninitializedException: The parameter 'fixed_string_no_default' is not initialized
156+
[ros2run]: Process exited with failure 1
157+
```

0 commit comments

Comments
 (0)