Skip to content

Commit

Permalink
Updated documentation with setup and build instructions for native an…
Browse files Browse the repository at this point in the history
…d target build after integration of uROS as library.
  • Loading branch information
hoeftjch committed Aug 30, 2024
1 parent 2280c5a commit ffbe2cb
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 11 deletions.
3 changes: 2 additions & 1 deletion doc/ROS2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@ The Webots integration is discussed on the [Webots subpage](./webots/webots.md).
* [ROS2 Jazzy](./setup/ROS2_Jazzy.md)
* [Webots](./setup/Webots.md)
* [Target](./setup/Target.md)
* [micro-ROS Native](./setup/microROS_Native.md)
* [micro-ROS Native](./setup/microROS_Native.md)
* [micro-ROS Agent](./setup/Agent.md)
22 changes: 21 additions & 1 deletion doc/ROS2/setup/Agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,28 @@ Once the Agent and the Client are connected, the terminal should show something

## Using the agent with the wifi interface

The `wifi` transport layer has not been tested yet.
Start the MicroXRCEAgent binary to listene to UDP connections
```bash
./MicroXRCEAgent udp4 -p 1883 -v 6
[1724834512.980210] info | UDPv4AgentLinux.cpp | init | running... | port: 1883
[1724834512.981013] info | Root.cpp | set_verbose_level | logger setup | verbose_level: 6
[1724834515.742593] debug | UDPv4AgentLinux.cpp | recv_message | [==>> UDP <<==] | client_key: 0x00000000, len: 24, data:
0000: 80 00 00 00 00 01 10 00 58 52 43 45 01 00 01 0F 61 53 75 C7 81 00 FC 01
[1724834515.742856] info | Root.cpp | create_client | create | client_key: 0x615375C7, session_id: 0x81
[1724834515.744803] info | SessionManager.hpp | establish_session | session established | client_key: 0x615375C7, address: 127.0.0.1:9903
[1724834515.744916] debug | UDPv4AgentLinux.cpp | send_message | [** <<UDP>> **] | client_key: 0x615375C7, len: 19, data:
0000: 81 00 00 00 04 01 0B 00 00 00 58 52 43 45 01 00 01 0F 00
```

## Troubleshooting on WSL environment

UDP connections [setup wsl](./wsl.md#exposing-wsl-udp-ports-to-the-network) (Requires Win 11).

## Testing the node

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.

Publish some test messages (1Hz twist message):
```bash
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}}"
```
17 changes: 14 additions & 3 deletions doc/ROS2/setup/Target.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,33 @@ How setup and use micro-ROS DCS target `TurtleTarget`

## Build TurtleTarget
Perform standard pio build of the TurtleTarget application. It will pull the [micro_ros_platformio](https://github.com/gabryelreyes/micro_ros_platformio) as library dependency and build scripts.
During the build process the micro_ros_platoformio will build uROS as static library which will be placed in the libdeps directory `.pio/libdeps/TurtleTarget/micro_ros_platformio/libmicroros`.

Create symbolic link to static library. Previous links will be overwritten using the `-f` option (ensure that the relative path is correct from the perspective of the link's location):
```bash
ln -sf ../.pio/libdeps/TurtleTarget/micro_ros_platformio/libmicroros ./lib/libmicroros
```

Verify the target architecture of libmicroros.a is for the ESP32. Command and expected output:
```bash
ar p lib/libmicroros/libmicroros.a | file -
/dev/stdin: ELF 32-bit LSB relocatable, Tensilica Xtensa, version 1 (SYSV), with debug_info, not stripped
```

## Bind USB port with WSL
Make the usb serial port visible to wsl in order to flash the binary using [usbipd](https://learn.microsoft.com/en-us/windows/wsl/connect-usb).

Run the following in an administrator shell:
```
```bat
usbipd bind --busid <busid>
```

Check available usb devices and sharing status.
```
```bat
usbipd list
```
![usbipd list](img/wsl_bind_usb.png)


Attach USB bus to wsl shell (no admin rights needed for attaching a shared port)
```
usbipd attach --wsl --busid <busid>
Expand Down
13 changes: 9 additions & 4 deletions doc/ROS2/setup/microROS_Native.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Static micro-ROS library

## Create a workspace for the library

See https://micro.ros.org/docs/tutorials/core/first_application_linux/

Create a workspace and get the micro-ROS tools:
Expand Down Expand Up @@ -30,7 +31,6 @@ source install/local_setup.bash

## Create static micro-ROS library


See https://micro.ros.org/docs/tutorials/advanced/create_custom_static_library/

Prepare the micro-ROS environment:
Expand All @@ -46,11 +46,16 @@ Now the library can be build by executing
ros2 run micro_ros_setup build_firmware.sh $(pwd)/my_custom_toolchain.cmake $(pwd)/my_custom_colcon.meta
```



## Include static micro-ROS library

Create a symbolic link to the library in the the lib folder of the workspace the library should be included
```
ln -s ~/microros_ws/firmware/build libmicroros
```
```

## Verify binary type of static library
To check the binary type of the static library use this command and see expected output:
```bash
ar p lib/libmicroros/libmicroros.a | file -
/dev/stdin: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), with debug_info, not stripped
```
27 changes: 25 additions & 2 deletions doc/ROS2/setup/wsl.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ require updates to install for WSL. Then start an Ubuntu console from start menu
![Ubuntu Start Menu](./img/ubuntu_start_menu.png)

## Checking Installation

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

```bash
Expand All @@ -45,7 +44,6 @@ Check that you have the right distribution installed (Ubuntu 24.04 LTS):
```

## New Terminal Window

Is is recommended to install the new Microsoft Terminal Window
if not done already. It is available from

Expand All @@ -54,3 +52,28 @@ if not done already. It is available from
It offers tabs, history and embedds all kinds of shells (cmd, powershell, Ubuntu, git ...)

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


## Exposing WSL UDP Ports to the Network
To make UDP ports listening in WSL accessible from your local network, follow these steps:
Find your WSL IP address by running this command in WSL:
```bash
ip addr show eth0
```
> **_NOTE:_**
UDP port forwarding to wsl is not supported without mirrored networking (WSL 2.0.0 on win11)

Open a terminal in an administrator shell on Windows.
Run the following command to forward the UDP port, replacing [PORT] with your desired port number and [WSL_IP] with the IP address:
```bat
netsh interface portproxy add v4tov4 listenport=[PORT] listenaddress=0.0.0.0 connectport=[PORT] connectaddress=[WSL_IP]
```

To view all forwarded ports:
```bat
netsh interface portproxy show all
```
To remove a port forward:
```bat
netsh interface portproxy delete v4tov4 listenport=[PORT] listenaddress=0.0.0.0
```

0 comments on commit ffbe2cb

Please sign in to comment.