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
This tutorial demonstrates velocity-based movement control in OFFBOARD mode. You'll learn how to command the drone to move forward using timed velocity commands - a fundamental building block for autonomous navigation.
14
+
This tutorial demonstrates the use of the velocity_local setpoint in OFFBOARD modeto move the drone in a single direction. This is very similar to [Offboard hover](05_offboard_hover.md) but the velocity will be non zero.
12
15
13
16
## Learning Objectives
14
17
15
-
- Command forward velocity in OFFBOARD mode
16
-
- Understand time-based open-loop control
17
-
- Calculate expected travel distance from velocity and time
18
+
- Use velocity setpoints in OFFBOARD mode for moving in a single direction.
19
+
- Use position setpoints in OFFBOARD mode for moving to a specific location.
18
20
- Stop movement by returning to zero velocity
19
-
- Understand the limitations of open-loop control
20
21
21
22
## Key Concepts
22
23
23
-
-**Velocity Control**: Commanding movement via velocity vectors
24
-
-**Open-Loop Control**: Time-based movement without position feedback
25
-
-**Body vs World Frame**: Velocity reference frames
-**velocity_local**: Commanding movement via velocity vectors in OFFBOARD mode
25
+
-**position_local**: Commanding movement to a local position in OFFBOARD mode
27
26
28
27
## Prerequisites
29
28
@@ -35,12 +34,24 @@ This tutorial demonstrates velocity-based movement control in OFFBOARD mode. You
35
34
36
35
This tutorial moves the drone forward for 5 seconds at 1 m/s, then lands.
37
36
37
+
<TabsgroupId="language">
38
+
<TabItemvalue="js"label="JavaScript"default>
38
39
```bash
39
40
bun run src/tutorials/06_move_forward.js
40
41
```
42
+
</TabItem>
43
+
<TabItemvalue="python"label="Python">
44
+
45
+
```bash
46
+
# Coming soon...
47
+
```
48
+
49
+
</TabItem>
50
+
</Tabs>
41
51
42
52
## Expected Output Example
43
53
54
+
<divstyle={{maxHeight:'400px',overflowY:'auto'}}>
44
55
```
45
56
[INFO] Connected to ROS Bridge
46
57
@@ -67,170 +78,142 @@ bun run src/tutorials/06_move_forward.js
67
78
[SUCCESS] Mission complete!
68
79
[EXIT] Closing connection...
69
80
```
81
+
</div>
70
82
71
83
## How It Works
72
84
73
-
The tutorial uses simple velocity commands to move forward:
85
+
### Coordinate system
86
+
In the `local` frame (North-East-Down) we have:
87
+
-**+X**: North
88
+
-**+Y**: East
89
+
-**+Z**: Down
74
90
75
-
```
76
-
Time: 0s -----> 5s -----> 6s
77
-
Velocity: 1 m/s 1 m/s 0 m/s
78
-
Action: MOVE MOVE STOP
79
-
```
91
+
So if you wanted to move up you would set the z element of the velocity to a negative value. Keep in mind that in the `velocity_local` coordinates, it doesn't matter which direction the dorne is facing. If it needs to rotate the autopilot has to take care of that.
80
92
81
-
##Code Analysis
93
+
### Manual sequence (With velocity control method)
82
94
83
-
### Configuration
95
+
We can have the drone move in a single direction by setting it's velocity. In this example we will be setting it to a constant value for a couple of seconds.
96
+
Keep in mind that it's also possible to use position_local for setpoint publication. But we will be using velocity for demonstration.
84
97
85
-
```javascript
86
-
constTARGET_ALTITUDE=3.0; // meters
87
-
constFORWARD_VELOCITY=1.0; // m/s
88
-
constMOVE_DURATION=5.0; // seconds
89
-
constSETPOINT_HZ=20;
98
+
Example of movement stages :
90
99
```
91
-
92
-
### Creating Forward Velocity Message
93
-
94
-
```javascript
95
-
constforwardVel=newROSLIB.Message({
96
-
header: { frame_id:"map" },
97
-
twist: {
98
-
linear: { x:FORWARD_VELOCITY, y:0.0, z:0.0 },
99
-
angular: { x:0.0, y:0.0, z:0.0 }
100
-
}
101
-
});
102
-
```
103
-
104
-
The velocity vector:
105
-
-`x: 1.0` - Move forward at 1 m/s
106
-
-`y: 0.0` - No lateral movement
107
-
-`z: 0.0` - Maintain altitude
108
-
109
-
### Movement Loop
110
-
111
-
```javascript
112
-
console.log(`[MOVE] Moving forward at ${FORWARD_VELOCITY} m/s for ${MOVE_DURATION}s`);
// Change the velocity setpoint to start hovering in OFFBOARD mode
141
+
// Zero velocity in offboard mode is only useful if we want to change the velocity again, otherwise it's best to switch to a hold position like "AUTO.LOITER"
-**Next**: [Tutorial 07: Go to Waypoint](07_goto_waypoint.md)
211
+
</TabItem>
212
+
<TabItemvalue="python"label="Python">
233
213
234
-
---
214
+
```bash
215
+
# Coming soon...
216
+
```
235
217
236
-
*Velocity control is the foundation of drone movement. Understanding this enables building any autonomous behavior from simple patterns to complex missions.*
0 commit comments