Skip to content

Contents

Introduction

Now that we have added both a model of our dynamics and a model of our sensors to CRS in the previous tutorials, let's take care of the msg files before we begin building our ROS architecture. ROS messages define the data format our ROS nodes will use to communicate later on. Almost all of the ROS-related code for CRS is defined within the ros4crs directory. We will just be dipping our toes in to src/ros4crs/crs_msgs, so don't worry about all those other folders (yet).

Step-by-Step

Folder Structure

Setup folder structure

1. Make sure you have matching folder for your model e.g. `crs_msgs/msg/parafoil`
2. Create `parafoil/core_messages` folder

State Message Definition

Create state msg file

  1. Duplicate car_state_cart.msg into parafoil/core_messages, and rename to match our model, e.g. parafoil_4dof_state.msg
  2. Edit state msg to match states from model e.g.

    Header header
    float64 x
    float64 y
    ...
    float64 w
    

Input Message Definition

Create input msg file

  1. Duplicate car_input.msg into parafoil/core_messages, and rename to match our model, e.g. parafoil_4dof_input.msg
  2. Edit input msg to match input from model, e.g.

    Header header
    float64 deflection_symmetric
    float64 deflection_asymmetric
    

Sensor Message Definition

Create each sensor's msg file. Depending on your exact system architecture it may make sense to move these message files into a separate I/O folder or ROS package at a later date, but as a starting point it makes sense to define them within the generic crs_msgs package

  1. Duplicate a previous .msg file or create a new one, name to match our sensor e.g parafoil_imu.msg
  2. Edit message to match sensor output e.g. for the parafoil IMU sensor

    Header header
    float64 p
    float64 q
    ...
    float64 a3
    

Admin Files

Update CmakeLists.txt

  1. Duplicate & update add_message_files-block, matching your folder/file structure

    add_message_files(
    DIRECTORY msg/parafoil/core_messages
    FILES
    parafoil_4dof_input.msg
    parafoil_4dof_state.msg
    parafoil_gps.msg
    parafoil_imu.msg
    )
    

Update package.xml

1. Update maintainer info (if necessary)

Review

Folder structure should then be equivalent to:

crs_msgs
├── CMakeLists.txt
├── msg
   ├── car
      └── ...
   ├── ...
   └── parafoil
       └── core_messages
           ├── parafoil_4dof_input.msg
           ├── parafoil_4dof_state.msg
           ├── parafoil_gps.msg
           └── parafoil_imu.msg
└── package.xml

Up Next

Now that we have defined our messages we can begin integrating our model into ROS, either by developing our own, barebones ROS simulator (recommended for ROS beginners) or by directly integrating our model into CRS' ros4crs/ros_simulator (recommended for those familiar with ROS)