Article directory
For some special motion models (such as closed-loop mechanical components and passive joints), how to use the urdf model to describe the model and simulate it in MoveIt2? An idea is provided below for reference only.
four-bar linkage
Structure introduction
The composition of the organization is shown in the figure below.
The pink and blue bases are fixed mechanisms, and the three yellow, gray, and cyan bars are hingedly connected to each other and the base and can rotate. The joint between the yellow and gray poles is the active axis, which can actively initiate rotation (it can be understood that a motor is installed here).
urdf file
fourbar.urdf
<?xml version="1.0"?>
<robot name="fourbar">
<!-- base link -->
<link name="base_link">
<visual>
<origin xyz="0 0 -0.06" rpy="0 0 0"/>
<geometry>
<cylinder length="0.12" radius="0.20"/>
</geometry>s
<material name="wtf0">
<color rgba="0.9 0.2 0.3 1.0" />
</material>
</visual>
<collision>
<origin xyz="0 0 -0.06" rpy="0 0 0"/>
<geometry>
<cylinder length="0.12" radius="0.20"/>
</geometry>
</collision>
</link>
<link name="bar1">
<visual>
<origin xyz="0 0 0.75" rpy="0 0 0"/>
<geometry>
<box size="0.15 0.1 1.5"/>
</geometry>
<material name="wtf1">
<color rgba="0.5 0.5 0.3 1.0" />
</material>
</visual>
<collision>
<origin xyz="0 0 0.75" rpy="0 0 0"/>
<geometry>
<box size="0.15 0.1 1.5"/>
</geometry>
</collision>
</link>
<joint name="joint1" type="continuous">
<parent link="base_link" />
<child link="bar1" />
<origin xyz="0 0 0" rpy="0 0 0"/>
<axis xyz="0 1 0"/>
</joint>
<link name="bar2">
<visual>
<origin xyz="0 0 0.5" rpy="0 0 0"/>
<geometry>
<box size="0.15 0.1 1.0"/>
</geometry>
<material name="wtf2">
<color rgba="0.5 0.5 0.6 1.0" />
</material>
</visual>
<collision>
<geometry>
<box size="0.15 0.1 1.0"/>
</geometry>
<origin xyz="0 0 0.5" rpy="0 0 0"/>
</collision>
</link>
<joint name="joint2" type="continuous">
<parent link="bar1" />
<child link="bar2" />
<origin xyz="0 -0.1 1.5" rpy="0 2.5 0" />
<axis xyz="0 1 0"/>
</joint>
<link name="bar3">
<visual>
<origin xyz="0 0 0.75" rpy="0 0 0"/>
<geometry>
<box size="0.15 0.1 1.5"/>
</geometry>
<material name="wtf3">
<color rgba="0.1 0.5 0.7 1.0" />
</material>
</visual>
<collision>
<geometry>
<box size="0.15 0.1 1.5"/>
</geometry>
<origin xyz="0 0 0.75" rpy="0 0 0"/>
</collision>
</link>
<joint name="joint3" type="continuous">
<parent link="bar2" />
<child link="bar3" />
<origin xyz="0 -0.1 1.0" rpy="0 -0.45 0" />
<axis xyz="0 1 0"/>
</joint>
<link name="base_link2">
<visual>
<origin xyz="0 0 -0.06" rpy="0 0 0"/>
<geometry>
<cylinder length="0.12" radius="0.20"/>
</geometry>
<material name="wtf4">
<color rgba="0. 0.1 0.5 1.0" />
</material>
</visual>
<collision>
<geometry>
<cylinder length="0.12" radius="0.20"/>
</geometry>
<origin xyz="0 0 -0.06" rpy="0 0 0"/>
</collision>
</link>
<joint name="joint4" type="continuous">
<parent link="bar3" />
<child link="base_link2" />
<origin xyz="0 0 1.5" rpy="0 -2.05 0" />
<axis xyz="0 1 0"/>
</joint>
</robot>
MoveIt settings
Regarding how to build the MoveIt2 project based on the urdf file, you can read what I wrote before: [In ROS2, control the custom manipulator in Gazebo through MoveIt2]
The steps are similar to the previous ones. Pay attention to these issues.
Select base_link and base_link2 for the start link and end link respectively:
set the active joint and the slave joint.
When moving the active joint to the right to become the slave joint, the active joint is still retained. It may be a bug, so ignore it for now. In short, the total joint minus the driven joint on the right side is the active joint.
You can see that it's the same thing, although the end will still shake.
four-bar linkage
The main difficulty is that urdf cannot describe a closed-loop structure tree. Theoretically base_link2 should be fixed to base_link, but this is not allowed.
Therefore, it can only be realized by controlling the position of the terminal mechanism in moveIt.
Slider crank mechanism
Structure introduction
How to implement the following slider-crank mechanism in moveit? [Image source]
urdf file
barSlider2. urdf
<?xml version="1.0"?>
<robot name="barSlider2">
<!-- base link -->
<link name="base_link">
<visual>
<origin xyz="0 0 0" rpy="1.57 0 0"/>
<geometry>
<cylinder length="0.12" radius="0.12"/>
</geometry>s
<material name="wtf0">
<color rgba="0.9 0.2 0.3 1.0" />
</material>
</visual>
<collision>
<geometry>
<cylinder length="0.12" radius="0.12"/>
</geometry>
<origin xyz="0 0 0" rpy="1.57 0 0"/>
</collision>
</link>
<link name="bar1">
<visual>
<origin xyz="0 0 0.35" rpy="0 0 0"/>
<geometry>
<box size="0.24 0.1 0.7"/>
</geometry>
<material name="wtf1">
<color rgba="0.5 0.5 0.3 1.0" />
</material>
</visual>
<collision>
<geometry>
<box size="0.24 0.1 0.7"/>
</geometry>
<origin xyz="0 0 0.35" rpy="0 0 0"/>
</collision>
</link>
<joint name="joint1" type="continuous">
<parent link="base_link" />
<child link="bar1" />
<origin xyz="0 0 0.0"/>
<axis xyz="0 1 0"/>
</joint>
<link name="bar2">
<visual>
<origin xyz="0 0 1.1" rpy="0 0 0"/>
<geometry>
<box size="0.15 0.1 2.2"/>
</geometry>
<material name="wtf2">
<color rgba="0.5 0.5 0.6 1.0" />
</material>
</visual>
<collision>
<geometry>
<box size="0.15 0.1 2.2"/>
</geometry>
<origin xyz="0 0 1.1" rpy="0 0 0"/>
</collision>
</link>
<joint name="joint2" type="continuous">
<parent link="bar1" />
<child link="bar2" />
<origin xyz="0 -0.1 0.7" rpy="0 1.9 0" />
<axis xyz="0 1 0"/>
</joint>
<link name="base_link2">
<visual>
<origin xyz="0 0 0" rpy="0 0 0"/>
<geometry>
<box size="0.6 0.1 0.3"/>
</geometry>
<material name="wtf4">
<color rgba="0. 0.1 0.5 1.0" />
</material>
</visual>
<collision>
<geometry>
<box size="0.6 0.1 0.3"/>
</geometry>
<origin xyz="0 0 0" rpy="0 0 0"/>
</collision>
</link>
<joint name="joint3" type="continuous">
<parent link="bar2" />
<child link="base_link2" />
<origin xyz="0 -0.1 2.2" rpy="0 -1.9 0" />
<axis xyz="0 1 0"/>
</joint>
<link name="base_link3">
<visual>
<origin xyz="0 0 0" rpy="0 0 0"/>
<geometry>
<box size="1.0 0.5 0.1"/>
</geometry>
<material name="wtf5">
<color rgba="0. 0.5 0.5 1.0" />
</material>
</visual>
<collision>
<geometry>
<box size="0.6 0.1 0.3"/>
</geometry>
<origin xyz="0 0 0" rpy="0 0 0"/>
</collision>
</link>
<joint name="joint4" type="prismatic">
<parent link="base_link2" />
<child link="base_link3" />
<origin xyz="0 0 -0.2" rpy="0 0 0" />
<axis xyz="1 0 0"/>
<limit effort="1000.0" lower="-10" upper="10" velocity="0.5"/>
</joint>
</robot>
MoveIt settings
Similar to the previous four-bar linkage,
the effect is as follows:
slider crank