Skip to main content

Install ROS 2 tutorial

Install ROS 2 and Luos

First, install ROS 2 Foxy for your OS with FastRTPS. Also, install colcon as advised in the guidelines. If you are not familiar with ROS, you should go on with a couple of ROS 2 tutorials to get started.

Then clone luos_ros2 to your workspace and compile it with colcon:

cd ros2_ws/src/    # Or replace by your ROS 2 workspace name, maybe also dev_ws/src
git clone
cd luos_ros2/luos_interface
pip3 install --no-warn-script-location .
cd ~/ros2_ws && colcon build --symlink-install
source ~/ros2_ws/install/setup.bash

Get started with Luos in ROS 2

Plug your Luos gate in and other services, such as IMU, Color or State, and run the broker. It will return the detected services:

~$ ros2 launch luos_interface
[INFO] [luos_broker]: Connecting to /dev/ttyUSB0...
[INFO] [luos_broker]: Found services:
Type Alias ID
Gate gate 1
Imu Imu_mod 2
State button_mod 3
Color rgb_led_mod 5

If you have several Luos gates, you need several brokers. Specify a port and a unique name for each of them:

ros2 launch luos_interface device:=/dev/ttyUSB1 name:=brokerUSB1

According to the services you have plugged-in, the broker will automatically publish the relevant topics in the namespace of your services' aliases. Here we have plugged a State service (alias button_mod), a Imu service (alias Imu_mod) and a Color service (alias rgb_led_mod) to the gate; thus the broker publishes the following topics:

~$ ros2 topic list

Most variables advertise both /read and /write topics to get data, write data, or (de)activate this data source. Other data types might be aggregates of Luos variables (such as the IMU) or Luos events.

In order to echo messages from the terminal, use a regular ROS subscriber. For instance, here is the current IMU data:

~$ ros2 topic echo /Imu_mod/imu
sec: 1581267954
nanosec: 5449
frame_id: Imu_mod
x: 0.97814
y: 0.052695
z: -0.042831
w: 0.196548
orientation_covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
x: 0.0
y: 0.0
z: 0.0
angular_velocity_covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
x: 0.177171
y: 0.04968
z: 0.176722
linear_acceleration_covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

In order to publish messages to the Luos services, use a regular ROS publisher. For instance, here is how to light up the Luos RGB service, in a pink color:

ros2 topic pub /rgb_led_mod/variables/color/write std_msgs/msg/ColorRGBA "{r: 64, g: 0, b: 64}" --once

Get started with my own ROS2 package using Luos in Python

These command lines will create a new package my_luos_ros2_package relying on luos_interface:

cd ~/ros2_ws/src
ros2 pkg create my_luos_ros2_package --build-type ament_python --dependencies luos_interface

You can then add your ROS Python scripts by taking examples on the shared-bike example page.