Skip to content

Commit 2105fb1

Browse files
authored
Merge pull request #220 from BlueAndi/feature/ros2Wsl
ROS2 WSL updated
2 parents e82c80d + 02fe7cc commit 2105fb1

File tree

16 files changed

+288
-129
lines changed

16 files changed

+288
-129
lines changed

README.md

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ It provides different kind of exclusive applications, used for educational purpo
1919

2020
- [The ZumoComSystem Shield](#the-zumocomsystem-shield)
2121
- [The simulation](#the-simulation)
22-
- [Installation for simulation](#installation-for-simulation)
22+
- [Installation for simulation](#installation-for-simulation)
2323
- [How to start?](#how-to-start)
24+
- [Run](#run)
25+
- [Run with Webots launcher (recommended)](#run-with-webots-launcher-recommended)
26+
- [Run without Webots launcher](#run-without-webots-launcher)
27+
- [Run via terminal](#run-via-terminal)
2428
- [The target](#the-target)
2529
- [Installation for target](#installation-for-target)
2630
- [Build and flash procedure](#build-and-flash-procedure)
@@ -48,7 +52,7 @@ The simulation is based on the open source robot simulator *Webots*. The applica
4852

4953
![simulation-deployment](http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.githubusercontent.com/BlueAndi/DroidControlShip/main/doc/architecture/uml/PhysicalView/SimulationDeployment.plantuml)
5054

51-
## Installation for simulation
55+
### Installation for simulation
5256

5357
1. Install the native compiler toolchain:
5458
- Linux
@@ -64,7 +68,7 @@ The simulation is based on the open source robot simulator *Webots*. The applica
6468

6569
### How to start?
6670

67-
After you built the application, you will find in in ```.pio/build/<APPLICATION-NAME>/program.exe```. It provides several command line arguments to configure certain features. Use -h or --help to get a short user friendly overview about them.
71+
After you built the application, you will find it in ```.pio/build/<APPLICATION-NAME>/program[.exe]```. It provides several command line arguments to configure certain features. Use -h or --help to get a short user friendly overview about them.
6872

6973
The applications are using a configuration file in JSON format to retrieve certain settings. In the very first run, such a configuration file will be automatically be created. If there exists already one, it will be loaded without modifications (regardless of any other program arguments).
7074

@@ -78,6 +82,42 @@ MQTT Broker --> Webots World --> RadonUlzer --> DroidControlShip
7882

7983
In order to simplify this process, the [Launcher](https://github.com/gabryelreyes/Launcher) project is under active development.
8084

85+
### Run
86+
87+
There are 3 ways how to run now the application. Choose according to your needs.
88+
89+
#### Run with Webots launcher (recommended)
90+
91+
The Webots launcher is recommended to connect to the simulation.
92+
93+
It is mandatory if the simulation contains more than one robot. The robot is identified by its name. Adapt the robot name in the [platformio_override.ini](./platformio_override.ini), see *webots_robot_name*.
94+
95+
The Webots documentation has more details about [Single Simulation and Multiple Local Extern Robot Controllers](https://cyberbotics.com/doc/guide/running-extern-robot-controllers?tab-os=windows#single-simulation-and-multiple-local-extern-robot-controllers).
96+
97+
It is mandatory too if the simulation does not run locally (e.g. Webots runs on windows host and RadonUlzer in WSL).
98+
Set the IP address and the port in [platformio_override.ini](./platformio_override.ini), see *webots_ip_address* and *webots_protocol*.
99+
100+
Use *ipc* as *webots_protocol* for local connections and *tcp* for remote connections.
101+
102+
| Key | Description |
103+
| --- | ----------- |
104+
| webots\_ip\_address | The IP address of the Webots simulation, which is used for TCP communication. |
105+
| webots\_protocol | \[ipc\|tcp\] - ipc is faster but only works on the same machine, tcp works also over network. |
106+
| webots\_robot\_name | The robot name used to identify the robot in the Webots world. See Webots world robot prototype. |
107+
108+
PlatformIO project tasks --> &lt;APP-NAME&gt; --> Custom --> Launch
109+
110+
#### Run without Webots launcher
111+
112+
This can be choosen in case the simulation waits just for one robot.
113+
114+
PlatformIO project tasks --> &lt;APP-NAME&gt; --> General --> Upload
115+
116+
#### Run via terminal
117+
118+
1. Open a command line (shell) and change to the folder with the built executable in ```.pio/build/<APP-NAME>```. This folder contains all necessary shared libraries as well.
119+
2. Start the executable.
120+
81121
## The target
82122

83123
The main target of the firmware is the [ZumoComSystem](https://github.com/NewTec-GmbH/ZumoComSystem) from NewTec GmbH, which is a shield for the [Pololu 32U4 Zumo](https://www.pololu.com/product/2510) robot.

doc/ROS2/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,14 @@ The following diagram illustrates the component deployment of micro-ROS in the D
7171

7272
## Installation Steps
7373

74+
The installation procedure handles how the WSL in Windows is used to install the Ubuntu Linux distribution, the ROS2, Webots and micro-ROS parts.
75+
7476
1. [WSL with Ubuntu](./setup/wsl.md)
7577
2. [ROS2 Jazzy](./setup/ROS2_Jazzy.md)
7678
3. [Webots](./setup/Webots.md)
77-
4. [micro-ROS Native](./setup/microROS_Native.md)
78-
5. [micro-ROS Agent](./setup/Agent.md)
79+
4. [VSCode in WSL](./setup/vscode.md)
80+
5. [micro-ROS Native](./setup/microROS_Native.md)
81+
6. [micro-ROS Agent](./setup/Agent.md)
7982

8083
## Execution Steps
8184

doc/ROS2/setup/Agent.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
Sources: [here](https://micro-xrce-dds.docs.eprosima.com/en/latest/index.html)
44

5-
* [Micro XRCE-DDS Agent](#micro-xrce-dds-agent)
6-
* [Installation](#installation)
7-
* [Using the agent with the serial interface](#using-the-agent-with-the-serial-interface)
8-
* [Using the agent with the UDP interface](#using-the-agent-with-the-udp-interface)
9-
* [Using the agent with the TCP interface](#using-the-agent-with-the-tcp-interface)
10-
* [Troubleshooting on WSL environment](#troubleshooting-on-wsl-environment)
11-
* [Testing the node](#testing-the-node)
5+
- [Micro XRCE-DDS Agent](#micro-xrce-dds-agent)
6+
- [Installation](#installation)
7+
- [Using the agent with the serial interface](#using-the-agent-with-the-serial-interface)
8+
- [Using the agent with the TCP interface (recommended)](#using-the-agent-with-the-tcp-interface-recommended)
9+
- [Using the agent with the UDP interface](#using-the-agent-with-the-udp-interface)
10+
- [Troubleshooting on WSL environment](#troubleshooting-on-wsl-environment)
11+
- [Testing the node](#testing-the-node)
1212

1313
## Installation
1414

15-
Follow the instructions detailed [here](https://micro-xrce-dds.docs.eprosima.com/en/latest/installation.html). It has only been tested as standalone executable (without Docker neither using Snap).
15+
Follow the instructions detailed in [eProsima Micro XRCE-DDS documentation](https://micro-xrce-dds.docs.eprosima.com/en/latest/installation.html). It has only been tested as standalone executable (without Docker neither using Snap).
1616
`cmake` and `make` are required to build the Agent.
1717

1818
## Using the agent with the serial interface
@@ -38,7 +38,7 @@ Once the Agent and the Client are connected, the terminal should show something
3838
[1723186868.574254] info | ProxyClient.cpp | create_datawriter | datawriter created | client_key: 0x64C59DFF, datawriter_id: 0x000(5), publisher_id: 0x000(3)
3939
```
4040

41-
## Using the agent with the TCP interface
41+
## Using the agent with the TCP interface (recommended)
4242

4343
Start the MicroXRCEAgent binary to listen to **TCP** connections:
4444

@@ -60,7 +60,7 @@ Start the MicroXRCEAgent binary to listen to **TCP** connections:
6060
> [!WARNING]
6161
> Note: UDP ports on WSL are not working properly if you need to access them outside of the WSL VM (Status 2024-10-31). Use TCP with WSL instead.
6262
> See [https://github.com/micro-ROS/micro-ROS-Agent/issues/194](https://github.com/micro-ROS/micro-ROS-Agent/issues/194) for further details.
63-
> The mentioned ```netsh`` tool for port proxy forwarding only supports TCP.
63+
> The mentioned ```netsh``` tool for port proxy forwarding only supports TCP.
6464
6565
Start the MicroXRCEAgent binary to listen to UDP connections:
6666

@@ -87,6 +87,7 @@ Update: 2024-10-30: TCP transport is available in DroidControlShip, making UDP u
8787
In order to test your node, you can use `ros2 topic list` to list all topics used, or `ros2 topic echo <topic_name>` to listen to incoming data in a specific topic.
8888

8989
Publish some test messages (1Hz twist message):
90+
9091
```bash
9192
ros2 topic pub -r 1.0 cmd_vel geometry_msgs/msg/Twist "{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 1.8}}"
9293
```

doc/ROS2/setup/Webots.md

Lines changed: 59 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,52 @@
1-
# Installation of Webots
1+
# Installation of Webots <!-- omit in toc -->
22

3-
## Webots Setup Procedure
3+
- [Windows](#windows)
4+
- [Webots ROS2 Package (Webots on Windows)](#webots-ros2-package-webots-on-windows)
5+
- [Running Webots ROS2 Universal Robot (on Windows)](#running-webots-ros2-universal-robot-on-windows)
6+
- [Linux](#linux)
7+
- [Webots Setup Procedure](#webots-setup-procedure)
8+
- [Launching Webots](#launching-webots)
9+
- [Webots ROS2 Package (Webots in WSL)](#webots-ros2-package-webots-in-wsl)
10+
- [Running Webots ROS2 Universal Robot (on Linux)](#running-webots-ros2-universal-robot-on-linux)
11+
- [Setting up a Webots Simulation with ROS2 controller](#setting-up-a-webots-simulation-with-ros2-controller)
12+
- [Webots Supervisor](#webots-supervisor)
413

5-
Follow the official installation guide for Webots on Linux with APT on the
6-
[Webots installation Page](https://cyberbotics.com/doc/guide/installation-procedure#installing-the-debian-package-with-the-advanced-packaging-tool-apt).
14+
## Windows
15+
16+
Follow the official installation guide for Webots on Windows in the [Webots User Guide Installation Procedure](https://cyberbotics.com/doc/guide/installation-procedure#installation-on-windows).
17+
18+
ROS2 requires Linux, therefore in this setup RadonUlzer and DroidControlShip are running inside the WSL. They will connect via TCP to Webots running on the host system.
19+
20+
### Webots ROS2 Package (Webots on Windows)
21+
22+
The setup procedure is described on [this page](https://docs.ros.org/en/jazzy/Tutorials/Advanced/Simulators/Webots/Installation-Windows.html) from the Jazzy documentation. If the listed package is not found by apt, you will need to install it by building from source.
23+
24+
### Running Webots ROS2 Universal Robot (on Windows)
25+
26+
See Task 2 from this [Jazzy documentaion page](https://docs.ros.org/en/jazzy/Tutorials/Advanced/Simulators/Webots/Installation-Ubuntu.html#launch-the-webots-ros2-universal-robot-example)
27+
28+
Replace ```<DRIVE>/<WEBOTS-INSTALLATION_DIRECTORY>``` in the following terminal commands:
29+
30+
```bash
31+
export WEBOTS_HOME=/mnt/<DRIVE>/<WEBOTS-INSTALLATION_DIRECTORY>
32+
export WEBOTS_CONTROLLER_LIB_PATH=$WEBOTS_HOME/lib
33+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$WEBOTS_CONTROLLER_LIB_PATH/controller
34+
35+
cd ros2_webots_ws
36+
source install/local_setup.bash
37+
38+
ros2 launch webots_ros2_universal_robot multirobot_launch.py
39+
```
40+
41+
You should get the following simulation on the screen:
42+
43+
![Webots ROS2 Example](./img/Webots_ros2_example.png)
44+
45+
## Linux
46+
47+
### Webots Setup Procedure
48+
49+
Follow the official installation guide for Webots on Linux with APT in the [Webots User Guide Installation Procedure](https://cyberbotics.com/doc/guide/installation-procedure#installing-the-debian-package-with-the-advanced-packaging-tool-apt).
750

851
> **_NOTE:_**
952
Some of the steps result in larger package downloads.
@@ -17,7 +60,7 @@ Set environment variables for Webots home directory, the Webots controller libra
1760
source $HOME/.bashrc
1861
```
1962

20-
## Launching Webots
63+
### Launching Webots
2164

2265
Try
2366

@@ -36,31 +79,25 @@ If you get an error like "cannot open Display", try the following:
3679

3780
- try running Webots again
3881

39-
## Webots ROS2 Package
40-
41-
The setup procedure is described on [this page](https://docs.ros.org/en/jazzy/Tutorials/Advanced/Simulators/Webots/Installation-Ubuntu.html)
42-
from the Jazzy documentation. The listed package is not found by apt, so
43-
install it using building from source.
82+
### Webots ROS2 Package (Webots in WSL)
4483

45-
Note: For the time being, we need to install a patched version from https://github.com/nhjschulz/webots_ros2.git.
46-
The official one doesn't seem to support webots running inside WSL, but expects msys2/mingw.
84+
The setup procedure is described on [this page](https://docs.ros.org/en/jazzy/Tutorials/Advanced/Simulators/Webots/Installation-Ubuntu.html) from the Jazzy documentation. If the listed package is not found by apt, you will need to install it by building from source.
4785

48-
transcript:
86+
Because of [Webots Issue 6570 in webots-ros2-driver](https://github.com/cyberbotics/webots/issues/6570), running Webots inside the WSL requires a small local change. If it detects that the system is a WSL system, it will try to run ```webots.exe``` instead of ```webots```.
4987

5088
```bash
51-
mkdir -p ros2_webots_ws/src
52-
cd ros2_webots_ws
53-
git clone --recurse-submodules https://github.com/nhjschulz/webots_ros2.git src/webots_ros2
54-
55-
sudo apt install python3-pip python3-rosdep python3-colcon-common-extensions
56-
sudo rosdep init && rosdep update
57-
rosdep install --from-paths src --ignore-src --rosdistro jazzy
89+
sudo nano /opt/ros/jazzy/lib/python3.12/site-packages/webots_ros2_driver/utils.py
90+
```
5891

59-
colcon build
92+
Required change:
6093

94+
```python
95+
def is_wsl():
96+
# return 'microsoft-standard' in uname().release
97+
return False
6198
```
6299

63-
## Running Webots ROS2 Universal Robot
100+
### Running Webots ROS2 Universal Robot (on Linux)
64101

65102
See Task 2 from this [Jazzy documentaion page](https://docs.ros.org/en/jazzy/Tutorials/Advanced/Simulators/Webots/Installation-Ubuntu.html#launch-the-webots-ros2-universal-robot-example)
66103

doc/ROS2/setup/vscode.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# VSCode in WSL
2+
3+
All of the following steps are applied in the Ubuntu terminal.
4+
5+
If DroidControlShip is not cloned yet, this will be the first step:
6+
7+
```bash
8+
cd ~
9+
git clone https://github.com/BlueAndi/DroidControlShip.git
10+
```
11+
12+
In VSCode the PlatformIO extension is required. The PlatformIO extension requires Python with virtual environment capabilities.
13+
14+
```bash
15+
sudo apt install -y python3-venv
16+
```
17+
18+
Start VSCode inside the DroidControlShip folder.
19+
20+
```bash
21+
cd DroidControlShip
22+
vscode .
23+
```
24+
25+
Install now the PlatformIO extension (extension id: platformio.platformio-ide) in VSCode and wait until installation is complete.
26+
27+
After that a VSCode restart is required and VSCode is ready.
28+
29+
Install additionally the C/C++ Extension Pack (extension id: ms-vscode.cpptools-extension-pack).

doc/ROS2/setup/wsl.md

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Installation of WSL for ROS2 Jazzy
22

3-
Each ROS2 distribution targets a specific Linux environment.
4-
For Jazzy it is *Ubuntu 24.04*. To run it on Windows 10/11,
3+
Each ROS2 distribution targets a specific Linux environment.
4+
For Jazzy it is *Ubuntu 24.04*. To run it on Windows 10/11,
55
the WSL2 feature will be used.
66

7-
## Install WSL
7+
## Install WSL
88

99
Installing WSL (Linux on Windows) is officially supported by Microsoft.
1010
For details refer to the following
@@ -18,9 +18,12 @@ But all you need is this from a windows power shell:
1818
```
1919

2020
> **_NOTE:_**
21-
A Windows message dialog may popup in the background, to ask for elevated rights.
21+
A Windows message dialog may popup in the background, to ask for elevated rights.
2222
Check for such a window if the installation does not progress.
2323

24+
> **_NOTE:_**
25+
If windows requests to restart after trying to install Ubuntu, do so and try to install again.
26+
2427
## First time use
2528

2629
A console window should appear with installation messages. It will ask you
@@ -51,6 +54,8 @@ Configure Ubuntu to login by default with your user in the windows power shell:
5154

5255
Check that you have the right distribution installed (Ubuntu 24.04 LTS):
5356

57+
In the Ubuntu terminal:
58+
5459
```bash
5560
$ lsb_release -a
5661
No LSB modules are available.
@@ -62,7 +67,7 @@ Check that you have the right distribution installed (Ubuntu 24.04 LTS):
6267

6368
## New Terminal Window
6469

65-
Is is recommended to install the new Microsoft Terminal Window
70+
Is is recommended to install the new Microsoft Terminal Window
6671
if not done already. It is available from
6772

6873
[Github Microsoft Terminal](https://github.com/microsoft/terminal).
@@ -71,20 +76,31 @@ It offers tabs, history and embedds all kinds of shells (cmd, powershell, Ubuntu
7176

7277
![New Shell](./img/new_shell.png)
7378

74-
## Exposing WSL UDP Ports to the Network
79+
## Exposing WSL Ports to the Network
7580

76-
To make UDP ports listening in WSL accessible from your local network, follow these steps:
77-
Find your WSL IP address by running this command in WSL:
81+
To make TCP/UDP ports listening in WSL accessible from your local network, follow these steps:
82+
83+
Find your WSL IP address by running this command **in WSL**:
7884

7985
```bash
8086
ip addr show eth0
8187
```
8288

89+
or this **in a windows powershell**:
90+
91+
```bat
92+
wsl hostname -I
93+
```
94+
8395
> **_NOTE:_**
84-
UDP port forwarding to wsl is not supported without mirrored networking (WSL 2.0.0 on win11)
96+
TCP/UDP port forwarding to WSL is not supported without mirrored networking (WSL 2.0.0 on win11)
8597

8698
Open a terminal in an administrator shell on Windows.
87-
Run the following command to forward the UDP port, replacing [PORT] with your desired port number (usually 8888) and [WSL_IP] with the IP address:
99+
Run the following commands to forward the TCP/UDP port, replacing [PORT] with your desired port number and [WSL_IP] with the IP address.
100+
101+
| Port | Description |
102+
| ---- | ------------------ |
103+
| 8888 | ROS2 network port |
88104

89105
```bat
90106
netsh interface portproxy add v4tov4 listenport=[PORT] listenaddress=0.0.0.0 connectport=[PORT] connectaddress=[WSL_IP]

doc/ROS2/webots/webots.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,3 @@ The `ros2_dcs_turtlesim` package is availabe from it's own GIT repository at
3434

3535
Create a Webots ros2 workspace as described in [setup/Webots.md](../setup/Webots.md),
3636
then follow the instructions in `ros2_dcs_turtlesim` readme.md for building and launching.
37-
38-
## Notes
39-
40-
If the robot display shows an MCAL error, the calibration for the RadonUlzer is missing. Perform it first or manipulate the settings:
41-
42-
```bash
43-
nano .pio/build/RemoteControlSim/settings.json
44-
```
45-
46-
Set the maxSpeed value to 4200.

lib/APPTurtle/src/App.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ void App::handleTurtle()
296296
RobotSpeed payload;
297297
const int32_t MILLI_CONVERSION_FACTOR = 1000;
298298
int32_t linearSpeed = m_turtleSpeedSetpoint.linear.x * MILLI_CONVERSION_FACTOR; /* Linear speed in mm/s */
299-
int32_t angularSpeed = m_turtleSpeedSetpoint.angular.z * MILLI_CONVERSION_FACTOR; /* Angular speed in mrad/s */
299+
int32_t angularSpeed = m_turtleSpeedSetpoint.angular.z * MILLI_CONVERSION_FACTOR; /* Angular speed in mrad/s */
300300

301301
payload.linearCenter = linearSpeed;
302302
payload.angular = angularSpeed;

0 commit comments

Comments
 (0)