Robot Operating System: How to Create a Robot Simulation Model

Create a Catkin Workspace and Package

$> mkdir -p ~/ROS/src
$> cd ~/ROS
$> catkin_make
Base path: /home/devcon/ROS
Source space: /home/devcon/ROS/src
...
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
...
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.8.5", minimum required is "3")
-- Using PYTHON_EXECUTABLE: /usr/bin/python3
-- Using Debian Python package layout
-- Found PY_em: /usr/lib/python3/dist-packages/em.py
-- Using empy: /usr/lib/python3/dist-packages/empy
$> cd ~/ROS/src
$> catkin_create_pkg car-robot
Created file car-robot/package.xml
Created file car-robot/CMakeLists.txt
Successfully created files in /home/devcon/ROS/car-robot. Please adjust the values in package.xml.

Create the URDF File

Define the Torso

<?xml version="1.0"?>
<robot name="bot">
<link>
<visual>
<geometry>
<box />
</geometry>
</visual>
</link>
</robot>
<?xml version="1.0"?>
<robot name="bot">
<link name="torso">
<visual>
<geometry>
<box size="0.6 0.3 0.1"/>
</geometry>
<material name="green">
<color rgba="1.0 1.0 0.0 1"/>
</material>
</visual>
</link>
</robot>
$> check_urdf urdf/bot.urdfrobot name is: car-bot
---------- Successfully Parsed XML ---------------
root Link: torso has 0 child(ren)
<link name="base_link">
<visual>
<geometry>
<box size="0 0 0"/>
</geometry>
<material name="red">
<color rgba="1 0 0 1"/>
</material>
</visual>
</link>
<joint name="base_link_torso" type="continuous">
<parent link="base_link" />
<child link="torso" />
<origin xyz="0 0 0" rpy="0 0 0"/>
</joint>

Add the Wheels

<link name="left_wheel">
<visual>
<geometry>
<cylinder radius="0.04" length="0.05" />
</geometry>
<material name="red">
<color rgba="1 0 0 1"/>
</material>
</visual>
</link>
<link name="right_wheel">
<visual>
<geometry>
<cylinder radius="0.04" length="0.05" />
</geometry>
<material name="red">
<color rgba="1 0 0 1"/>
</material>
</visual>
</link>
<joint name="base_link_right_wheel" type="continuous">
<parent link="base_link" />
<child link="right_wheel" />
<origin xyz="0.2 -0.2 -0.05" rpy="1.570796 0 0"/>
</joint>
<joint name="base_link_left_wheel" type="continuous">
<axis xyz="0.0 0.0 1" />
<parent link="base_link" />
<child link="left_wheel" />
<origin xyz="1.5 0 0" rpy="-1.5 0 0" />
</joint>
<joint name="base_link_right_wheel" type="continuous">
<axis xyz="0.0 0.0 1" />
<parent link="base_link" />
<child link="right_wheel" />
<origin xyz="-1.5 0 0" rpy="-1.5 0 0" />
</joint>
<link name="left_wheel_backside">
<visual>
<geometry>
<cylinder radius="0.04" length="0.05" />
</geometry>
<material name="red">
<color rgba="1 0 0 1"/>
</material>
</visual>
</link>
<joint name="base_link_left_wheel_backside" type="continuous">
<parent link="base_link" />
<child link="left_wheel_backside" />
<origin xyz="-0.2 0.2 -0.05" rpy="1.570796 0 0"/>
</joint>
<link name="right_wheel_frontside">
<visual>
<geometry>
<cylinder radius="0.04" length="0.05" />
</geometry>
<material name="red">
<color rgba="1 0 0 1"/>
</material>
</visual>
</link>
<joint name="base_link_right_wheel_frontside" type="continuous">
<parent link="base_link" />
<child link="right_wheel_frontside" />
<origin xyz="0.2 -0.2 -0.05" rpy="1.570796 0 0"/>
</joint>
<link name="right_wheel_backside">
<visual>
<geometry>
<cylinder radius="0.04" length="0.05" />
</geometry>
<material name="red">
<color rgba="1 0 0 1"/>
</material>
</visual>
</link>

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store