The first link of this model is called the base_link. This is the main body of the robot.
You can notice that some of the links have different files referenced for the visual and for the collision models. The reason behind this is that the simulation uses much less resources if you use a simpler model for the collision than for the visualization.
In the case of this urdf file, the path which indicates the location of the meshes is a so-called absolute path. This gives the location of the file in the entire file system starting from /. In order for rviz to be able to locate the meshes given by an absolute path, the <file location> section in the <mesh filename="<file location>" element needs to start with file://
The other links of the model consists of the base_footprint, imu_link, top_link, front_left_wheel, front_right_wheel, rear_left_wheel, rear_right_wheel, camera_link, camera_rgb_frame, camera_depth_frame and the laser. These correspond to the footprint of the robot on the ground, the imu sensor, the top cover section, the four wheels, the camera and its frames, and the lidar sensor of the robot, respectively.
These links are connected by joints, in most cases to the base_link, but in some cases to each other. When a component is supposed to be fixed and unmoving with respect to the component it is attached to, a fixed joint is used. This is the case for example in case of the top_link and the base_link.
When a component is supposed to be moving, however, it is attached by a different type of joint. For example in case of the wheels, they are attached by continuous joints to the base_link.
rosbot.urdf
<?xml version="1.0" ?><!-- This file has been created with using the files available at https://github.com/husarion/rosbot_description. These have an MIT licence.MIT LicenseCopyright (c) 2018-2020 Husarion Sp. z o.o.Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--><robotname="husarion_rosbot"><!--<link name="dummy">--><!-- </link>--> <linkname="base_link"> <pose>0 0 0.1 0 0 0</pose> <inertial> <massvalue="5"/> <originrpy=" 0 0 0"xyz="0 0 0.04"/><!-- <inertia ixx="0.01" ixy="0.01" ixz="0.0" iyy="0.01" iyz="0.01" izz="0.01"/>--> <inertiaixx="0.01"ixy="0.0"ixz="0.0"iyy="0.017"iyz="0.0"izz="0.026"/> </inertial> <collisionname="collision"> <originrpy="0 0 0"xyz="0 0 0.02"/> <geometry> <boxsize="0.20 0.15 0.04"/> </geometry> </collision> <visualname="base_link_visual"> <originrpy=" 1.5707 0 1.5707"xyz="0 0 -0.02"/> <geometry> <meshfilename="file:///ros2_pkgs_ws/src/husarion_rosbot/meshes/box.dae"scale="0.001 0.001 0.001"/> </geometry> <materialname="white"> <colorrgba="1.0 1.0 1.0 1.0"/> </material> </visual> </link><!-- <joint name="dummy_joint" type="fixed">--><!-- <parent link="dummy"/>--><!-- <child link="base_link"/>--><!-- </joint>--> <linkname="base_footprint"/> <jointname="base_joint"type="fixed"> <parentlink="base_link"/> <childlink="base_footprint"/> <originrpy="0 0 0"xyz="0.0 0.0 0.0"/> </joint> <linkname="imu_link"/> <jointname="imu_joint"type="fixed"> <parentlink="base_link"/> <childlink="imu_link"/> <originrpy="0 0 0"xyz="0.0 0.0 0.0"/> </joint> <linkname="top_link"> <pose>0 0 0 0 0 0</pose> <inertial> <massvalue="0.01"/> <originrpy=" 0 0 0"xyz="0 0 0.055"/> <inertiaixx="0.0001"ixy="0"ixz="0"iyy="0.0001"iyz="0"izz="0.0001"/> </inertial> <visualname="top"> <originrpy=" 1.5707 0 1.5707"xyz="0 0 0.055"/> <geometry> <meshfilename="file:///ros2_pkgs_ws/src/husarion_rosbot/meshes/upper.dae"scale="0.001 0.001 0.001"/> </geometry> <materialname="red"> <colorrgba="0.8 0.0 0.0 1.0"/> </material> </visual> <collision> <geometry> <boxsize="0.001 0.001 0.001"/> </geometry> </collision>> </link> <jointname="top_joint"type="fixed"> <axisxyz="0 1 0"/> <originrpy="0 0 0"xyz="0 0 0"/> <parentlink="base_link"/> <childlink="top_link"/> </joint> <linkname="front_left_wheel"> <collisionname="collision"> <originrpy="0 0 1.5707"xyz="0 0 0"/> <geometry> <meshfilename="file:///ros2_pkgs_ws/src/husarion_rosbot/meshes/wheel_simple.dae"scale="0.001 0.001 0.001"/> </geometry> <surface> <friction> <ode> <mu>10</mu> <mu2>10</mu2> </ode> </friction> </surface> </collision> <visualname="front_left_wheel_visual"> <originrpy="0 0 1.5707"xyz="0 0 0"/> <geometry> <meshfilename="file:///ros2_pkgs_ws/src/husarion_rosbot/meshes/wheel.dae"scale="0.001 0.001 0.001"/> </geometry> <materialname="black"> <colorrgba="0.0 0.0 0.0 1.0"/> </material> </visual> <inertial> <originrpy="0 1.5707 1.5707"xyz="0 0 0"/> <massvalue="0.5"/> <inertiaixx="0.001"ixy="0.0"ixz="0.0"iyy="0.001"iyz="0.0"izz="0.001"/> </inertial> </link> <linkname="front_right_wheel"> <collisionname="collision"> <originrpy="0 0 -1.5707"xyz="0 0 0"/> <geometry> <meshfilename="file:///ros2_pkgs_ws/src/husarion_rosbot/meshes/wheel_simple.dae"scale="0.001 0.001 0.001"/> </geometry> <surface> <friction> <ode> <mu>10</mu> <mu2>10</mu2> </ode> </friction> </surface> </collision> <visualname="front_right_wheel_visual"> <originrpy="0 0 -1.5707"xyz="0 0 0"/> <geometry> <meshfilename="file:///ros2_pkgs_ws/src/husarion_rosbot/meshes/wheel.dae"scale="0.001 0.001 0.001"/> </geometry> <materialname="black"> <colorrgba="0.0 0.0 0.0 1.0"/> </material> </visual> <inertial> <originrpy="0 1.5707 1.5707"xyz="0 0 0"/> <massvalue="0.5"/> <inertiaixx="0.001"ixy="0.0"ixz="0.0"iyy="0.001"iyz="0.0"izz="0.001"/> </inertial> </link> <linkname="rear_left_wheel"> <collisionname="collision"> <originrpy="0 0 1.5707"xyz="0 0 0"/> <geometry> <meshfilename="file:///ros2_pkgs_ws/src/husarion_rosbot/meshes/wheel_simple.dae"scale="0.001 0.001 0.001"/> </geometry> <surface> <friction> <ode> <mu>10</mu> <mu2>10</mu2> </ode> </friction> </surface> </collision> <visualname="rear_left_wheel_visual"> <originrpy="0 0 1.5707"xyz="0 0 0"/> <geometry> <meshfilename="file:///ros2_pkgs_ws/src/husarion_rosbot/meshes/wheel.dae"scale="0.001 0.001 0.001"/> </geometry> <materialname="black"> <colorrgba="0.0 0.0 0.0 1.0"/> </material> </visual> <inertial> <originrpy="0 1.5707 1.5707"xyz="0 0 0"/> <massvalue="0.5"/> <inertiaixx="0.001"ixy="0.0"ixz="0.0"iyy="0.001"iyz="0.0"izz="0.001"/> </inertial> </link> <linkname="rear_right_wheel"> <collisionname="collision"> <originrpy="0 0 -1.5707"xyz="0 0 0"/> <geometry> <meshfilename="file:///ros2_pkgs_ws/src/husarion_rosbot/meshes/wheel_simple.dae"scale="0.001 0.001 0.001"/> </geometry> <surface> <friction> <ode> <mu>10</mu> <mu2>10</mu2> </ode> </friction> </surface> </collision> <visualname="rear_right_wheel_visual"> <originrpy="0 0 -1.5707"xyz="0 0 0"/> <geometry> <meshfilename="file:///ros2_pkgs_ws/src/husarion_rosbot/meshes/wheel.dae"scale="0.001 0.001 0.001"/> </geometry> <materialname="black"> <colorrgba="0.0 0.0 0.0 1.0"/> </material> </visual> <inertial> <originrpy="0 1.5707 1.5707"xyz="0 0 0"/> <massvalue="0.5"/> <inertiaixx="0.001"ixy="0.0"ixz="0.0"iyy="0.001"iyz="0.0"izz="0.001"/> </inertial> </link> <jointname="front_left_wheel_hinge"type="continuous"> <originrpy="0 0 0"xyz="0.05 0.11 0"/> <childlink="front_left_wheel"/> <parentlink="base_link"/> <axisrpy="0 0 0"xyz="0 1 0"/><!-- <limit effort="5" velocity="50"/>--> <limiteffort="1"velocity="10"/> <joint_propertiesdamping="5.0"friction="1.0"/> </joint> <jointname="front_right_wheel_hinge"type="continuous"> <originrpy="0 0 0"xyz="0.05 -0.11 0"/> <childlink="front_right_wheel"/> <parentlink="base_link"/> <axisrpy="0 0 0"xyz="0 1 0"/><!-- <limit effort="5" velocity="50"/>--> <limiteffort="1"velocity="10"/> <joint_propertiesdamping="5.0"friction="1.0"/> </joint> <jointname="rear_left_wheel_hinge"type="continuous"> <originrpy="0 0 0"xyz="-0.055 0.11 0"/> <childlink="rear_left_wheel"/> <parentlink="base_link"/> <axisrpy="0 0 0"xyz="0 1 0"/><!-- <limit effort="5" velocity="50"/>--> <limiteffort="1"velocity="10"/> <joint_propertiesdamping="5.0"friction="1.0"/> </joint> <jointname="rear_right_wheel_hinge"type="continuous"> <originrpy="0 0 0"xyz="-0.055 -0.11 0"/> <childlink="rear_right_wheel"/> <parentlink="base_link"/> <axisrpy="0 0 0"xyz="0 1 0"/><!-- <limit effort="5" velocity="50"/>--> <limiteffort="1"velocity="10"/> <joint_propertiesdamping="5.0"friction="1.0"/> </joint> <linkname="camera_link"> <collision> <originrpy="0 0 0"xyz="0.02 0 0"/> <geometry> <boxsize="0.001 0.001 0.001"/> </geometry> </collision> <visual> <originrpy="1.5707 0 1.5707"xyz="-0.01 0 -0.03"/> <geometry> <meshfilename="file:///ros2_pkgs_ws/src/husarion_rosbot/meshes/astra.dae"scale="0.001 0.001 0.001"/> </geometry> <materialname="black"> <colorrgba="0.0 0.0 0.0 1.0"/> </material> </visual> <inertial> <massvalue="1e-5"/> <originrpy="0 0 0"xyz="0 0 0"/> <inertiaixx="0"ixy="0"ixz="0"iyy="0"iyz="0"izz="0"/> </inertial> </link> <jointname="astra_joint"type="fixed"> <axisxyz="0 0 0"/> <originrpy="0 0 0"xyz="-0.03 0 0.18"/> <parentlink="base_link"/> <childlink="camera_link"/> </joint> <linkname="camera_rgb_frame"> </link> <jointname="camera_optical_joint"type="fixed"> <originrpy="-1.5707963267948966 0 -1.5707963267948966"xyz="0 0 0"/> <parentlink="camera_link"/> <childlink="camera_rgb_frame"/> </joint> <linkname="camera_depth_frame"> </link> <jointname="camera_depth_joint"type="fixed"> <originrpy="-1.5707963267948966 0 -1.5707963267948966"xyz="0 0 0"/> <parentlink="camera_link"/> <childlink="camera_depth_frame"/> </joint><!-- rplidar Laser --> <linkname="laser"> <collision> <originrpy="1.5707 0 4.71"xyz="0 0 0.058"/> <geometry> <meshfilename="file:///ros2_pkgs_ws/src/husarion_rosbot/meshes/rplidar_simple.dae"scale="0.001 0.001 0.001"/> </geometry> </collision> <visual> <originrpy="1.5707 0 4.71"xyz="0 0 0.058"/> <geometry> <meshfilename="file:///ros2_pkgs_ws/src/husarion_rosbot/meshes/rplidar.dae"scale="0.001 0.001 0.001"/> </geometry> <materialname="black"> <colorrgba="0.0 0.0 0.0 1.0"/> </material> </visual> <inertial> <massvalue="1e-5"/> <originrpy="1.5707 0 4.71"xyz="0 0 0.058"/> <inertiaixx="0"ixy="0"ixz="0"iyy="0"iyz="0"izz="0"/> </inertial> </link> <jointname="rplidar_joint"type="fixed"> <axisxyz="0 1 0"/> <originrpy="0 0 3.14"xyz="0.02 0 0"/> <parentlink="base_link"/> <childlink="laser"/> </joint> <gazebo> <pluginfilename="libignition-gazebo-joint-state-publisher-system.so"name="ignition::gazebo::systems::JointStatePublisher"> <topic>/joint_state</topic> </plugin> <pluginfilename="ignition-gazebo-diff-drive-system"name="ignition::gazebo::systems::DiffDrive"> <left_joint>front_left_wheel_hinge</left_joint> <left_joint>rear_left_wheel_hinge</left_joint> <right_joint>front_right_wheel_hinge</right_joint> <right_joint>rear_right_wheel_hinge</right_joint> <wheel_separation>0.1</wheel_separation> <wheel_radius>0.04</wheel_radius> <topic>cmd_vel</topic> <odom_publish_frequency>20</odom_publish_frequency> <frame_id>odom</frame_id> <child_frame_id>base_link</child_frame_id> </plugin> </gazebo> <gazeboreference="laser"> <sensorname="laser"type="gpu_lidar"> <topic>scan</topic> <frame>laser</frame> <pose>0 0 0.06 0 0 0</pose> <visualize>false</visualize> <update_rate>20</update_rate> <ray> <scan> <horizontal> <samples>360</samples> <resolution>1</resolution> <min_angle>-3.14159265</min_angle> <max_angle>3.14159265</max_angle> </horizontal> </scan> <range> <min>0.1</min> <max>10.0</max> <resolution>0.01</resolution> </range> <noise> <type>gaussian</type> <mean>0.0</mean> <stddev>0.01</stddev> </noise> </ray> </sensor> </gazebo> <gazeboreference="imu_link"> <sensorname="imu_sensor"type="imu"> <always_on>true</always_on> <update_rate>20</update_rate> <visualize>true</visualize><!--<namespace>/demo</namespace>--> <topic>imu</topic> <imu> <angular_velocity> <x> <noisetype="gaussian"> <mean>0.0</mean> <stddev>2e-4</stddev> <bias_mean>0.0000075</bias_mean> <bias_stddev>0.0000008</bias_stddev> </noise> </x> <y> <noisetype="gaussian"> <mean>0.0</mean> <stddev>2e-4</stddev> <bias_mean>0.0000075</bias_mean> <bias_stddev>0.0000008</bias_stddev> </noise> </y> <z> <noisetype="gaussian"> <mean>0.0</mean> <stddev>2e-4</stddev> <bias_mean>0.0000075</bias_mean> <bias_stddev>0.0000008</bias_stddev> </noise> </z> </angular_velocity> <linear_acceleration> <x> <noisetype="gaussian"> <mean>0.0</mean> <stddev>1.7e-2</stddev> <bias_mean>0.1</bias_mean> <bias_stddev>0.001</bias_stddev> </noise> </x> <y> <noisetype="gaussian"> <mean>0.0</mean> <stddev>1.7e-2</stddev> <bias_mean>0.1</bias_mean> <bias_stddev>0.001</bias_stddev> </noise> </y> <z> <noisetype="gaussian"> <mean>0.0</mean> <stddev>1.7e-2</stddev> <bias_mean>0.1</bias_mean> <bias_stddev>0.001</bias_stddev> </noise> </z> </linear_acceleration> </imu> </sensor> </gazebo></robot>
In the page before, we have described the phenomena of simulation gap. This simulation gap concerns both the simulation world and the robot's model. In case the world's model or the robot's model and behavior would be made more realistic, the effect of simulation gap would be lessened. However, this is out of the bounds of this project. This is why in this project a ROS2 node was created to update the position and orientation of the robot model inside the simulated world that is available here.
Setting the appropriate QoS policy is very important for this script. It needs to be set to Best effort, as with the reliable setting the node transfers messages too slowly. Moreover, it needs to be set to VOLATILE instead of TRANSIENT_LOCAL, otherwise the node does not transmit messages at all.