Ask Your Question

How to edit parameters from the YAML file?

asked 2019-08-06 15:35:26 -0600

Amjanis gravatar image

updated 2019-08-07 14:37:53 -0600

So I have a basic launch file set up:

  <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)/ $(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=""/>
    <node pkg="me439robotarm" name="smooth_waypoint_seeker" type=""/>
    <node pkg="me439robotarm" name="set_waypoints" type=""/>
    <node pkg="me439robotarm" name="command_arm" type=""/>

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 ...
edit retag flag offensive close merge delete


Can you try moving the rosparam load line inside your group ns tag? It looks like there could be a mismatch between the namespace of your parameters and the namespace of your nodes.

Thomas D gravatar image Thomas D  ( 2019-08-06 21:07:43 -0600 )edit

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.

Amjanis gravatar image Amjanis  ( 2019-08-07 09:15:03 -0600 )edit

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 from rosparam get. I'm unable to re-create the issue you are reporting. Sorry I couldn't help more.

Thomas D gravatar image Thomas D  ( 2019-08-07 21:56:04 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2019-08-06 15:59:25 -0600

Did you rebuild your workspace between yaml line edits?

edit flag offensive delete link more


You shouldn't need to do that. The yaml edits do not get compiled.

Thomas D gravatar image Thomas D  ( 2019-08-06 21:04:35 -0600 )edit

But they get moved to the install space, where the yaml file is going to be read from.

stevemacenski gravatar image stevemacenski  ( 2019-08-07 13:11:43 -0600 )edit

I was making the assumption that the workspace was built with catkin build, and that the devel space was sourced.

Thomas D gravatar image Thomas D  ( 2019-08-07 21:52:48 -0600 )edit

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.

stevemacenski gravatar image stevemacenski  ( 2019-08-08 13:33:54 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2019-08-06 15:35:26 -0600

Seen: 566 times

Last updated: Aug 07 '19