You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**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.
23
26
-**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
26
28
27
29
## Prerequisites
28
30
@@ -31,26 +33,41 @@ This tutorial demonstrates fundamental concepts for connecting to a drone via RO
31
33
32
34
## Running the Tutorial
33
35
34
-
First we will go through the basics of connecting to the VM through javascript.
35
36
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
36
39
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.
39
41
40
42
Here we have an example of how to connect to a drone and conduct basic telemetry of the states (armed, flight mode, etc.)
41
43
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
+
<TabsgroupId="language">
47
+
<TabItemvalue="js"label="JavaScript"default>
43
48
44
49
```bash
45
50
bun run src/tutorials/01_connect.js
46
51
```
47
52
53
+
</TabItem>
54
+
<TabItemvalue="python"label="Python">
55
+
56
+
```bash
57
+
# Coming soon...
58
+
```
59
+
60
+
</TabItem>
61
+
</Tabs>
62
+
48
63
This will start the tutorial script, which connects to the drone via MAVROS and begins monitoring state changes.
49
64
50
65
## Expected Output Example
51
66
52
67
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):
53
68
69
+
<divstyle={{maxHeight:'400px',overflowY:'auto'}}>
70
+
54
71
```
55
72
[INFO] Listening to drone state...
56
73
@@ -239,75 +256,77 @@ status:
239
256
}
240
257
```
241
258
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>
253
260
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
262
262
263
+
First we connect to the ROS bridge using our utility class
264
+
<TabsgroupId="language">
265
+
<TabItemvalue="js"label="JavaScript"default>
263
266
```javascript
264
-
// Create ROS bridge using the wrapper
265
267
constbridge=newROSLibBridgeWrapper();
266
-
awaitbridge.waitForConnection();
267
268
```
269
+
</TabItem>
270
+
<TabItemvalue="python"label="Python">
268
271
269
-
The `ROSLibBridgeWrapper` handles the complex connection setup including authentication and proxy configuration.
272
+
```python
273
+
# Coming soon
274
+
```
270
275
271
-
### Raw State Tracking
276
+
</TabItem>
277
+
</Tabs>
272
278
279
+
Then we can listen to ROS topics by calling the `.subscribe` function on the object as shown below
280
+
<TabsgroupId="language">
281
+
<TabItemvalue="js"label="JavaScript"default>
273
282
```javascript
274
-
// Subscribe to state topic via wrapper (educational: raw ROS processing)
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.
312
331
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