CMU-cabot/cabot

Migrate cabot_sites repositories for ROS2

Closed this issue · 0 comments

This is related to #72.

The current cabot_sites_xxx repos has a main branch and a ros2 branch.
The ROS2 migration requires you to migrate your cabot_sites_xxx.
General migration steps are as follows

  1. make a branch dev-ros2 from ros2
  2. merge main/master into dev-ros2
  3. revert config/config.sh file as main/master one (usually ros2 branch updated the file)
  4. make sure CMakeLists.txt installs all the sub folders such as models and worlds
  5. configure gazebo world for ROS2 environment
    • model files that are accessed with file:// URI in world files needs to be updated to model:// URI
    • typical configuration of models directory
  6. remove export GAZEBO_RESOURCE_PATH=$sitedir if it is specified config.sh (this may cause a crush gazebo ROS2)
- package.xml
- worlds/your_world.world
- models/
  |- <model_name1>/
  |  |- <model_name1>.{stl,dae}
  |  |- model.config
  |  |- model.sdf
  |- <model_name2>/
  |  |- <model_name2>.{stl,dae}
  |  |- model.config
  |  |- model.sdf
  |- database.config
  |- ... # others

Start from your world file

find file:// URIs in your world file

    ...
    <model name="my_mesh">
      <pose>0 0 0 0 0 0</pose>
      <static>true</static>
      <link name="link1">
        <collision name="collision">
          <geometry>
            <mesh>
      	      <uri>file://models/model_name1/model_name1.stl</uri>
              <scale>0.001 0.001 0.001</scale>
      	    </mesh>
          </geometry>
        </collision>
        <visual name="visual">
          <geometry>
            <mesh>
      	      <uri>file://models/model_name1/model_name1.dae</uri>
      	    </mesh>
          </geometry>
        </visual>
      </link>
      ...

modify it to model:// URIs

You can make any portion of sdf elements into a model. In this case, <link name="link1"> element is moved to a model.sdf

   ...
    <model name="my_mesh">
      <pose>0 0 0 0 0 0</pose>
      <static>true</static>
      <model name='link1'>
	<static>true</static>
	<include>
          <uri>model://model_name1</uri>
	</include>
      </model>
      ...

Configure models

sample model.sdf

<?xml version='1.0'?>
<sdf version='1.6'>
  <model name='model_name1'>
    <link name="link1">
      <collision name="collision">
        <geometry>
          <mesh>
      	    <uri>model://model_name1/model_name1.stl</uri>
            <scale>0.001 0.001 0.001</scale>
      	  </mesh>
        </geometry>
      </collision>
      <visual name="visual">
        <geometry>
          <mesh>
      	    <uri>model://model_name1/model_name1.dae</uri>
      	  </mesh>
        </geometry>
      </visual>
    </link>
  </model>
</sdf>

sample model.config

<?xml version="1.0" ?>
<model>
    <name>model_name1</name>
    <version>1.0</version>
    <sdf version="1.6">model.sdf</sdf>
    <author>
        <name></name>
        <email></email>
    </author>
    <description></description>
</model>

sample database.config

<?xml version='1.0'?>
<database>
  <name>cabot_sites_xxx_model</name>
  <license>MIT</license>
  <models>
    <uri>file://model_name1</uri>
    <uri>file://model_name2</uri>
  </models>
</database>

add gazebo_ros tag into package.xml so that gazebo_ros can find your models

<package>
  ...
  <export>
    <build_type>ament_cmake</build_type>
    <gazebo_ros gazebo_model_path="${prefix}/models"/>
  </export>
</package>