|
| 1 | +# High-Level Commander |
| 2 | + |
| 3 | +The high-level commander provides autonomous flight capabilities for the Crazyflie. It handles |
| 4 | +takeoff, landing, position control, and trajectory execution. All commands require the Crazyflie |
| 5 | +to have a valid position estimate (from a positioning system like Lighthouse or Loco). |
| 6 | + |
| 7 | +```text |
| 8 | +Usage: cfcli hl <COMMAND> |
| 9 | +
|
| 10 | +Commands: |
| 11 | + arm Arm the Crazyflie (enable motors) |
| 12 | + disarm Disarm the Crazyflie (disable motors) |
| 13 | + takeoff Take off to a specified height |
| 14 | + land Land at the current position |
| 15 | + goto Go to a specified position |
| 16 | + stop Stop all high-level commands and disable motors |
| 17 | + trajectory Trajectory operations |
| 18 | + help Print this message or the help of the given subcommand(s) |
| 19 | +``` |
| 20 | + |
| 21 | +## Arm and Disarm |
| 22 | + |
| 23 | +Before flying, the Crazyflie must be armed. This enables the motors and allows the high-level |
| 24 | +commander to control the drone. |
| 25 | + |
| 26 | +```text |
| 27 | +cfcli hl arm |
| 28 | +cfcli hl disarm |
| 29 | +``` |
| 30 | + |
| 31 | +## Takeoff |
| 32 | + |
| 33 | +Take off to a specified height. The duration specifies how long it should take to reach the target height. |
| 34 | + |
| 35 | +```text |
| 36 | +cfcli hl takeoff <HEIGHT> [DURATION] [--yaw <YAW>] |
| 37 | +``` |
| 38 | + |
| 39 | +### Takeoff Examples |
| 40 | + |
| 41 | +```text |
| 42 | +# Take off to 0.5 meters over 2 seconds (default) |
| 43 | +cfcli hl takeoff 0.5 |
| 44 | +
|
| 45 | +# Take off to 1 meter over 3 seconds |
| 46 | +cfcli hl takeoff 1.0 3.0 |
| 47 | +
|
| 48 | +# Take off to 0.5 meters while rotating to 90 degrees yaw |
| 49 | +cfcli hl takeoff 0.5 --yaw 90 |
| 50 | +``` |
| 51 | + |
| 52 | +## Land |
| 53 | + |
| 54 | +Land at the current position. The height parameter specifies the target landing height (typically 0.0). |
| 55 | + |
| 56 | +```text |
| 57 | +cfcli hl land [HEIGHT] [DURATION] [--yaw <YAW>] |
| 58 | +``` |
| 59 | + |
| 60 | +### Land Examples |
| 61 | + |
| 62 | +```text |
| 63 | +# Land over 2 seconds (default) |
| 64 | +cfcli hl land |
| 65 | +
|
| 66 | +# Land over 3 seconds |
| 67 | +cfcli hl land 0.0 3.0 |
| 68 | +
|
| 69 | +# Land while rotating to 0 degrees yaw |
| 70 | +cfcli hl land --yaw 0 |
| 71 | +``` |
| 72 | + |
| 73 | +## Go To Position |
| 74 | + |
| 75 | +Move to a specified position. The position is given as comma-separated x,y,z coordinates. |
| 76 | + |
| 77 | +```text |
| 78 | +cfcli hl goto <POSITION> [-d <DURATION>] [--yaw <YAW>] [-r] |
| 79 | +``` |
| 80 | + |
| 81 | +The position format is `x,y,z` where `x`, `y`, `z` are coordinates in meters. |
| 82 | + |
| 83 | +Options: |
| 84 | + |
| 85 | +- `-d, --duration`: Time in seconds to reach the position (default: 2.0) |
| 86 | +- `--yaw`: Target yaw in degrees (default: 0) |
| 87 | +- `-r, --relative`: Move relative to current position |
| 88 | + |
| 89 | +### Go To Examples |
| 90 | + |
| 91 | +```text |
| 92 | +# Go to position (1, 0, 0.5) over 2 seconds |
| 93 | +cfcli hl goto 1.0,0.0,0.5 |
| 94 | +
|
| 95 | +# Go to position (1, 2, 1) with 90 degree yaw over 5 seconds |
| 96 | +cfcli hl goto 1.0,2.0,1.0 --yaw 90 -d 5.0 |
| 97 | +
|
| 98 | +# Move 0.5 meters forward relative to current position |
| 99 | +cfcli hl goto 0.5,0,0 -r |
| 100 | +
|
| 101 | +# Negative coordinates are supported |
| 102 | +cfcli hl goto -1.0,-0.5,0.5 |
| 103 | +
|
| 104 | +# Rotate to 180 degrees yaw while moving |
| 105 | +cfcli hl goto 0.0,0.0,0.5 --yaw 180 |
| 106 | +``` |
| 107 | + |
| 108 | +## Stop |
| 109 | + |
| 110 | +Immediately stop all high-level commander operations and disable the motors. |
| 111 | + |
| 112 | +```text |
| 113 | +cfcli hl stop |
| 114 | +``` |
| 115 | + |
| 116 | +## Trajectory Operations |
| 117 | + |
| 118 | +Trajectories allow complex pre-defined flight paths to be executed. Trajectories are defined |
| 119 | +as polynomial segments in a YAML file, uploaded to the Crazyflie's memory, and then executed. |
| 120 | + |
| 121 | +```text |
| 122 | +Usage: cfcli hl trajectory <COMMAND> |
| 123 | +
|
| 124 | +Commands: |
| 125 | + upload Upload a trajectory from a YAML file |
| 126 | + run Run a previously uploaded trajectory |
| 127 | + display Display trajectory information (memory info or file contents) |
| 128 | +``` |
| 129 | + |
| 130 | +### Trajectory File Format |
| 131 | + |
| 132 | +Trajectory files are YAML files containing a list of polynomial segments. Each segment defines |
| 133 | +a 7th-degree polynomial for x, y, z, and yaw over a specified duration. This format is compatible |
| 134 | +with the output from the [uav_trajectories](https://github.com/whoenig/uav_trajectories) tool. |
| 135 | + |
| 136 | +```yaml |
| 137 | +segments: |
| 138 | + - duration: 1.5 |
| 139 | + x: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] |
| 140 | + y: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] |
| 141 | + z: [0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] |
| 142 | + yaw: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] |
| 143 | + - duration: 2.0 |
| 144 | + x: [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] |
| 145 | + y: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] |
| 146 | + z: [0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] |
| 147 | + yaw: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] |
| 148 | +``` |
| 149 | +
|
| 150 | +Each segment contains: |
| 151 | +- `duration`: Time in seconds for this segment |
| 152 | +- `x`, `y`, `z`: 8 polynomial coefficients (constant through 7th degree) for position in meters |
| 153 | +- `yaw`: 8 polynomial coefficients for yaw angle in radians |
| 154 | + |
| 155 | +The polynomial is evaluated as: `p(t) = c[0] + c[1]*t + c[2]*t^2 + ... + c[7]*t^7` |
| 156 | + |
| 157 | +Each segment uses 132 bytes of memory on the Crazyflie. |
| 158 | + |
| 159 | +### Upload Trajectory |
| 160 | + |
| 161 | +Upload a trajectory from a YAML file to the Crazyflie's trajectory memory. |
| 162 | + |
| 163 | +```text |
| 164 | +cfcli hl trajectory upload <FILE> [-i <ID>] [-o <OFFSET>] |
| 165 | +``` |
| 166 | + |
| 167 | +Options: |
| 168 | +- `-i, --trajectory-id`: Trajectory ID to assign (default: 1) |
| 169 | +- `-o, --offset`: Memory offset in bytes (default: 0) |
| 170 | + |
| 171 | +### Upload Examples |
| 172 | + |
| 173 | +```text |
| 174 | +# Upload trajectory with default ID (1) |
| 175 | +cfcli hl trajectory upload my_trajectory.yaml |
| 176 | +
|
| 177 | +# Upload trajectory with ID 2 |
| 178 | +cfcli hl trajectory upload figure8.yaml -i 2 |
| 179 | +
|
| 180 | +# Upload multiple trajectories at different offsets |
| 181 | +cfcli hl trajectory upload traj1.yaml -i 1 -o 0 |
| 182 | +cfcli hl trajectory upload traj2.yaml -i 2 -o 1000 |
| 183 | +``` |
| 184 | + |
| 185 | +### Run Trajectory |
| 186 | + |
| 187 | +Execute a previously uploaded trajectory. |
| 188 | + |
| 189 | +```text |
| 190 | +cfcli hl trajectory run <ID> [-s <SCALE>] [-r] [-y] [--reversed] |
| 191 | +``` |
| 192 | + |
| 193 | +Options: |
| 194 | +- `-s, --time-scale`: Time scale factor (1.0 = normal, >1.0 = slower, <1.0 = faster) |
| 195 | +- `-r, --relative-position`: Shift trajectory to start at current position |
| 196 | +- `-y, --relative-yaw`: Align trajectory yaw to current heading |
| 197 | +- `--reversed`: Run the trajectory backwards |
| 198 | + |
| 199 | +### Run Examples |
| 200 | + |
| 201 | +```text |
| 202 | +# Run trajectory ID 1 at normal speed |
| 203 | +cfcli hl trajectory run 1 |
| 204 | +
|
| 205 | +# Run trajectory at half speed |
| 206 | +cfcli hl trajectory run 1 -s 2.0 |
| 207 | +
|
| 208 | +# Run trajectory at double speed |
| 209 | +cfcli hl trajectory run 1 -s 0.5 |
| 210 | +
|
| 211 | +# Run trajectory relative to current position and yaw |
| 212 | +cfcli hl trajectory run 1 -r -y |
| 213 | +
|
| 214 | +# Run trajectory in reverse |
| 215 | +cfcli hl trajectory run 1 --reversed |
| 216 | +``` |
| 217 | + |
| 218 | +### Display Trajectory Info |
| 219 | + |
| 220 | +Display information about a trajectory file or the Crazyflie's trajectory memory. |
| 221 | + |
| 222 | +```text |
| 223 | +# Display trajectory file contents |
| 224 | +cfcli hl trajectory display my_trajectory.yaml |
| 225 | +
|
| 226 | +# Display trajectory memory info from Crazyflie |
| 227 | +cfcli hl trajectory display |
| 228 | +``` |
| 229 | + |
| 230 | +## Complete Flight Example |
| 231 | + |
| 232 | +Here's a complete example of a simple flight sequence: |
| 233 | + |
| 234 | +```bash |
| 235 | +# Select your Crazyflie |
| 236 | +cfcli select |
| 237 | +
|
| 238 | +# Arm the motors |
| 239 | +cfcli hl arm |
| 240 | +
|
| 241 | +# Take off to 0.5 meters |
| 242 | +cfcli hl takeoff 0.5 |
| 243 | +
|
| 244 | +# Wait a moment (the command returns immediately) |
| 245 | +sleep 3 |
| 246 | +
|
| 247 | +# Move to a position |
| 248 | +cfcli hl goto 1.0,0.0,0.5 -d 2.0 |
| 249 | +sleep 3 |
| 250 | +
|
| 251 | +# Move to another position |
| 252 | +cfcli hl goto 0.0,1.0,0.5 -d 2.0 |
| 253 | +sleep 3 |
| 254 | +
|
| 255 | +# Return to origin |
| 256 | +cfcli hl goto 0.0,0.0,0.5 -d 2.0 |
| 257 | +sleep 3 |
| 258 | +
|
| 259 | +# Land |
| 260 | +cfcli hl land |
| 261 | +sleep 3 |
| 262 | +
|
| 263 | +# Disarm (optional, landing auto-disarms after a delay) |
| 264 | +cfcli hl disarm |
| 265 | +``` |
| 266 | + |
| 267 | +## Trajectory Flight Example |
| 268 | + |
| 269 | +Example of uploading and running a trajectory: |
| 270 | + |
| 271 | +```bash |
| 272 | +# Select your Crazyflie |
| 273 | +cfcli select |
| 274 | +
|
| 275 | +# Check trajectory file contents |
| 276 | +cfcli hl trajectory display figure8.yaml |
| 277 | +
|
| 278 | +# Arm and take off |
| 279 | +cfcli hl arm |
| 280 | +cfcli hl takeoff 0.5 |
| 281 | +sleep 3 |
| 282 | +
|
| 283 | +# Upload the trajectory |
| 284 | +cfcli hl trajectory upload figure8.yaml -i 1 |
| 285 | +
|
| 286 | +# Run the trajectory (relative to current position) |
| 287 | +cfcli hl trajectory run 1 -r |
| 288 | +
|
| 289 | +# Wait for trajectory to complete, then land |
| 290 | +sleep 10 |
| 291 | +cfcli hl land |
| 292 | +``` |
0 commit comments