How to edit parameters from the YAML file?
So I have a basic launch file set up:
<launch>
<rosparam command="load" file="$(find me439robotarm)/src/robot_arm_info.yaml" />
<arg name="model" default="$(find me439robotarm)/src/urdf/robot-arm.urdf" />
<arg name="gui" default="true" />
<param name="path_svg_file" value="$(find me439robotarm)/src/RobotArmPath.svg" />
<param name="robot_description" command="$(find xacro)/xacro.py $(arg model)" />
<param name="use_gui" value="$(arg gui)"/>
<node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
<group ns="robot_control">
<node pkg="me439robotarm" name="inverse_kinematics" type="inverse_kinematics.py"/>
<node pkg="me439robotarm" name="smooth_waypoint_seeker" type="smooth_waypoint_seeker.py"/>
<node pkg="me439robotarm" name="set_waypoints" type="set_waypoints_from_svg.py"/>
<node pkg="me439robotarm" name="command_arm" type="command_arm.py"/>
</group>
</launch>
The second line is supposed to load parameters from a YAML file. For some reason, when I change the values of the parameters from the YAML file, none of the paramters appear changed when I run the launch file. For eample, the original YAML file was:
# Parameters for ME439 Robot assuming RRRRRR structure with zyyxyx rotations (x forward, y left, z up)
# Frequency to compute new commands
command_frequency: 50
# Speed for controlled movement
endpoint_speed: 0.05
# Height offset (for safety: do dry runs in the air)
vertical_offset: 0.02
# Sign of positive rotations w.r.t. the +y axis
y_rotation_sign: 1 # Could otherwise be -1 if using 'positive rotations about the -y axis'
# Frame offsets to successive links
**frame_offset_01: [0., 0., 0.1026]**
frame_offset_12: [0.031, 0., 0.]
frame_offset_23: [0.1180, 0., 0.]
frame_offset_34: [0.1335, 0., 0.0200]
frame_offset_45: [0., 0., 0.]
frame_offset_56: [0., 0., 0.] # Define the Frame 6 ('fingers') origin to coincide with the 3-4 and 4-5 axes ("spherical wrist").
# Location of the end effector centerpoint relative to the wrist center
endpoint_offset_in_frame_6: [0.0370, 0., -0.035] # forward from 'wrist' to 'fingers' and down to marker tip
# Rotational Axis limits (degrees)
rotational_limits_joint_01: [-90,90]
rotational_limits_joint_12: [-160,-24]
rotational_limits_joint_23: [0,136]
rotational_limits_joint_34: [-84,110]
rotational_limits_joint_45: [-85,85]
rotational_limits_joint_56: [-87,96]
# Rotational Axis degrees-to-microseconds mapping
rotational_angles_for_mapping_joint_01: [-114.,0.,60]
servo_cmd_us_for_mapping_joint_01: [600, 1616, 2281]
rotational_angles_for_mapping_joint_12: [-169.,-90.,-34.]
servo_cmd_us_for_mapping_joint_12: [2483, 1657, 1020]
rotational_angles_for_mapping_joint_23: [-11.,0.,129.]
servo_cmd_us_for_mapping_joint_23: [649, 744, 1656]
rotational_angles_for_mapping_joint_34: [-112.,0.,82.]
servo_cmd_us_for_mapping_joint_34: [601, 1620, 2500]
rotational_angles_for_mapping_joint_45: [-85.,0.,90.]
servo_cmd_us_for_mapping_joint_45: [2500, 1620, 715]
rotational_angles_for_mapping_joint_56: [-116.,0.,72.]
servo_cmd_us_for_mapping_joint_56: [540, 1622, 2380]
I changed the value of the frame_offset_01
parameter to [0.04035, 0., 0.1026]
in the YAML file. When I run the launch file, it lists the parameter as frame_offset_01: [0., 0., 0.1026]
. I tried using rosparam set /frame_offset_01 "[0.04035, 0., 0.1026]"
. This seemingly worked because then when I did rosparam get /frame_offset_01
it spit out the same value. But when running the launch file, the parameter was back to the original value.
Any suggestions on how to do this?
edit: I tried putting the rosparam command = "load"
line into the group ns
tag. When I do this is the terminal output:
pi@Expt2019_A:~ $ roslaunch /home/pi/catkin_ws/me439robotarm/src/alex_launch_test.launch
... logging to /home/pi/.ros/log/3da619c8-b91d-11e9-9e6f-b827eb90a835/roslaunch-Expt2019_A-1459.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
xacro: Traditional processing is deprecated. Switch to --inorder processing!
To check for compatibility of your document, use option --check-order.
For more infos, see http://wiki.ros.org/xacro#Processing_Order
xacro.py is deprecated; please use xacro instead
started roslaunch server http://Expt2019_A:41141/
SUMMARY
========
PARAMETERS
* /path_svg_file: /home/pi/catkin_w...
* /robot_control/command_frequency: 50
* /robot_control/endpoint_offset_in_frame_6: [0.037, 0.0, -0.035]
* /robot_control/endpoint_speed: 0.05
* /robot_control/frame_offset_01: [0.0, 0.0, 0.1026]
* /robot_control/frame_offset_12: [0.031, 0.0, 0.0]
* /robot_control/frame_offset_23: [0.118, 0.0, 0.0]
* /robot_control/frame_offset_34: [0.1335, 0.0, 0.02]
* /robot_control/frame_offset_45: [0.0, 0.0, 0.0]
* /robot_control/frame_offset_56: [0.0, 0.0, 0.0]
* /robot_control/rotational_angles_for_mapping_joint_01: [-114.0, 0.0, 60]
* /robot_control/rotational_angles_for_mapping_joint_12: [-169.0, -90.0, -...
* /robot_control/rotational_angles_for_mapping_joint_23: [-11.0, 0.0, 129.0]
* /robot_control/rotational_angles_for_mapping_joint_34: [-112.0, 0.0, 82.0]
* /robot_control/rotational_angles_for_mapping_joint_45: [-85.0, 0.0, 90.0]
* /robot_control/rotational_angles_for_mapping_joint_56: [-116.0, 0.0, 72.0]
* /robot_control/rotational_limits_joint_01: [-90, 90]
* /robot_control/rotational_limits_joint_12: [-160, -24]
* /robot_control/rotational_limits_joint_23: [0, 136]
* /robot_control/rotational_limits_joint_34: [-84, 110]
* /robot_control/rotational_limits_joint_45: [-85, 85]
* /robot_control/rotational_limits_joint_56: [-87, 96]
* /robot_control/servo_cmd_us_for_mapping_joint_01: [600, 1616, 2281]
* /robot_control/servo_cmd_us_for_mapping_joint_12: [2483, 1657, 1020]
* /robot_control/servo_cmd_us_for_mapping_joint_23: [649, 744, 1656]
* /robot_control/servo_cmd_us_for_mapping_joint_34: [601, 1620, 2500]
* /robot_control/servo_cmd_us_for_mapping_joint_45: [2500, 1620, 715]
* /robot_control/servo_cmd_us_for_mapping_joint_56: [540, 1622, 2380]
* /robot_control/vertical_offset: 0.02
* /robot_control/y_rotation_sign: 1
* /robot_description: <?xml version="1....
* /rosdistro: kinetic
* /rosversion: 1.12.14
* /use_gui: True
NODES
/robot_control/
command_arm (me439robotarm/command_arm.py)
inverse_kinematics (me439robotarm/inverse_kinematics.py)
set_waypoints (me439robotarm/set_waypoints_from_svg.py)
smooth_waypoint_seeker (me439robotarm/smooth_waypoint_seeker.py)
/
robot_state_publisher (robot_state_publisher/state_publisher)
ROS_MASTER_URI=http://localhost:11311
process[robot_state_publisher-1]: started with pid [1479]
process[robot_control/inverse_kinematics-2]: started with pid [1480]
process[robot_control/smooth_waypoint_seeker-3]: started with pid [1481]
process[robot_control/set_waypoints-4]: started with pid [1482]
process[robot_control/command_arm-5]: started with pid [1491]
Traceback (most recent call last):
File "/home/pi/catkin_ws/src/me439robotarm/src/inverse_kinematics.py", line 17, in <module>
y_rotation_sign = np.sign(rospy.get_param('/y_rotation_sign'))
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/client.py", line 465, in get_param
return _param_server[param_name] #MasterProxy does all the magic for us
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/msproxy.py", line 123, in __getitem__
raise KeyError(key)
KeyError: '/y_rotation_sign'
Traceback (most recent call last):
File "/home/pi/catkin_ws/src/me439robotarm/src/set_waypoints_from_svg.py", line 21, in <module>
vertical_offset = rospy.get_param('/vertical_offset')
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/client.py", line 465, in get_param
return _param_server[param_name] #MasterProxy does all the magic for us
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/msproxy.py", line 123, in __getitem__
raise KeyError(key)
KeyError: '/vertical_offset'
Traceback (most recent call last):
File "/home/pi/catkin_ws/src/me439robotarm/src/smooth_waypoint_seeker.py", line 33, in <module>
endpoint_speed = rospy.get_param('/endpoint_speed') # how fast should we move?
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/client.py", line 465, in get_param
return _param_server[param_name] #MasterProxy does all the magic for us
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/msproxy.py", line 123, in __getitem__
raise KeyError(key)
KeyError: '/endpoint_speed'
[robot_control/inverse_kinematics-2] process has died [pid 1480, exit code 1, cmd /home/pi/catkin_ws/src/me439robotarm/src/inverse_kinematics.py __name:=inverse_kinematics __log:=/home/pi/.ros/log/3da619c8-b91d-11e9-9e6f-b827eb90a835/robot_control-inverse_kinematics-2.log].
log file: /home/pi/.ros/log/3da619c8-b91d-11e9-9e6f-b827eb90a835/robot_control-inverse_kinematics-2*.log
Traceback (most recent call last):
File "/home/pi/catkin_ws/src/me439robotarm/src/command_arm.py", line 25, in <module>
print(rospy.get_param('/rotational_angles_for_mapping_joint_01'))
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/client.py", line 465, in get_param
return _param_server[param_name] #MasterProxy does all the magic for us
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/msproxy.py", line 123, in __getitem__
raise KeyError(key)
KeyError: '/rotational_angles_for_mapping_joint_01'
[robot_control/set_waypoints-4] process has died [pid 1482, exit code 1, cmd /home/pi/catkin_ws/src/me439robotarm/src/set_waypoints_from_svg.py __name:=set_waypoints __log:=/home/pi/.ros/log/3da619c8-b91d-11e9-9e6f-b827eb90a835/robot_control-set_waypoints-4.log].
log file: /home/pi/.ros/log/3da619c8-b91d-11e9-9e6f-b827eb90a835/robot_control-set_waypoints-4*.log
[robot_control/smooth_waypoint_seeker-3] process has died [pid 1481, exit code 1, cmd /home/pi/catkin_ws/src/me439robotarm/src/smooth_waypoint_seeker.py __name:=smooth_waypoint_seeker __log:=/home/pi/.ros/log/3da619c8-b91d-11e9-9e6f-b827eb90a835/robot_control-smooth_waypoint_seeker-3.log].
log file: /home/pi/.ros/log/3da619c8-b91d-11e9-9e6f-b827eb90a835/robot_control-smooth_waypoint_seeker-3*.log
[robot_control/command_arm-5] process has died [pid 1491, exit code 1, cmd /home/pi/catkin_ws/src/me439robotarm/src/command_arm.py __name:=command_arm __log:=/home/pi/.ros/log/3da619c8-b91d-11e9-9e6f-b827eb90a835/robot_control-command_arm-5.log].
log file: /home/pi/.ros/log/3da619c8-b91d-11e9-9e6f-b827eb90a835/robot_control-command_arm-5*.log
Asked by Amjanis on 2019-08-06 15:35:26 UTC
Answers
Did you rebuild your workspace between yaml line edits?
Asked by stevemacenski on 2019-08-06 15:59:25 UTC
Comments
You shouldn't need to do that. The yaml edits do not get compiled.
Asked by Thomas D on 2019-08-06 21:04:35 UTC
But they get moved to the install space, where the yaml file is going to be read from.
Asked by stevemacenski on 2019-08-07 13:11:43 UTC
I was making the assumption that the workspace was built with catkin build
, and that the devel
space was sourced.
Asked by Thomas D on 2019-08-07 21:52:48 UTC
I wouldn't necessarily assume that :-) the issues they're describing seem exactly like their yaml file they're isnt being read so its not being copied over.
Asked by stevemacenski on 2019-08-08 13:33:54 UTC
Comments
Can you try moving the
rosparam load
line inside yourgroup ns
tag? It looks like there could be a mismatch between the namespace of your parameters and the namespace of your nodes.Asked by Thomas D on 2019-08-06 21:07:43 UTC
When I do that the system throws a bunch of strange errors that weren't there before. I will put the output in the original question post.
Asked by Amjanis on 2019-08-07 09:15:03 UTC
I copied your launch file and yaml file into a workspace on my machine. In the launch file I commented out all of the custom args and params that are not provided, and the rospy nodes you are starting since those are not available. I then launched the launch file and did
rosparam get /frame_offset_01
. The initial values were as expected. After stopping the launch file, editing the yaml file, and relaunching, I got the new values fromrosparam get
. I'm unable to re-create the issue you are reporting. Sorry I couldn't help more.Asked by Thomas D on 2019-08-07 21:56:04 UTC