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
Copy file name to clipboardExpand all lines: docs/tutorials/03_arm.md
+45-58Lines changed: 45 additions & 58 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,6 +30,7 @@ This tutorial demonstrates fundamental drone safety and control operations using
30
30
-**Automatic Transitions**: How requesting a takeoff can modify the vehicle's flight mode.
31
31
-**DroneController**: Our automatic utility that reads `DroneStateModel` and forwards ROS service calls based on our desired results.
32
32
-**ROS param sets**: Each ROS node can have specific service calls to set configuration parameters on it. we use this to configure heartbeat signal frequency and type on the mavros node.
33
+
-**initializeDroneControl**: This is our connection utility imported from `src/lib/drone_utils.js`. This helps us avoid some of the intialization boilerplate code we had in the previous examples.
**Automatic Arming**: You set your requested state. The `DroneController` internals will take care of any ongoing issues to arm or disarm the drone
148
149
150
+
## Manual arm/disarm
151
+
In here we can see that we call the `.arm()` function if needed. And we keep monitoring the drone state till we observe an armed state
152
+
153
+
<TabsgroupId="language">
154
+
<TabItemvalue="js"label="JavaScript"default>
155
+
156
+
```javascript
157
+
{
158
+
constst=awaitdroneState.getState();
159
+
console.log(`[STEP 1] Current state before arming: armed=${st.vehicle?.armed}, mode=${st.vehicle?.mode}`);
160
+
if (!st.vehicle?.armed) {
161
+
console.log("[STEP 1] Arming drone...");
162
+
await droneController.arm();
163
+
console.log("[STEP 1] Arm command sent successfully");
164
+
} else {
165
+
console.log("[STEP 1] Drone already armed - skipping arm command");
166
+
}
167
+
}
168
+
169
+
// Step 2: Wait to observe the armed state
170
+
console.log("[STEP 2] Waiting 6 seconds to observe armed state...");
171
+
await sleep(6000);
172
+
let armedState = await droneState.getState();
173
+
174
+
while(!armedState.vehicle?.armed) {
175
+
console.log("[STEP 2] Retrying. drone not armed...");
176
+
await droneController.arm();
177
+
await sleep(1000);
178
+
armedState = await droneState.getState();
179
+
}
180
+
```
181
+
182
+
</TabItem>
183
+
<TabItem value="python" label="Python">
184
+
185
+
```bash
186
+
# Coming soon...
187
+
```
188
+
</TabItem>
189
+
</Tabs>
190
+
191
+
## Automatic arm/disarm
192
+
149
193
<Tabs groupId="language">
150
194
<TabItem value="js" label="JavaScript" default>
151
195
@@ -195,65 +239,8 @@ Flight controllers include multiple safety features:
195
239
- **Pre-Arm Checks**: Validates GPS, battery, sensors before arming. Even ground control connection will be validated here. We use mavros so we already configure mavros to act as the ground control for our drone. Had we not done that then the arm would fail. We do this by using ros param sets
196
240
- setting `/mavros/sys.heartbeat_mav_type` to `GCS`
Instead of polling every 100ms, this tutorial uses the new `onSectionChange()` API:
246
-
247
-
- **`onSectionChange(section, listener)`**: Registers a listener for changes in a specific state section
248
-
- **Immediate notifications**: Fires when ROS messages update state, not on a timer
249
-
- **Selective listening**: Only listens to relevant state sections (excludes time updates)
250
-
- **Automatic cleanup**: Listeners are unsubscribed when no longer needed
242
+
Keep in mind that our map panel and anything utility that we have that interacts with the mavros node will do this just to ensure that things are setup properly. As long as the mavros node is up these configurations will remain.
251
243
252
-
The code waits for state confirmation because:
253
-
- Commands are sent asynchronously
254
-
- Network delays may occur
255
-
- Verifies the flight controller accepted the command
256
-
- Provides immediate feedback when we receive new states from mavros.
0 commit comments