Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump mros2 to v0.5.3 #50

Merged
merged 6 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ else()
endif()
message(STATUS "APP_NAME=${APP_NAME}")

# specify your own files for the application
# specify your own file(s) for the application
set(APP_SRCS
workspace/${APP_NAME}/app.cpp
)
Expand All @@ -42,16 +42,18 @@ execute_process(COMMAND git submodule update --init --recursive
add_library(mros2 INTERFACE)
add_subdirectory(mros2)

# Generate plaform/templates.hpp from mros2 application code
## You can add dir(s) in `--indir` if you have several dirs
## that contain application code files
execute_process(COMMAND
python3 ${CMAKE_CURRENT_SOURCE_DIR}/mros2/mros2_header_generator/templates_generator.py --outdir ${CMAKE_CURRENT_SOURCE_DIR}/platform --file ${APP_SRCS}
python3 ${CMAKE_CURRENT_SOURCE_DIR}/mros2/mros2_header_generator/templates_generator.py --outdir ${CMAKE_CURRENT_SOURCE_DIR}/platform --indir ${CMAKE_CURRENT_SOURCE_DIR}/workspace/${APP_NAME}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

set(MROS2_TARGET_DIR "${PROJECT_SOURCE_DIR}/platform")

target_include_directories(
mros2-mbed
PRIVATE workspace/${APP_NAME}
PRIVATE workspace/custom_msgs
PRIVATE ${MROS2_TARGET_DIR}
)

Expand Down
90 changes: 18 additions & 72 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# mros2-mbed

mROS 2 (formally `mros2`) realizes a agent-less and lightweight runtime environment compatible with ROS 2 for embedded devices.
mROS 2 (`mros2` as casually codename) realizes a agent-less and lightweight runtime environment compatible with ROS 2 for embedded devices.
mROS 2 mainly offers pub/sub APIs compatible with [rclcpp](https://docs.ros.org/en/rolling/p/rclcpp/index.html) for embedded devices.

mROS 2 consists of communication library for pub/sub APIs, RTPS protocol, UDP/IP stack, and real-time kernel.
Expand Down Expand Up @@ -36,7 +36,7 @@ Please also check [mros2 repository](https://github.com/mROS-base/mros2) for mor
- You can configure them by editing `platform/mros2-platform.h`.
- Note that we have not confirmed the operation using DHCP setting yet. So you cannot comment out the `#define MROS2_IP_ADDRESS_STATIC` line to assign static IP address.
- The firewall on the host (Ubuntu) needs to be disabled for ROS 2 (DDS) communication (e.g. `$ sudo ufw disable`).
- If the host is connected to the Internet other than wired network (e.g., Wi-Fi), communication with mros2 may not work properly. In that case, please turn off them.
- If the host is connected to the Internet with other network adapters, communication with mros2 may not work properly. In that case, please turn off them.

## Getting Started

Expand Down Expand Up @@ -274,88 +274,34 @@ Please also check [mROS-base/mros2-host-examples](https://github.com/mROS-base/m
- And then, subscribe to the topic `/to_linux` and visualize it by `Image View` on the GUI like below.
[Movie Sample](https://github-production-user-asset-6210df.s3.amazonaws.com/90823686/243369057-839cf812-eb1d-45bf-820e-e0166253899c.webm)

## Note: File for the application
## Note: File(s) for the application

The main source of the application is `app.cpp`.
You can change filename by editing `${APP_SRCS}` in `CMakeLists.txt`.
Currently, we could not handle multiple files as source code,,,
You can change and/or add filename by editing `${APP_SRCS}` in `CMakeLists.txt`.

## 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/`.
If you have several directories that contain application code files,
you also need to edit `CMakeLists.txt` (see details in comment).

```
$ 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.
## Generating header files for custom MsgTypes

```
#include "mros2.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

`include/rtps/config.h` is the configuration file for embeddedRTPS.
We may be able to realize the RTPS communication to the appropriate configuration by editting this file.

`platform/rtps/config.h` is the configuration file for embeddedRTPS.
We may be able to realize the RTPS communication to the appropriate configuration by editting this file.
And also, you can configure for lwIP (UDP/IP) by `mbed_app.json`.
Currently, we are unable to communicate large size of messages probably due to these configurations.

We should seek the appropreate configurations or how to fit them to the demand of applications.
Please let us know about them if you have any opinions or awesome knowledges!

## Tips 2: Getting started in 5 minutes with the online compiler
## Tips 2: Development with the latest mros2 repo (a.k.a memo for me)

When using the docker environment for build, it will try to clone `mros2/` dir/repo automatically during the cmake process.
To prevent this, we can simply clone code from GitHub as the development mode and/or add `#` to the beginning of `mros2.lib`.

## Tips 3: Getting started in 5 minutes with the online compiler

> Caution:
> Although you can easily try out the basic features of mros2 online, this environment has not been fully maintained.
Expand All @@ -375,7 +321,7 @@ Please feel free to let us know in [Issues on this repository](https://github.co
## Submodules and Licenses

The source code of this repository itself is published under [Apache License 2.0](https://github.com/mROS-base/mros2/blob/main/LICENSE).
Please note that this repository contains the following stacks as the submodules, and also check their Licenses.
Please note that this repository requires the following stacks as the submodules, and also check their Licenses.

- [mros2](https://github.com/mROS-base/mros2): the pub/sub APIs compatible with ROS 2 Rclcpp
- [embeddedRTPS](https://github.com/mROS-base/embeddedRTPS): RTPS communication layer (including lwIP and Micro-CDR)
Expand Down
2 changes: 1 addition & 1 deletion mros2.lib
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://github.com/mROS-base/mros2#v0.5.2
https://github.com/mROS-base/mros2#v0.5.3
15 changes: 9 additions & 6 deletions platform/mros2-platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace mros2_platform
nsapi_error_t network_connect(void)
{
EthernetInterface network;
nsapi_size_or_error_t result;
nsapi_size_or_error_t result = 0;

#ifdef MROS2_IP_ADDRESS_STATIC
network.set_dhcp(false);
Expand All @@ -38,17 +38,20 @@ nsapi_error_t network_connect(void)
#endif /* MROS2_IP_ADDRESS_STATIC */
result = network.connect();

if (result) {
printf("Network connection failed: %d\r\n", result);
if (result)
{
MROS2_ERROR("Network connection failed: %d", result);
return result;
} else {
printf("Successfully connected to network\r\n");
}
else
{
MROS2_DEBUG("Successfully connected to network");
}

SocketAddress socketAddress;
network.get_ip_address(&socketAddress);
const char* ip_address = socketAddress.get_ip_address();
printf(" IP Address: %s\r\n", ip_address);
MROS2_DEBUG(" IP Address: %s", ip_address);

/* convert IP address to be used in rtps/config.h */
std::array<uint8_t, 4> ipaddr;
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.

Loading