Skip to content

Commit 2bc396f

Browse files
authored
Merge pull request #106 from micro-ROS/feature/microros_6lowpan
Feature/microros 6lowpan
2 parents 45448af + 19e4e93 commit 2bc396f

2 files changed

Lines changed: 147 additions & 0 deletions

File tree

‎_data/docs.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
- tutorials/advanced/6lowpan_nuttx_rpi
5050
- tutorials/advanced/tracing
5151
- tutorials/advanced/microros_nuttx_bsp
52+
- tutorials/advanced/microros_6lowpan_tutorial
5253

5354
- title: Demos
5455
docs:
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
---
2+
title: Micro-ROS 6LoWPAN Guide
3+
permalink: /docs/tutorials/advanced/microros_6lowpan_tutorial/
4+
---
5+
6+
In this guide, we will show how to use Micro-ROS over 6LoWPAN communication.
7+
8+
# What is 6LoWPAN?
9+
10+
6LoWPAN is an acronym of IPv6 over Low-Power Wireless Personal Area Networks. This communication protocol allows wireless communication over IEEE 802.15.4 based networks using IPv6. Some of the main advantages are:
11+
- Easy to route from radio devices to the Internet, thanks to the usage of the IP packets.
12+
- Easy to use on UDP and TCP server/clients.
13+
- A protocol designed for low power and constrained devices. Perfect for Micro-ROS remote sensors.
14+
15+
# Needed devices
16+
17+
At this moment this communication protocol is only available for NuttX RTOS. You need the following devices to implement the steps highlighted in this guide:
18+
19+
- Olimex-STM32-E407 board. [Link](https://www.olimex.com/Products/ARM/ST/STM32-E407/open-source-hardware)
20+
- PmodRF2 Radio. [Link](https://store.digilentinc.com/pmod-rf2-ieee-802-15-rf-transceiver/)
21+
- Micro-ROS hardware bridge.
22+
23+
**Important!**
24+
You can find a guide on how to set-up the Micro-ROS hardware bridge at the following link: [uROS hardware bridge guide](https://github.com/micro-ROS/micro-ROS-bridge_RPI/blob/new_bridge_tools/Readme.md).
25+
In the micro-ROS hardware bridge guide, you can find everything that you need to set-up this device base.
26+
27+
# Configure the 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
32+
First we're going to connect the PmodRF2 radio. To do so, follow the wiring table below:
33+
34+
- `Board D13` -> `MRF24J40 SCLK`
35+
- `Board D12` -> `MRF24J40 MISO`
36+
- `Board D11` -> `MRF24J40 MOSI`
37+
- `Board D10` -> `MRF24J40 CS`
38+
- `Board D8` -> `MRF24J40 INT`
39+
40+
The ``D`` letter refers to the Arduino header pins of the board.
41+
To ease the set-up process, you can find the pinout of the radio at the following link: [PmodRF2 pinout](https://reference.digilentinc.com/reference/pmod/pmodrf2/start)
42+
43+
The last step is to connect a mini-USB cable to the OTG2 USB port (The USB port next to the Ethernet port).
44+
45+
## Set-up the software
46+
47+
To create and flash the firmware, we're going to use the micro-ROS build system.
48+
49+
You can find the instructions at the following link: [Micro-ROS build system](https://github.com/micro-ROS/micro-ros-build/blob/dashing/micro_ros_setup/README.md).
50+
For this particular guide, it is necessary to use the branch ``dashing`` and the configuration profile ``uros_6lowpan``.
51+
52+
### Temporary solution
53+
54+
Due to the build system is work in progress, you need to do the next modifications, but is just temporary:
55+
56+
- Open ``uros_ws/firmware/mcu_ws/uros/rmw_microxrcedds/rmw_microxrcedds_c/CMakeLists.txt`` and on the line 42 change value of ``RMW_UXRCE_STREAM_HISTORY`` from 4 to 55.
57+
- 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 40.
58+
59+
This set the appropiate MTU and history for 6LoWPAN communications on NuttX.
60+
61+
Once you follow all the instructions in the build system and flash the board, everything is ready.
62+
63+
# How to use it?
64+
65+
- Turn on the Olimex-STM32-E407 board and open the NSH console on a terminal.
66+
- Check if all the applications are ready by typing ``?`` on the console. It should return the following:
67+
68+
```bash
69+
help usage: help [-v] [<cmd>]
70+
71+
[ cd df help ls mw set true
72+
? cp echo hexdump mb ps sh uname
73+
addroute cmp exec ifconfig mkdir pwd sleep umount
74+
basename dirname exit ifdown mh rm test unset
75+
break dd false ifup mount rmdir telnetd usleep
76+
cat delroute free kill mv route time xd
77+
78+
Builtin Apps:
79+
ping6 i8sak uros_6lowpan
80+
```
81+
- Now turn-on the Raspberry Pi and execute the micro-ROS hardware bridge tool, by typing the next command:
82+
83+
```bash
84+
./ ~/micro-ROS-HB.sh
85+
```
86+
- Once everything is configured, it will return the connection data of the 6LowPAN network:
87+
88+
```bash
89+
lowpan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1280
90+
inet6 fe80::b482:ca65:743b:b6bd prefixlen 64 scopeid 0x20<link>
91+
unspec B6-82-CA-65-74-3B-B6-BD-00-00-00-00-00-00-00-00 txqueuelen 1000 (UNSPEC)
92+
RX packets 0 bytes 0 (0.0 B)
93+
RX errors 0 dropped 0 overruns 0 frame 0
94+
TX packets 21 bytes 2242 (2.1 KiB)
95+
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
96+
97+
1) Add new 6LoWPAN micro-ROS device 3) Create UDP micro-ROS Agent 5) Create Serial micro-ROS Agent server
98+
2) Create UDP 6LoWPAN micro-ROS Agent 4) Create TCP micro-ROS Agent 6) Quit
99+
#?
100+
```
101+
- The value **inet6** is the IPV6 direction of the Raspberry Pi over the 6LoWPAN interface. Copy it, because is necessary for the subsequent steps.
102+
103+
- Go to the Olimex-STM32-E407 board and execute the micro-ROS 6lowpan application, by typing the next command:
104+
```bash
105+
uros_6lowpan <Agent_IP> <Agent_Port> <pub/sub>```
106+
- Agent_IP: In this field, you should write the IP of the Agent for this specific example (it is the IP that you should have copied in the previous step).
107+
- Agent_PORT: In this field, you should write the port that you want to open for micro-ROS communications.
108+
- pub/sub: If you write **pub**, it will create a micro-ROS publisher, which will publish an integer numbers up to one thousand. Otherwise, if you write **sub** it will create a subscriber that will be subscribe to the ``std_msgs_msg_Int32`` topic.
109+
110+
- Once you execute the app, it will ask you if you want to configure the 6LoWPAN network. (Necessary to configure each time you reboot the board)
111+
- This will return connection data, you should save the ``inet_6_addr`` and ``HWaddr``.
112+
- Note: If you want to change the ID of the radio, you can do it on the menuconfig of NuttX on the example configuration.
113+
114+
```bash
115+
nsh> uros_6lowpan fe80::bc81:c3b9:5c14:1ab 8888 pub
116+
Do you want to configure the 6lowpan network? (Y/N)
117+
ifdown wpan0...OK
118+
i8sak: resetting MAC layer
119+
i8sak: starting PAN
120+
Introduce your 6LowPan ID (It must between 00 and FF (Hex))
121+
i8sak: accepting all assoc requests
122+
i8sak: daemon started
123+
ifup wpan0...OK
124+
Connection data
125+
wpan0 Link encap:6LoWPAN HWaddr 00:be:ad:de:00:de:fa:00 at UP
126+
inet6 addr: fe80::2be:adde:de:fa00/64
127+
inet6 DRaddr: ::/64
128+
129+
RX: Received Fragment Errors
130+
00000000 00000000 00000000
131+
IPv6 Dropped
132+
00000000 00000000
133+
TX: Queued Sent Errors Timeouts
134+
00000000 00000000 00000000 00000000
135+
Total Errors: 00000000
136+
```
137+
- After this step, the application on the Olimex board will be blocked waiting for a user input confirming that the Agent on the hardware bridge is ready to receive data.
138+
139+
- Go back to the hardware bridge, now we're going to add a new 6LoWPAN device. Push ``1 + enter``. (Note: This step is only necessary if you're attaching for the first time a new device)
140+
- First, introduce the IPV6 of the Olimex board (inet6_addr)
141+
- Introduce the hardware address of the Olimex board (Hwaddr).
142+
- Now the device is registered and ready to establish communication.
143+
- The final step on the hardware bridge is to execute the micro-ROS Agent, to do so, push ``2 + enter`` and introduce the port to use.
144+
145+
- Finally, on the Olimex board, push ``y`` to confirm that everything is ready and it will start the micro-ROS application.
146+

0 commit comments

Comments
 (0)