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 ...
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.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.
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.