Skip to content

Commit

Permalink
move custom_msgs/ to mros2 repo because it is common feature
Browse files Browse the repository at this point in the history
  • Loading branch information
takasehideki committed Sep 20, 2023
1 parent c881b29 commit 0d76e84
Show file tree
Hide file tree
Showing 11 changed files with 2 additions and 1,353 deletions.
64 changes: 2 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,68 +284,8 @@ you also need to edit `CMakeLists.txt` (see details in comment).

## Generating header files for custom MsgTypes

You can use almost any [built-in-types in ROS 2](https://docs.ros.org/en/rolling/Concepts/About-ROS-Interfaces.html#field-types) on the embedded device.

In additon, you can define a customized message type (e.g., `Twist.msg`) in the same way as in ROS 2, and use its header file for your application. This section describes how to generate header files for your own MsgTypes (`geometry_msgs::msg::Twist` as an example).

### Prepare .msg files

`.msg` files are simple text files that describe the fields of a ROS message (see [About ROS 2 interface](https://docs.ros.org/en/rolling/Concepts/About-ROS-Interfaces.html)). In mros2, they are used to generate header files for messages in embedded applications.

Prepare `Twist.msg` file and make sure it is in `workspace/custom_msgs/geometry_msgs/msg/`.

```
$ cat workspace/custom_msgs/geometry_msgs/msg/Twist.msg
geometry_msgs/msg/Vector3 linear
geometry_msgs/msg/Vector3 angular
```

In this example, `Twist` has a nested structure with `Vector3` as a child element. So you also need to prepare its file.

```
$ cat workspace/custom_msgs/geometry_msgs/msg/Vector3.msg
float64 x
float64 y
float64 z
```

### Generate header files

To generate header files for `Twist` and `Vector3`, run the following command in `workspace/`.

```
$ cd workspace
$ python3 ../mros2/mros2_header_generator/header_generator.py geometry_msgs/msg/Twist.msg
```

Make sure header files for custom MsgType are generated in `custom_msgs/`.

```
$ ls -R custom_msgs/
custom_msgs/:
geometry_msgs
custom_msgs/geometry_msgs:
msg
custom_msgs/geometry_msgs/msg:
twist.hpp vector3.hpp Twist.msg Vector3.msg
```

You can now use them in your applicaton like this.

```
#include "mros2.hpp"
#include "mros2-platform.hpp"
#include "geometry_msgs/msg/vector3.hpp"
#include "geometry_msgs/msg/twist.hpp"
int main(int argc, char * argv[])
{
<snip.>
pub = node.create_publisher<geometry_msgs::msg::Twist>("cmd_vel", 10);
<snip.>
```
If you want to use your own customized message type followed by the ROS 2 manner, please refer to [mros2#generating-header-files-for-custom-msgtypes](https://github.com/mROS-base/mros2#generating-header-files-for-custom-msgtypes) section.
(this section was moved because it is common feature for mROS 2).

## Tips 1: Configure the network

Expand Down
3 changes: 0 additions & 3 deletions workspace/custom_msgs/geometry_msgs/msg/Point.msg

This file was deleted.

2 changes: 0 additions & 2 deletions workspace/custom_msgs/geometry_msgs/msg/Pose.msg

This file was deleted.

4 changes: 0 additions & 4 deletions workspace/custom_msgs/geometry_msgs/msg/Quaternion.msg

This file was deleted.

2 changes: 0 additions & 2 deletions workspace/custom_msgs/geometry_msgs/msg/Twist.msg

This file was deleted.

3 changes: 0 additions & 3 deletions workspace/custom_msgs/geometry_msgs/msg/Vector3.msg

This file was deleted.

272 changes: 0 additions & 272 deletions workspace/custom_msgs/geometry_msgs/msg/point.hpp

This file was deleted.

Loading

0 comments on commit 0d76e84

Please # to comment.