Skip to content

Commit c415677

Browse files
author
julibert
committed
Link demo tutorial to repositories READMEs.
1 parent 4d7eda5 commit c415677

7 files changed

Lines changed: 16 additions & 297 deletions

File tree

.gitmodules

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[submodule "_includes/crazyflie_demo"]
2+
path = _includes/crazyflie_demo
3+
url = https://github.com/micro-ROS/micro-ROS_crazyflie_demo
4+
branch = master
5+
[submodule "_includes/sensors_demo"]
6+
path = _includes/sensors_demo
7+
url = https://github.com/micro-ROS/micro-ROS_sensors_demo
8+
branch = master

_data/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
- title: Demos
4949
docs:
5050
- tutorials/demos/kobuki_demo
51+
- tutorials/demos/crazyflie_demo
5152
- tutorials/demos/tof_demo
5253
- tutorials/demos/fiware_demo
53-
- tutorials/demos/crazyflie_demo
5454
- tutorials/demos/complete_demo
5555

5656
- title: Advanced Tutorials with Nuttx

_docs/tutorials/demos/crazyflie_demo/index.md

Lines changed: 2 additions & 295 deletions
Original file line numberDiff line numberDiff line change
@@ -5,298 +5,5 @@ redirect_from:
55
- /crazyflie_demo/
66
---
77

8-
This demo aims to expose a **micro-ROS** use case. It runs on a pair of embedded devices:
9-
a [**Crazyflie 2.1**](https://www.bitcraze.io/crazyflie-2-1/) drone, used as a user controller,
10-
and a [**Kobuki Turtlebot 2**](https://www.turtlebot.com/turtlebot2/) as a mobile and controlled device.
11-
12-
![Illustration of the Crazyflie - DDS interaction](micro-ROS_crazyflie.png)
13-
14-
Both of them rely on **micro-ROS** publication and subscription mechanisms and use an underlying [**Micro XRCE-DSS client**](https://micro-xrce-dds.readthedocs.io/en/latest/).
15-
16-
This demo also includes conventional ROS 2 tooling as a demonstration of integration with **ROS 2**. We use Gazebo, RVIZ and simple ROS 2 nodes (aka **external nodes**) acting as data converters.
17-
18-
This demo was developed taking as base the [Kobuki demo](/docs/tutorials/demos/kobuki_demo).
19-
20-
## Index
21-
- [Installation](#installation)
22-
- [Install external ROS 2 nodes](#install-external-ros-2-nodes)
23-
- [Build and flash Crazyflie 2.1 firmware](#build-and-flash-crazyflie-21-firmware)
24-
- [Install Crazyflie Client + Bridge](#install-crazyflie-client--bridge)
25-
- [Build and flash Kobuki Turtlebot 2 firmware](#build-and-flash-kobuki-turtlebot-2-firmware)
26-
- [Usage](#usage)
27-
- [Run Kobuki Turtlebot 2 Node](#run-kobuki-turtlebot-2-node)
28-
- [Run Crazyflie 2.1 Node](#run-crazyflie-21-node)
29-
- [Run external ROS 2 nodes](#run-external-ros-2-nodes)
30-
- [Run RVIZ visualizers](#run-rviz-visualizers)
31-
32-
## Setup
33-
34-
The proposed demo is composed of different kind of messages and topics.
35-
36-
The **Crazyflie 2.1** drone relies on [ST STM32F405](https://www.st.com/en/microcontrollers-microprocessors/stm32f405-415.html) MCU running **[FreeRTOS](https://www.freertos.org/)**. Using the RTOS capabilities and the integrated radio communication device, the drone can run a node that publishes:
37-
- its own relative position as a 3D vector (X, Y and Z) using a *geometry_msg/Point32* message type on */drone/odometry* topic.
38-
- its own attitude as a 3D vector (pitch, roll and yaw) using a *geometry_msg/Point32* message type on */drone/attitude* topic.
39-
40-
The **Kobuki Turtlebot 2** robot is controlled using a UART protocol through a custom DB25 connector. The micro-ROS node runs on an Olimex STM32-E407 board attached to that UART port. This hardware features a [ST STM32F407](https://www.st.com/en/microcontrollers-microprocessors/stm32f407-417.html) MCU running **[Nuttx](https://nuttx.org/)** RTOS. In the same way, this node can communicate with the robot (UART) and with the ROS2 world (integrated Ethernet). Its used topics are:
41-
- a subscription on */cmd_vel* topic (*geometry_msg/Twist* message type) to receive the controlling angular and linear velocity.
42-
- a publication on */robot_pose* topic (*geometry_msg/Vector3* message type) which includes X position, Y position and robot yaw.
43-
44-
The **external ROS 2 nodes** are rclpy tools with some different functionalities:
45-
- *attitude_to_vel.py*
46-
- Converts Crazyflie */drone/attitude* to Kobuki Turtlebot 2 */cmd_vel* so that drone pitch is mapped to robot linear velocity and drone roll to angular valocity.
47-
- Converts Crazyflie publications on */drone/attitude* and */drone/attitude* topics to *tf2_msgs/TFMessage* messages (required by RVIZ visualizer)
48-
- *odom_to_tf.py*
49-
- Converts Kobuki Turtlebot 2 publications on */robot_pose* topic to *tf2_msgs/TFMessage* messages (required by RVIZ visualizer).
50-
51-
The following image shows the described setup.
52-
53-
![Kobuki_drone_demo](http://www.plantuml.com/plantuml/png/XLDHJzim47xlhp3P2wlMP0FniWS40uhGDeegreUXANAJQx18V95zBcBJ_llYIpChfDdwuChVz_axt-VBcILfo5Nbv227ZT8WRYuMjz-MNyGZKMq_9ecHpt6XwD6jdGMJeIRG56TO9UHgcPlZf2wbzXOprR2pJQEOsTee0fjiZ-8FyVl9WT9PwN9mfkpyayQXGXtNN7iFppxo6InMC3j93AwHnjK5Rdrrc-G6DRGw-wHqBOsin5fcJuL1f_CBBD68D_FvV38HpKzf0hEH6OYeFTeMIckq81xkiE6FZtw8wVJAbM34kIvAiDDf9AGL30rSiYfFjr2AXmAm0Z8lQMKBcpHBSl-iB7cp5PIOANhP6J4-C0eNsUUrWepG77ktHSvavzPjH_h37TthxWwj8eLwPz5jsQ8DwdgnIY-NYzkhmqjlyqv4_1-zPVO2gxhPQHAII97B8INqCSJro-IL8hgMFs6DuZEktPEAX2_OGcaB2JumFpz9bujFY_l35cqgxawq9Nana97qRoAYhR9EbifAV_58_6B-TGIq4G_tywzWhInWJ-D_kS7f460jwR49hrdPmC1MeGkPTTFX1UpIxzx7xxEXZOzco4VBrSrtmTcAyrsMxEVnbF5K_kTSTvNNv-hHSssoGT_kMVuxfDswpsQdOVG35eQ6SLQ8E3xTCn4iwEJ_qWnXhXI-bp51UCPHKNWWNjYJxn9w3s1_GBd3FiIElIzl7yv4jsFV_ZWm7w11Eom8MtRelzUG3LCpIeVXu526p1det5Nb7m00)
54-
55-
## Required Hardware
56-
57-
This setup uses the following hardware:
58-
59-
| Item | |
60-
|---------------|----------------------------------------------------------|
61-
| Kobuki Turtlebot 2 | [Link](https://www.turtlebot.com/turtlebot2/) |
62-
| Olimex STM32-E407 | [Link](https://www.olimex.com/Products/ARM/ST/STM32-E407/open-source-hardware) |
63-
| Olimex ARM-USB-TINY-H | [Link](https://www.olimex.com/Products/ARM/JTAG/ARM-USB-TINY-H/) |
64-
| Crazyflie 2.1 | [Link](https://store.bitcraze.io/products/crazyflie-2-1) |
65-
| Flow Desk v2 | [Link](https://store.bitcraze.io/collections/decks/products/flow-deck-v2) |
66-
| Debug adapter | [Link](https://store.bitcraze.io/collections/accessories/products/debug-adapter) |
67-
| Crazyradio PA 2.4 GHz USB dongle | [Link](https://store.bitcraze.io/collections/accessories/products/crazyradio-pa) |
68-
| Additional battery + charger (optional) | [Link](https://store.bitcraze.io/collections/accessories/products/240mah-lipo-battery-including-500ma-usb-charger) |
69-
70-
71-
# Installation
72-
73-
## Install external ROS 2 nodes
74-
75-
[Install Micro XCRE-DDS](https://micro-xrce-dds.readthedocs.io/en/latest/installation.html). Recommended procedure:
76-
77-
```bash
78-
git clone https://github.com/eProsima/Micro-XRCE-DDS.git -b v1.1.0
79-
cd Micro-XRCE-DDS
80-
mkdir build && cd build
81-
cmake ..
82-
make
83-
sudo make install
84-
```
85-
86-
Create a workspace folder for this demo:
87-
```bash
88-
mkdir -p crazyflie_demo/src
89-
cd crazyflie_demo
90-
```
91-
92-
Clone this repo:
93-
```bash
94-
git clone --single-branch --branch crazyflie_demo https://github.com/micro-ROS/micro-ROS_kobuki_demo src
95-
```
96-
97-
[Install Gazebo](http://gazebosim.org/tutorials?tut=install_ubuntu&cat=install#InstallGazebousingUbuntupackages). Recommended procedure:
98-
```bash
99-
curl -sSL http://get.gazebosim.org | sh
100-
```
101-
102-
[Install gazebo_ros_pkgs (ROS 2)](http://gazebosim.org/tutorials?tut=ros2_installing&cat=connect_ros). Recommended procedure:
103-
```bash
104-
source /opt/ros/dashing/setup.bash
105-
wget https://bitbucket.org/api/2.0/snippets/chapulina/geRKyA/f02dcd15c2c3b83b2d6aac00afe281162800da74/files/ros2.yaml
106-
vcs import src < ros2.yaml
107-
rosdep update && rosdep install --from-paths src --ignore-src -r -y
108-
rm ros2.yaml
109-
```
110-
111-
Build the project:
112-
```bash
113-
source /opt/ros/dashing/setup.bash
114-
rosdep update && rosdep install --from-paths src --ignore-src -r -y
115-
colcon build --symlink-install
116-
```
117-
118-
## Build and flash Crazyflie 2.1 firmware
119-
120-
Install the toolchain:
121-
```bash
122-
sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
123-
sudo apt-get update
124-
sudo apt install gcc-arm-embedded dfu-util
125-
```
126-
127-
Download and build the **Crazyflie 2.1** firmware repository:
128-
```bash
129-
mkdir crazyflie_firmware
130-
git clone https://github.com/eProsima/crazyflie-firmware -b crazyflie_demo
131-
cd crazyflie_firmware
132-
git submodule init
133-
git submodule update
134-
make PLATFORM=cf2
135-
```
136-
137-
Unplug the **Crazyflie 2.1** battery
138-
139-
Push the reset button while connecting the USB power supply.
140-
141-
The top-left blue LED blinks, first slowly and after 4 seconds sightly faster, now it is in DFU programming mode. Check it with `lsusb`:
142-
```bash
143-
Bus 001 Device 051: ID 0483:df11 STMicroelectronics STM Device in DFU Mode
144-
```
145-
146-
Flash the device:
147-
```bash
148-
sudo dfu-util -d 0483:df11 -a 0 -s 0x08000000 -D cf2.bin
149-
```
150-
151-
Unplug and plug the **Crazyflie 2.1** power to exit DFU mode.
152-
153-
154-
## Install Crazyflie Client + Bridge
155-
156-
Install dependencies:
157-
```
158-
sudo apt-get install libusb-1.0-0-dev
159-
sudo apt-get install python3 python3-pip python3-pyqt5 python3-pyqt5.qtsvg
160-
```
161-
162-
Fix permissions for the Crazyradio PA 2.4 GHz USB dongle (restart required for apply changes):
163-
```
164-
sudo groupadd plugdev
165-
sudo usermod -a -G plugdev $USER
166-
sudo echo SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"1915\", ATTRS{idProduct}==\"7777\", \
167-
MODE=\"0664\", GROUP=\"plugdev\" > /etc/udev/rules.d/99-crazyradio.rules
168-
sudo echo SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"0483\", ATTRS{idProduct}==\"5740\", \
169-
MODE=\"0664\", GROUP=\"plugdev\" > /etc/udev/rules.d/99-crazyflie.rules
170-
```
171-
172-
Clone the repo dependencies:
173-
```
174-
git clone -b Micro-XRCE-DDS_Bridge https://github.com/eProsima/crazyflie-clients-python
175-
```
176-
177-
## Build and flash Kobuki Turtlebot 2 firmware
178-
179-
Create a workspace for building **micro-ROS**:
180-
```
181-
source /opt/ros/crystal/setup.bash
182-
sudo apt install python-rosdep curl flex ed gperf openocd automake ed bison libncurses5-dev gcc-arm-none-eabi clang clang-tidy usbutils
183-
mkdir -p kobuki-firmware/src
184-
cd kobuki-firmware
185-
git clone --recursive -b crazyflie_demo https://github.com/micro-ROS/micro-ros-build.git src/micro-ros-build
186-
colcon build --packages-select micro_ros_setup
187-
source install/local_setup.bash
188-
```
189-
190-
Build **micro-ROS Agent**:
191-
```
192-
ros2 run micro_ros_setup create_agent_ws.sh
193-
colcon build
194-
source install/local_setup.sh
195-
```
196-
197-
Install tools:
198-
```
199-
git clone https://bitbucket.org/nuttx/tools.git ~/tools
200-
pushd ~/tools/kconfig-frontends >/dev/null
201-
./configure --enable-mconf --disable-nconf --disable-gconf --disable-qconf
202-
LD_RUN_PATH=/usr/local/lib && make && make install && ldconfig
203-
popd >/dev/null
204-
```
205-
206-
Build Olimex STM32-E407 firmware:
207-
```
208-
ros2 run micro_ros_setup create_firmware_ws.sh
209-
cd firmware/NuttX
210-
tools/configure.sh configs/olimex-stm32-e407/uros
211-
cd ../..
212-
213-
#Put here your agent IP and port
214-
find ./firmware/mcu_ws/ -name rmw_microxrcedds.config -exec sed -i "s/CONFIG_IP=127.0.0.1/CONFIG_IP=192.168.8.10/g" {} \;
215-
find ./firmware/mcu_ws/ -name rmw_microxrcedds.config -exec sed -i "s/CONFIG_PORT=8888/CONFIG_PORT=9999/g" {} \;
216-
217-
ros2 run micro_ros_setup build_firmware.sh
218-
```
219-
220-
Connect Olimex ARM-USB-TINY-H JTAG debugger to Olimex STM32-E407 and flash the board:
221-
```
222-
cd firmware/NuttX
223-
scripts/flash.sh olimex-stm32-e407
224-
```
225-
226-
# Usage
227-
228-
After installation, the following packages should be present in your system:
229-
230-
```
231-
.
232-
+-- Micro-XRCE-DDS # used for installing Micro-XRCE-DDS
233-
+-- crazyflie_demo
234-
+-- crazyflie-firmware # used for building and flashing Crazyflie 2.1 firmware
235-
+-- kobuki-firmware # used for building and flashing Kobuki Turtlebot 2 firmware
236-
+-- crazyflie-clients-python
237-
```
238-
239-
Make sure that all ROS 2 or micro-ROS nodes created along with the following steps **can reach each other using its network interfaces**.
240-
241-
## Run Kobuki Turtlebot 2 Node
242-
243-
TODO: Explain data and power connections between Kobuki Turtlebot 2, Olimex STM32-E407 and MiniRouter.
244-
245-
Run the **micro-ROS Agent**:
246-
```
247-
cd kobuki-firmware
248-
source /opt/ros/crystal/setup.bash && source install/local_setup.bash
249-
ros2 run micro_ros_agent micro_ros_agent udp 9999
250-
```
251-
252-
**micro-ROS Agent** should receive an incoming client connection and */robot_pose* topic should be published. Check it with `ros2 topic echo /robot_pose`
253-
254-
## Run Crazyflie 2.1 Node
255-
256-
Connect Crazyradio PA 2.4 GHz USB dongle and turn on Crazyflie 2.1 drone.
257-
258-
Run the Crazyflie Client + Bridge:
259-
```
260-
cd crazyflie-clients-python
261-
python3 bin/cfclient
262-
```
263-
264-
This command should open the Crazyflie Client and print a serial device path in the terminal (something like /dev/pts/0).
265-
266-
Run (in another prompt) a **Micro XRCE-DDS Agent**:
267-
```
268-
MicroXRCEAgent serial --dev [serial device]
269-
```
270-
271-
**Micro XRCE-DDS Agent** should receive an incoming client connection and */drone/attitude* and */drone/position* topics should be published. Check it with `ros2 topic echo /drone/attitude` and `ros2 topic echo /drone/position`
272-
273-
274-
## Run external ROS 2 nodes
275-
276-
Run commands:
277-
```
278-
cd crazyflie_demo
279-
source /opt/ros/crystal/setup.bash && source install/local_setup.bash
280-
ros2 run micro-ros_crazyflie_demo_remote attitude_to_vel
281-
```
282-
283-
Topic */cmd_vel* should be published, and the **Kobuki Turtlebot 2** should start moving. Check it with `ros2 topic echo /cmd_vel`
284-
285-
## Run RVIZ visualizers
286-
Run complete visualizer:
287-
```
288-
cd crazyflie_demo
289-
source /opt/ros/crystal/setup.bash && source install/local_setup.bash
290-
ros2 launch micro-ros_crazyflie_demo_remote launch_drone_position.launch.py
291-
```
292-
293-
RVIZ windows should be open, and a Crazyflie 2.1 drone model should represent the drone attitude and position along with a historic path.
294-
295-
Run attitude visualizer:
296-
```
297-
cd crazyflie_demo
298-
source /opt/ros/crystal/setup.bash && source install/local_setup.bash
299-
ros2 launch micro-ros_crazyflie_demo_remote launch_drone_attitude.launch.py
300-
```
301-
302-
RVIZ windows should be open and a Crazyflie 2.1 drone model should represent **only** the drone attitude.
8+
{% capture my_include %}{% include crazyflie_demo/README.md %}{% endcapture %}
9+
{{ my_include | markdownify }}
-148 KB
Binary file not shown.

_docs/tutorials/demos/tof_demo/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
title: Time of Flight Sensor Demo
33
permalink: /docs/tutorials/demos/tof_demo/
44
---
5-
WIP
5+
6+
{% capture my_include %}{% include sensors_demo/README.md %}{% endcapture %}
7+
{{ my_include | markdownify }}

_includes/crazyflie_demo

Submodule crazyflie_demo added at 0a55eba

_includes/sensors_demo

Submodule sensors_demo added at 9f96e7e

0 commit comments

Comments
 (0)