Robot setup - zitongbai/ur_project_ros2 GitHub Wiki
This page provides some tips for setting up a robot in ROS2. It is not a tutorial but gives some scattered suggestions.
For example, for robot ur_robotiq_rs
, we create a ur_robotiq_rs_macro.urdf.xacro
to describe it. Inside this file, we put xacro macro
of universal robot arm, robotiq gripper and realsense camera together to make a new robot: ur_robotiq_rs
. Xacro param is used to extend the capability. ur_robotiq_rs
is also defined as a xacro macro
for the convenience of re-use in other xacro files.
Use xacro
in terminal to check whether your xacro file is valid, for example:
xacro ur_robotiq_rs.urdf.xacro > test.urdf
Consider using:
<mesh filename="file://$(find robotiq_description)/xxx"/>
insteal of:
<mesh filename="package://robotiq_description/xxx"/>
The last way would make gazebo fail to load your urdf file 😢.
It would cause error that is hard to find. For example: Unable to parse the value of parameter robot_description as yaml
- controllers.yaml (used for ros2 control
controller_manager
orlibgazebo_ros2_control.so
) - initial_positions.yaml (used for ros2 control, it would affect the
<state_interface>
in<ros2_control>
tag in urdf)
- Use prefix for link and joint.
- Add prefix to blocks like
ros2_control
tag - Use xacro property, argument, etc. to make your code clear and readable.
Sometimes it is better to add gazebo plugin tag in low level robot description files to make your code clear. But for some plugins like libgazebo_ros2_control.so
and libgazebo_grasp_fix.so
, it is better to only load them once at the top level description file, this is because:
-
libgazebo_ros2_control.so
requirescontrollers.yaml
for controller manager, which may contain joints with different prefix, but it seems not common to pass parameters to yaml files to change the prefix. -
libgazebo_grasp_fix.so
: https://github.com/JenniferBuehler/gazebo-pkgs/issues/2#issuecomment-319747463
In the package.xml
of your package, add the following:
<export>
<build_type>ament_cmake</build_type>
<!-- gazebo_ros_paths_plugin automatically adds these to
GAZEBO_PLUGIN_PATH and GAZEBO_MODEL_PATH when you do this export inside
the package.xml file. You can than use URIs of type model://my_package/stuff. -->
<!-- https://answers.gazebosim.org/question/6568/uri-paths-to-packages-in-the-sdf-model-file/ -->
<gazebo_ros
gazebo_plugin_path="${prefix}/lib"
gazebo_model_path="${prefix}/.." />
</export>