Repository navigation
Description
Description
When working with a SO-101 robot arm, the urdf had joints that did not have 0 in their joint limits.
When I used MSA all the initial positions of joints in initial_positions.yaml were given 0 as the value even if 0 was outside the limits.
The generated robot_arm.ros2_control.xacro uses these values as each joint's initial_value, so the mock hardware starts with joints outside their limits.
Cause
In moveit_setup_controllers/src/control_xacro_config.cpp
ControlXacroConfig::setControlInterfaces():
moveit2/moveit_setup_assistant/moveit_setup_controllers/src/control_xacro_config.cpp
Lines 165 to 186 in 900e0e4
| void ControlXacroConfig::setControlInterfaces(const ControlInterfaces& ci) | |
| { | |
| default_ci_ = ci; | |
| for (const std::string& joint_name : joint_names_) | |
| { | |
| if (original_joint_interfaces_.count(joint_name)) | |
| { | |
| continue; | |
| } | |
| new_joint_interfaces_[joint_name] = default_ci_; | |
| // Setup the initial state | |
| std::vector<double> joint_value; | |
| // TODO: There could be an option to load a group state from the RobotPoses | |
| // For now, just assume one DOF, and it is zero | |
| joint_value.push_back(0.0); | |
| initial_group_state_.joint_values_[joint_name] = joint_value; | |
| } | |
| changed_ = true; | |
| } |
// TODO: There could be an option to load a group state from the RobotPoses
// For now, just assume one DOF, and it is zero
This applies to every joint that has no <ros2_control> tag.
I'm happy to open a PR that fills these values from the robot model's default positions (getVariableDefaultPositions()) instead of the hard-coded 0.
ROS Distro
Jazzy
OS and version
Ubuntu 24.04
Source or binary build?
Binary
If binary, which release version?
ros-jazzy-moveit-setup-assistant 2.12.4
If source, which branch?
No response
Which RMW are you using?
None
Steps to Reproduce
- test_robot.urdf
<?xml version="1.0"?>
<!-- repro: minimal arm. j1 range contains 0 (control case), j2 and j3 do not. -->
<robot name="robot_arm">
<link name="base_link">
<visual>
<geometry>
<box size="0.1 0.1 0.05"/>
</geometry>
</visual>
</link>
<link name="link1">
<visual>
<origin xyz="0 0 0.1"/>
<geometry>
<box size="0.04 0.04 0.2"/>
</geometry>
</visual>
</link>
<link name="link2">
<visual>
<origin xyz="0 0 0.1"/>
<geometry>
<box size="0.04 0.04 0.2"/>
</geometry>
</visual>
</link>
<link name="tool_link">
<visual>
<geometry>
<box size="0.02 0.02 0.02"/>
</geometry>
</visual>
</link>
<!-- control: 0 is inside the range, expected initial position 0 -->
<joint name="j1" type="revolute">
<parent link="base_link"/>
<child link="link1"/>
<origin xyz="0 0 0.025"/>
<axis xyz="0 0 1"/>
<limit lower="-1.57" upper="1.57" effort="1" velocity="1"/>
</joint>
<!-- revolute, 0 outside (same range as SO-101 wrist_roll): expected midpoint -1.64 -->
<joint name="j2" type="revolute">
<parent link="link1"/>
<child link="link2"/>
<origin xyz="0 0 0.2"/>
<axis xyz="0 1 0"/>
<limit lower="-2.96" upper="-0.32" effort="1" velocity="1"/>
</joint>
<!-- prismatic, 0 outside: expected midpoint 0.035 -->
<joint name="j3" type="prismatic">
<parent link="link2"/>
<child link="tool_link"/>
<origin xyz="0 0 0.2"/>
<axis xyz="0 0 1"/>
<limit lower="0.02" upper="0.05" effort="1" velocity="1"/>
</joint>
</robot>
- Run MSA:
ros2 launch moveit_setup_assistant setup_assistant.launch.py
- Create new moveit configuration package and load test_robot.urdf
- Generate default self-collision matrix.
- Skip virtual joints and add planning group (group name = arm, everything else default).
- Add kinematic chain group base_link -> tool_link.
- Skip robot poses, end effectors and passive joints.
- Default ros2_control URDF modifications and skip ROS2 controllers, MoveIt controllers and perception.
- Default launch files options.
- Save path and generate package.
Expected behavior
config/initial_positions.yaml:
# Default initial positions for robot_arm's ros2_control fake system
initial_positions:
j1: 0
j2: -1.64
j3: 0.035
0 if it is within the joint's bounds, otherwise the midpoint, i.e. the same default moveit_core uses in JointModel::getVariableDefaultPositions().
Actual behavior
config/initial_positions.yaml
# Default initial positions for robot_arm's ros2_control fake system
initial_positions:
j1: 0
j2: 0
j3: 0
Backtrace or Console output
No warning or error is printed about initial positions.
Activity