Skip to content

Commit 65adccc

Browse files
committed
update 01 and 02 tutorial docs
1 parent 7c7a291 commit 65adccc

3 files changed

Lines changed: 195 additions & 86 deletions

File tree

docs/tutorials/00_overview.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,24 @@ This section contains step-by-step tutorials for learning drone programming with
1515

1616
| Tutorial | Topic | Prerequisites |
1717
|----------|-------|---------------|
18-
| [00: Preparation](00_preparation.md) | Setup & Simulation | None |
19-
| [01: Connection](01_connection.md) | ROS Bridge Connection & State Monitoring | Preparation |
20-
| [02: Telemetry](02_telemetry.md) | Comprehensive Telemetry Collection | Connection |
18+
| [Preparation](00_preparation.md) | Setup & Simulation | None |
19+
| [Connection](01_connection.md) | ROS Bridge Connection & State Monitoring | Preparation |
20+
| [Telemetry](02_telemetry.md) | Comprehensive Telemetry Collection | Connection |
2121

2222
### Intermediate
2323

2424
| Tutorial | Topic | Prerequisites |
2525
|----------|-------|---------------|
26-
| [03: Arm/Disarm](03_arm.md) | Arm and Disarm the Drone | Telemetry |
27-
| [04: Takeoff & Land](04_takeoff_land.md) | Complete Flight Cycle | Arm/Disarm |
28-
| [05: OFFBOARD Hover](05_offboard_hover.md) | Enter OFFBOARD Mode and Hover | Takeoff/Land |
26+
| [Arm/Disarm](03_arm.md) | Arm and Disarm the Drone | Telemetry |
27+
| [Takeoff & Land](04_takeoff_land.md) | Complete Flight Cycle | Arm/Disarm |
28+
| [OFFBOARD Hover](05_offboard_hover.md) | Enter OFFBOARD Mode and Hover | Takeoff/Land |
2929

3030
### Advanced
3131

3232
| Tutorial | Topic | Prerequisites |
3333
|----------|-------|---------------|
34-
| [06: Move Forward](06_move_forward.md) | Velocity-Based Movement Control | OFFBOARD Hover |
35-
| [07: Go to Waypoint](07_goto_waypoint.md) | Position-Based Navigation | Move Forward |
34+
| [Move Forward](06_move_forward.md) | Velocity-Based Movement Control | OFFBOARD Hover |
35+
| [Go to Waypoint](07_goto_waypoint.md) | Position-Based Navigation | Move Forward |
3636

3737
## Learning Path
3838

docs/tutorials/01_connection.md

Lines changed: 70 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ title: "Tutorial 01: Connection & State Monitoring"
44
sidebar_label: "01: Connection & State Monitoring"
55
---
66

7+
import Tabs from '@theme/Tabs';
8+
import TabItem from '@theme/TabItem';
9+
710
# Tutorial 01: Connection & State Monitoring
811

912
## Overview
@@ -12,17 +15,16 @@ This tutorial demonstrates fundamental concepts for connecting to a drone via RO
1215

1316
## Learning Objectives
1417

15-
- Establish a WebSocket connection to ROS Bridge using ROSLibBridgeWrapper
18+
- Establish a WebSocket connection to ROS Bridge using `ROSLibBridgeWrapper`
1619
- Subscribe directly to MAVROS ROS topics for low-level state monitoring
1720
- Utilize DroneStateModel for aggregated, managed drone state handling
1821
- Compare raw ROS processing vs. managed state utilities
19-
- Monitor key drone parameters: connection status, arming state, flight mode, and guided mode
2022

2123
## Key Concepts
2224

25+
- **ROS**: A robotics communication framework. Data is published on specific topics. And is received by subscribing to the topics. Allows nodes and sensors to communicate with each other.
2326
- **ROS Bridge**: Enables remote WebSocket-based communication with ROS systems
24-
- **MAVROS**: MAVLink extendable communication library for ROS drone integration
25-
- **State Aggregation**: Combining multiple ROS topics into a unified state representation
27+
- **MAVROS**: Mavlink is a very common protocol used to communicate with robotics vehicle controllers. mavlink is built on top of UDP. MAVROS is a library that exposes mavlink to ROS
2628

2729
## Prerequisites
2830

@@ -31,26 +33,41 @@ This tutorial demonstrates fundamental concepts for connecting to a drone via RO
3133

3234
## Running the Tutorial
3335

34-
First we will go through the basics of connecting to the VM through javascript.
3536
There are many ways to connect to a drone. The most basic ways are with a ROS Bridge or directly via ROS.
37+
First we will go through the basics of connecting to the VM remotely via ROS bridge.
38+
ROS bridge will use an authenticated websocket connection to connect to the ROS topics of the virtual machine
3639

37-
For the start we will use ROS Bridge for basic operations. The advantage of ROS Bridge is that it's suitable for websocket connections which are easier to establish remotely.
38-
We already have utilities that connect you to the drone's environment using an authenticated proxy and the "roslib" javascript library.
40+
We already have utilities that connect you to the drone's environment using an authenticated proxy and a ROS bridge library.
3941

4042
Here we have an example of how to connect to a drone and conduct basic telemetry of the states (armed, flight mode, etc.)
4143

42-
To run the 01_connect tutorial, use the following bun command:
44+
To run the 01_connect tutorial example script, use the following command:
45+
46+
<Tabs groupId="language">
47+
<TabItem value="js" label="JavaScript" default>
4348

4449
```bash
4550
bun run src/tutorials/01_connect.js
4651
```
4752

53+
</TabItem>
54+
<TabItem value="python" label="Python">
55+
56+
```bash
57+
# Coming soon...
58+
```
59+
60+
</TabItem>
61+
</Tabs>
62+
4863
This will start the tutorial script, which connects to the drone via MAVROS and begins monitoring state changes.
4964

5065
## Expected Output Example
5166

5267
When running the tutorial, you should see output similar to the following (this is the result of a successful connection and state monitoring and only prints again when changes occur):
5368

69+
<div style={{maxHeight: '400px', overflowY: 'auto'}}>
70+
5471
```
5572
[INFO] Listening to drone state...
5673
@@ -239,75 +256,77 @@ status:
239256
}
240257
```
241258

242-
## How It Works
243-
244-
The tutorial demonstrates two approaches to accessing drone state:
245-
246-
1. **Direct MAVROS Usage**: You can subscribe directly to ROS topics using the MAVROS library. This gives you raw access to individual sensor and state messages, allowing for fine-grained control over what data you receive and how you process it.
247-
248-
2. **Managed State Utility**: The `DroneStateModel` provides an automatically managed state utility that handles subscriptions to multiple ROS topics internally. It aggregates and processes the data into a structured state object, making it easier to work with drone state without manually managing each subscription.
249-
250-
## Update Detection
251-
252-
Updates are detected through ROS topic subscriptions:
259+
</div>
253260

254-
- For the raw approach, each topic subscription triggers a callback whenever a new message is published on that topic.
255-
- For the managed approach, the `DroneStateModel` subscribes to all relevant topics and emits updates when the aggregated state changes, reducing the need for individual topic handlers.
256-
257-
This allows real-time monitoring of the drone's connection status, arming state, flight mode, and other critical parameters.
258-
259-
## Code Analysis
260-
261-
### Connection Setup
261+
## How It Works
262262

263+
First we connect to the ROS bridge using our utility class
264+
<Tabs groupId="language">
265+
<TabItem value="js" label="JavaScript" default>
263266
```javascript
264-
// Create ROS bridge using the wrapper
265267
const bridge = new ROSLibBridgeWrapper();
266-
await bridge.waitForConnection();
267268
```
269+
</TabItem>
270+
<TabItem value="python" label="Python">
268271

269-
The `ROSLibBridgeWrapper` handles the complex connection setup including authentication and proxy configuration.
272+
```python
273+
# Coming soon
274+
```
270275

271-
### Raw State Tracking
276+
</TabItem>
277+
</Tabs>
272278

279+
Then we can listen to ROS topics by calling the `.subscribe` function on the object as shown below
280+
<Tabs groupId="language">
281+
<TabItem value="js" label="JavaScript" default>
273282
```javascript
274-
// Subscribe to state topic via wrapper (educational: raw ROS processing)
275283
const unsubscribeRaw = bridge.subscribe(
276-
{ topic: "/mavros/state", type: "mavros_msgs/State" },
277-
(msg) => {
278-
// Process raw MAVROS message
279-
const currentConnected = msg.connected;
280-
const currentArmed = msg.armed;
281-
// ... handle state changes
282-
}
283-
);
284+
{ topic: "/mavros/state", type: "mavros_msgs/State" },
285+
(msg) => { /*Your code here */ }
284286
```
287+
</TabItem>
288+
<TabItem value="python" label="Python">
285289
286-
Direct topic subscription gives you complete control over message processing.
290+
```python
291+
# Coming soon
292+
```
287293
288-
### Managed State Tracking
294+
</TabItem>
295+
</Tabs>
289296
297+
However this is cumbersome and requires a lot of finetuning and testing.
298+
We already have a utility class that does all the common subscriptions and provides us with a higher level usage and update tracking.
299+
Here is how to use this utility
300+
301+
<Tabs groupId="language">
302+
<TabItem value="js" label="JavaScript" default>
290303
```javascript
291-
// Create drone state model for comparison (shows utility)
292304
const droneState = new DroneStateModel();
305+
// Connect to the bridge.
293306
droneState.connect(bridge);
294307

308+
// Track status update of the drone (slight position changes will not trigger this)
295309
droneState.onStatusUpdate((state) => {
296310
console.log("=== MANAGED DRONE STATE MODEL UPDATE ===");
297311
if (state.vehicle) {
298312
console.log("vehicle :\n", state.vehicle);
299313
}
300-
// ... display aggregated state
314+
315+
if (state.status) {
316+
console.log("status: \n", state.status);
317+
}
301318
});
302319
```
320+
</TabItem>
321+
<TabItem value="python" label="Python">
303322
304-
The `DroneStateModel` automatically manages subscriptions and provides structured state data.
305-
306-
## Navigation
323+
```python
324+
# Coming soon
325+
```
307326
308-
- **Previous**: [Tutorial 00: Preparation](00_preparation.md)
309-
- **Next**: [Tutorial 02: Telemetry](02_telemetry.md)
327+
</TabItem>
328+
</Tabs>
310329
311-
---
330+
The `DroneStateModel` automatically manages subscriptions and provides structured state data. So you won't have to look for topic names and handle decoding them and tracking their updates.
312331
313-
*Tip: Use the Map panel to trigger state changes (arming, mode changes) while the tutorial runs to see live updates.*
332+
Now that we know how to connect to the drone and read it's sensor data we can go over some better examples on how to use this structured sensor data.

0 commit comments

Comments
 (0)