Skip to content

Commit fcd64e6

Browse files
committed
tutorial: nuttx: update micro-ROS over 6lowpan
1 parent 679c858 commit fcd64e6

1 file changed

Lines changed: 101 additions & 74 deletions

File tree

  • _docs/tutorials/advanced/nuttx/6lowpan
Lines changed: 101 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,116 @@
11
---
2-
title: 6LoWPAN Guide
2+
title: Micro-ROS 6LoWPAN guide
33
permalink: /docs/tutorials/advanced/nuttx/6lowpan/
44
---
5-
6-
In this guide, we will show how to use micro-ROS over 6LoWPAN communication.
5+
This guide will describe how to use Micro-ROS over 6LoWPAN communication.
76

87
# What is 6LoWPAN?
98

10-
6LoWPAN is an acronym o IPv6 over Low-Power Wireless Personal Area Networks.
11-
This communication protocol allows wireless communication over IEEE 802.15.4 based networks using IPv6. Some of the main advantages are:
9+
6LoWPAN is an acronym of IPv6 over Low-Power Wireless Personal Area Networks.
10+
This communication protocol allows wireless communication over IEEE 802.15.4 based networks using IPv6.
11+
Some of the main advantages are:
12+
1213
- Easy to route from radio devices to the Internet, thanks to the usage of the IP packets.
1314
- Easy to use on UDP and TCP server/clients.
14-
- A protocol designed for low power and constrained devices, perfect or micro-ROS remote sensors.
15+
- A protocol designed for low power and constrained devices. Perfect for Micro-ROS remote sensors.
16+
17+
# Needed devices
18+
19+
At this moment this communication protocol is only available for NuttX RTOS.
20+
Below the list of what is needed to continue:
21+
22+
- Olimex-STM32-E407 board. [Link](https://www.olimex.com/Products/ARM/ST/STM32-E407/open-source-hardware)
23+
- PmodRF2 Radio. [Link](https://store.digilentinc.com/pmod-rf2-ieee-802-15-rf-transceiver/)
24+
- A Linux Ubuntu 18.04 machine with docker installed.
25+
- A 802.15.4 Radio USB dongle [Link](http://shop.sysmocom.de/products/atusb) plugged into the Linux machine.
26+
27+
# Configure the Olimex board
28+
29+
The configuration of the board is divided into two parts: the set-up of the hardware and the set-up of the software.
30+
31+
## Set-up the hardware
1532

16-
# Needed hardware
33+
First the PmodRF2 need to be connected to the Olimex board as desribed below:
1734

18-
At present, 6LoWPAN is only available for the NuttX RTOS.
19-
In order to implement the steps highlighted in this guide, you need the following devices:
35+
- `Board D13` -> `MRF24J40 SCLK`
36+
- `Board D12` -> `MRF24J40 MISO`
37+
- `Board D11` -> `MRF24J40 MOSI`
38+
- `Board D10` -> `MRF24J40 CS`,
39+
- `Board D8` -> `MRF24J40 INT`.
2040

21-
- Raspberry Pi.
22-
- [Olimex-STM32-E407 board](https://www.olimex.com/Products/ARM/ST/STM32-E407/open-source-hardware).
23-
- [PmodRF2 Radio](https://store.digilentinc.com/pmod-rf2-ieee-802-15-rf-transceiver/).
24-
- micro-ROS-bridge-RPI.
41+
The ``D`` letter refers to the Arduino header pins of the board denoted ``CON4``.
42+
To ease the set-up process, The radio's pinout can be found at the following link: [PmodRF2 pinout](https://reference.digilentinc.com/reference/pmod/pmodrf2/start)
2543

26-
**Important!**
27-
You can find a guide of how to setup the micro-ROS-bridge_RPI at its [repository](https://github.com/micro-ROS/micro-ROS-bridge_RPI/blob/new_bridge_tools/Readme.md).
28-
In the micro-ROS-bridge-RPI guide, you can find everything that you need to set-up this device base.
44+
The last step is to connect a mini-USB cable to the OTG2 USB port (The USB port next to the Ethernet port).
2945

30-
# Configure the board
46+
## Set-up the software
47+
48+
The micro-ROS build system will be use in order to create and flash the
49+
firmware.
50+
51+
Instructions are available at the following link: [Micro-ROS build system](https://github.com/micro-ROS/micro-ros-build/blob/dashing/micro_ros_setup/README.md).
52+
For this particular guide, it is necessary to use the branch ``dashing`` and the configuration profile ``uros_6lowpan``.
53+
54+
### Manual patches
55+
56+
Due to the build system being a work in progress, some of files have to be
57+
modified.
58+
59+
- Open ``uros_ws/firmware/mcu_ws/eProsima/Micro-XRCE-DDS-Client/client.config`` and modify the value of ``CONFIG_UDP_TRANSPORT_MTU`` from ``512`` to ``450``.
60+
61+
This is an appropiate MTU for 6LoWPAN communications on NuttX.
62+
Also the micro-XRCE-DDS needs to be to be change to the version 1.2.5 in the docker:
63+
64+
```bash
65+
cd /uros_ws/firmware/mcu_ws/eProsima/Micro-XRCE-DDS-Client
66+
git checkout v1.2.5
67+
```
3168

32-
The configuration of the board is divided into two parts: hardware and software set-up.
69+
Once the modifications done, the binary can be compiled [as explained here](git checkout v1.2.5)
3370

34-
## Hardware set-up
71+
# Configure the Linux machine
3572

36-
First we are going to connect the PmodRF2 radio.
73+
The Linux machine is where is going to run the agent.
74+
In order to setup the wireless, some settings have to be set as follow:
3775

38-
| | RPi | Olimex | PmodRF2 |
39-
| ----- | --- | ------ | ------- |
40-
| VIN | 1 | D13 | 12 |
41-
| GND | 20 | GND | 11 |
42-
| RESET | 17 | - | 8 |
43-
| INT | 16 | D8 | 7 |
44-
| SDI | 19 | D12 | 2 |
45-
| SDO | 21 | D11 | 3 |
46-
| SCK | 23 | D13 | 4 |
47-
| CS | 26 | D10 | 1 |
76+
```bash
77+
#Setting up the 6lowpan network
78+
sudo apt update && sudo apt install iwpan # install the iwpan tool
79+
sudo ip link set wpan0 down
80+
sudo ip link set lowpan0 down
81+
sudo iwpan dev wpan0 set pan_id 0xabcd
82+
sudo iwpan phy phy0 set channel 0 26 # phy can be phy0 or any other phyN where N [0,1,2,3,4,5,6,7,8,9,10,...]
83+
sudo ip link add link wpan0 name lowpan0 type lowpan
84+
sudo ip link set wpan0 up
85+
sudo ip link set lowpan0 up
86+
sudo ip link set docker0 down # Necessary to not reroute everything over the docker and use the lowpan0
87+
sudo ip neigh flush all
88+
sudo ip neigh add to {**IPV6 of the microROS node**} dev lowpan0 lladdr {**HW 802.15.4 of the micro-controller**} # repeat it for all the device
89+
```
4890

49-
To ease the set-up process, you can use the [RPi pinout](https://pinout.xyz/#) and [PmodRF2 pinout](https://reference.digilentinc.com/reference/pmod/pmodrf2/start).
91+
It appears that depending on the PC configuration, the packets will not be able to be routed correctly from the docker to the lowpan0/wpan0 and vice-versa.
92+
In order to forward the packet to the correct interface the following commands need to be entered:
5093

51-
The last step is to connect a mini-USB cable to the OTG2 USB port (this USB port next to the Ethernet port).
94+
```bash
95+
#Setting up the 6lowpan routing
96+
sudo ip -6 route add {**IPV6 of the microROS node**} dev lowpan0 proto kernel metric 50 pref medium
97+
```
5298

53-
## Software set-up
99+
Once hte setup done, the docker may be run:
100+
```bash
101+
docker run -it --network host microros/micro-ros-agent:dashing udp6 --port 9999 -v6
54102

55-
To create and flash the firmware, we are going to use the micro-ROS build system.
56-
You can find the instructions at the micro-ros-build's [README](https://github.com/micro-ROS/micro-ros-build/blob/dashing/micro_ros_setup/README.md).
57-
For this particular guide, it is necessary to use the branch `dashing` and the configuration profile `uros_6lowpan`.
103+
[1599566641.351706] info | UDPv6AgentLinux.cpp | init | running... | port: 9999
104+
[1599566641.351889] info | Root.cpp | set_verbose_level | logger setup | verbose_level: 6
58105

59-
Once you follow all the instructions in the build system and flash the board, everything is ready.
106+
```
60107

61108
# How to use it?
62109

63-
- Turn on the Olimex board and open the NSH console on a terminal.
64-
- Check if all the applications are ready by typing `?` on the console. It should return the following:
110+
- Olimex-STM32-E407 board must be switched on and a connection to the NSH
111+
console established,
112+
- By typing ``?`` in the console prompt, ``Builtin Apps``` show be displayed as
113+
explained below:
65114

66115
```bash
67116
help usage: help [-v] [<cmd>]
@@ -75,41 +124,15 @@ help usage: help [-v] [<cmd>]
75124

76125
Builtin Apps:
77126
ping6 i8sak uros_6lowpan
78-
```
79-
- Now turn-on the RPi and execute the micro-ROS-bridge-RPI tool by typing the next command:
80127

81-
```bash
82-
./ ~/micro-ROS-HB.sh
83128
```
84-
- Once everything is configured, it will return the connection data of the 6LoWPAN network:
129+
- Then the publisher can executed as follow. Note that the ipv6 address (fe80::bc81:c3b9:5c14:1ab) is the
130+
ipv6 address of the Linux lowpan0 interface.
85131
86-
```bash
87-
lowpan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1280
88-
inet6 fe80::b482:ca65:743b:b6bd prefixlen 64 scopeid 0x20<link>
89-
unspec B6-82-CA-65-74-3B-B6-BD-00-00-00-00-00-00-00-00 txqueuelen 1000 (UNSPEC)
90-
RX packets 0 bytes 0 (0.0 B)
91-
RX errors 0 dropped 0 overruns 0 frame 0
92-
TX packets 21 bytes 2242 (2.1 KiB)
93-
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
94-
95-
1) Add new 6LoWPAN micro-ROS device 3) Create UDP micro-ROS Agent 5) Create Serial micro-ROS Agent server
96-
2) Create UDP 6LoWPAN micro-ROS Agent 4) Create TCP micro-ROS Agent 6) Quit
97-
#?
98-
```
99-
- The value **inet6** is the IPv6 direction of the RPi over the 6LoWPAN interface. Copy it because is necessary for the subsequent steps.
100-
- Execute the micro-ROS 6LoWPAN application on the Olimex typing the next command:
101132
102133
```bash
103-
uros_6lowpan <Agent_IP> <Agent_Port> <pub/sub>
104-
```
105-
where `Agent_IP` is the IPv6 copied previously, `Agent_PORT` is the port selected for the Agent and `pub/sub` controls the application behavior: in case of `pub` it will act as publisher and as in case of `sub`, it will act as a subscriber.
106134

107-
- Once you execute the app, ti will ask you if you want to configure the 6LoWPAN network.
108-
- This will return connection data, you should save the `inet_6_addr` and `HWaddr`.
109-
- Note: if you want to change the ID of the radio, you can do it on the `menuconfig` of NuttX on the example configuration.
110-
111-
```bash
112-
nsh> uros_6lowpan fe80::bc81:c3b9:5c14:1ab 8888 pub
135+
nsh> uros_6lowpan fe80::bc81:c3b9:5c14:1ab 9999 pub
113136
Do you want to configure the 6lowpan network? (Y/N)
114137
ifdown wpan0...OK
115138
i8sak: resetting MAC layer
@@ -131,11 +154,15 @@ wpan0 Link encap:6LoWPAN HWaddr 00:be:ad:de:00:de:fa:00 at UP
131154
00000000 00000000 00000000 00000000
132155
Total Errors: 00000000
133156
```
157+
- After this step, the application on the Olimex board will be blocked waiting
158+
for a user to press any key and enter. The following output should appear.
134159
135-
- After this step, the application on the Olimex board will be blocked waiting for a user input confirming that the Agent on the bridge is ready to receive data.
160+
```bash
161+
Sent: '0'
162+
Sent: '1'
163+
Sent: '2'
164+
...
165+
```
136166
137-
- Go back to the bridge, now we are going to add a new 6LoWPAN device. Push `1 + enter`. (Note: this step is only necessary if you are attaching for the first time a new device).
138-
- First, introduce the IPv6 of the Olimex board (`inet6_addr`).
139-
- Introduce the hardware address of the Olimex board (HWaddr).
140-
- Now the device is registered and ready to establish communication.
141-
- The final step on the bridge is to execute the micro-ROS-Agent, to do so, push `2 + enter` and introduce the port to use.
167+
- The same procedure needs to be followed to run the subscriber but the last
168+
parameter of the ``uros_6lowpan`` command should be ``sub``.

0 commit comments

Comments
 (0)