How can I build slider-crank structure in URDF
I tried to use URDF to simulate the motion trajectory of the crank slider in ROS, but failed. How should I handle this problem.
My URDF file:
<?xml version="1.0" encoding="utf-8"?>
<robot name="qubing_self">
<link name="base_link">
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<!-- chang kuan gao -->
<box size="3 0.05 0.05" />
</geometry>
</visual>
</link>
<link name="link1">
<visual>
<origin xyz="0 0.75 0" rpy="0 0 0" />
<geometry>
<box size="0.05 1.5 0.05"/>
</geometry>
<material name="white">
<color rgba="1 1 1 0.5" />
</material>
</visual>
</link>
<joint name="joint_1" type="prismatic">
<origin xyz="-0.75 0 0" rpy="0 0 0" />
<parent link="base_link"/>
<child link="link1" />
<limit effort="1000.0" lower="-0.75" upper="0.75" velocity="0.5"/>
</joint>
<link name="link2">
<visual>
<origin xyz="0.75 0 0" rpy="0 0 0" />
<geometry>
<box size="1.5 0.05 0.05"/>
</geometry>
<material name="white">
<color rgba="1 1 1 0.5" />
</material>
</visual>
</link>
<joint name="joint_2" type="continuous">
<origin xyz="0 1.5 0" rpy="0 0 0" />
<parent link="link1"/>
<child link="link2" />
<axis xyz="0 0 1"/>
</joint>
<link name="link3">
<visual>
<origin xyz="0 -0.75 0" rpy="0 0 -1.570796" />
<geometry>
<box size="1.5 0.05 0.05"/>
</geometry>
<material name="white">
<color rgba="1 1 1 0.5" />
</material>
</visual>
</link>
<joint name="joint_3" type="continuous">
<origin xyz="1.5 0 0" rpy="0 0 0" />
<parent link="link2"/>
<child link="link3" />
<axis xyz="0 0 1"/>
</joint>
<link name="link4">
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<box size="0.05 0.05 0.05"/>
</geometry>
<material name="white">
<color rgba="0 0 0 0.5" />
</material>
</visual>
</link>
<joint name="joint_4" type="continuous">
<origin xyz="0 -1.5 0" rpy="0 0 0" />
<parent link="link3"/>
<child link="link4" />
<axis xyz="0 0 1"/>
</joint>
<link name="link5">
<visual>
<origin xyz="0 0 0" rpy="0 0 0" />
<geometry>
<box size="0.05 0.05 0.05"/>
</geometry>
<material name="white">
<color rgba="0 0 0 1" />
</material>
</visual>
</link>
<joint name="joint_5" type="fixed">
<parent link="link4"/>
<child link="link5" />
</joint>
<!-- <joint name="joint_6" type="fixed">
<parent link="link5"/>
<child link="base_link" />
</joint> -->
</robot>
This is a closed chain manipulator, I think you can try to get around with duplicate joints etc, but this task is difficult for robot simulators. AFAIK there is no support for it in Gazebo - of course I will be happy if I am wrong.
There is no support for closed kinematic loops in URDF but there is in Gazebo/SDF, and presumably other simulation specific description formats. There are a few examples floating out there, such as the linkage based grippers used on certain robots.
The "trick", at least for Gazebo, is to break the loop in your URDF, then use a
<gazebo>
tag to wrap the final joint which would close the loop.