Skip to content

Commit 7d40b54

Browse files
authored
Merge pull request #1281 from bitcraze/krichardsson/arming
Improved arming functionality
2 parents 2418c3f + aa38f7b commit 7d40b54

File tree

18 files changed

+327
-91
lines changed

18 files changed

+327
-91
lines changed

docs/functional-areas/crtp/crtp_localization.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ channels:
99

1010
| Port | Channel | Name|
1111
| ------| ---------| ----------------------|
12-
| 6 | 0 | External Position|
13-
| 6 | 1 | Generic localization|
12+
| 6 | 0 | External Position |
13+
| 6 | 1 | Generic localization |
1414

1515
External Position
1616
-----------------
@@ -39,16 +39,24 @@ subsystem. It has been created to serve the Loco Positioning System
3939
packets but can be used for more general things like GPS NMEA or binary
4040
streams. The format of the packet is:
4141

42-
| Byte | Value | Note|
43-
| ------| ---------| ---------------------------------------|
44-
| 0 | ID | ID of the packet|
45-
| 1.. | Payload | Packet payload. Format defined per ID|
46-
47-
| ID | Packet |
48-
| ----| ------------------------------|
49-
| 2 | LPP Short packet tunnel|
50-
| 3 | Enable emergency stop|
51-
| 4 | Reset emergency stop timeout|
42+
| Byte | Value | Note |
43+
| ------| ---------| --------------------------------------|
44+
| 0 | ID | ID of the packet |
45+
| 1.. | Payload | Packet payload. Format defined per ID |
46+
47+
| ID | Packet |
48+
| ----| -------------------------------------------|
49+
| 0 | Range stream report |
50+
| 1 | Range stream report, 16 bit floating point |
51+
| 2 | LPP Short packet tunnel |
52+
| 3 | Enable emergency stop |
53+
| 4 | Reset emergency stop timeout |
54+
| 6 | COMM GNSS NMEA |
55+
| 7 | COMM GNSS proprietary |
56+
| 8 | External pose information |
57+
| 9 | External pose information, packed |
58+
| 10 | Lighthouse angle stream |
59+
| 11 | Lighthouse data persist |
5260

5361
### LPP Short packet tunnel
5462

docs/functional-areas/crtp/crtp_platform.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ The first byte describes the command:
2121
| value | Command |
2222
|-------|---------|
2323
| 0 | [Set continuous wave](#set-continuous-wave) |
24+
| 1 | [Request arm/disarm the system](#armdisarm-system) |
2425

2526
### Set continuous wave
2627

2728
Command and answer:
2829

2930
| Byte | Description |
3031
|------|-------------|
31-
| 0 | setContinuousWave (0) |
32+
| 0 | command setContinuousWave (0) |
3233
| 1 | Enable |
3334

3435
If enable is not 0, the Crazyflie radio will start transmitting a continuous sine wave at the currently setup
@@ -38,6 +39,25 @@ This command should only be sent over USB (it disables the radio communication).
3839
It is used in production to test the Crazyflie radio path and should not be used outside of a lab or
3940
other very controlled environment. It will effectively jam local radio communication on the channel.
4041

42+
### Arm/disarm system
43+
44+
Arm or disarm the system if possible.
45+
46+
Command:
47+
48+
| Byte | Description |
49+
|------|---------------------------------------|
50+
| 0 | command request arm/disarm system (1) |
51+
| 1 | 0 = disarm, non-zero = arm the system |
52+
53+
Answer:
54+
55+
| Byte | Description |
56+
|------|------------------------------------------------------|
57+
| 0 | command request arm/disarm system (1) |
58+
| 1 | success: 1 if the requested arming state was set |
59+
| 2 | isArmed: 0 = system is disarmed, 1 = system is armed |
60+
4161
## Version commands
4262

4363
The first byte describes the command:
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title: Arming
3+
page_id: supervisor_arming
4+
sort_order: 4
5+
---
6+
7+
Arming is a manual action required before take off to let the system know that the pilot is in control of the system
8+
and is ready to fly. Arming is implemented as a condition in the supervisor and is required to transition from the
9+
`Pre flight checks passed` state to `Ready to fly`. The condition is satisfied by making an arming request in the
10+
supervisor, that is arming in an event. If the supervisor state transitions back to `Pre flight checks passed`, the
11+
system must be armed again to be able to fly.
12+
13+
## Arming request
14+
15+
Clients perform an arming request by sending a [CRTP arming message](/docs/functional-areas/crtp/crtp_platform.md#armdisarm-system)
16+
to the Crazyflie.
17+
18+
Apps running in the Crazyflie request arming by calling the `supervisorRequestArming()` function.
19+
20+
## Auto arming
21+
22+
On small, safe platforms with brushed motors, like the Crazyflie 2.X, it is possible to configure auto arming. When
23+
auto arming is enabled, the system will automatically request arming when entering the `Pre flight checks passed`
24+
state. This will (if all other conditions are met) make the supervisor transition into the `Ready to fly` state.
25+
26+
Auto arming is the default setting for the Crazyflie 2.X.
27+
28+
Auto arming is configured at compile time through the `CONFIG_MOTORS_REQUIRE_ARMING=y` kconfig flag.
29+
30+
## Idle thrust
31+
32+
The motors are used to indicate to the pilot that the system is armed and ready to fly. Motors runs at idle thrust when
33+
the supervisor is in a state where flight is enabled.
34+
35+
Note that the default
36+
settings for idle thrust on the Crazyflie 2.X is 0 and the motors will not spin. On platforms using brushless motors,
37+
an idle thrust that spins the motors should be used.
38+
39+
Idle thrust is configured at compile time through the `CONFIG_MOTORS_DEFAULT_IDLE_THRUST` kconfig parameter.

docs/functional-areas/supervisor/conditions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: Supervisor conditions
33
page_id: supervisor_conditions
4+
sort_order: 1
45
---
56

67
A condition express the state of some part of the system, for instance if we are flying, if the system is armed or

docs/functional-areas/supervisor/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The update sequence is separated into a few steps:
2121
## Modifying behavior
2222

2323
The main modification of behavior is to prevent the motors from spinning when the system is not ready to fly, for
24-
instance if the system is not armed or the USB cable is connected. Also the high level commander is blocked from
24+
instance if the system is not armed or the Crazyflie is up side down. Also the high level commander is blocked from
2525
running trajectories in this case.
2626

2727
Exceptional situations when flying, for instance when tumbling is detected, are simply handled by stopping the

docs/functional-areas/supervisor/states.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: Supervisor states
33
page_id: supervisor_states
4+
sort_order: 2
45
---
56

67
## State diagram

docs/functional-areas/supervisor/transitions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: Supervisor transitions
33
page_id: supervisor_transitions
4+
sort_order: 3
45
---
56

67
A state transition takes the state machine from one state to another. The [conditions bit field](conditions.md) is used to identify

src/config/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
#include "trace.h"
4747
#include "usec_time.h"
4848

49-
#define PROTOCOL_VERSION 5
49+
#define PROTOCOL_VERSION 6
5050

5151
#define CONFIG_BLOCK_ADDRESS (2048 * (64-1))
5252
#define MCU_ID_ADDRESS 0x1FFF7A10

src/modules/interface/supervisor.h

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Crazyflie control firmware
99
*
10-
* Copyright (C) 2021 Bitcraze AB
10+
* Copyright (C) 2021-2023 Bitcraze AB
1111
*
1212
* This program is free software: you can redistribute it and/or modify
1313
* it under the terms of the GNU General Public License as published by
@@ -82,3 +82,29 @@ bool supervisorIsFlying(void);
8282
* @return false
8383
*/
8484
bool supervisorIsTumbled(void);
85+
86+
/**
87+
* @brief Request the system to be armed or disarmed. The system can only be armed under certain conditions, this is
88+
* indicated by the supervisorCanArm() function.
89+
*
90+
* @param doArm true - request arming. false - request disarming.
91+
* @return true The request was granted
92+
* @return false The request could not be granted
93+
*/
94+
bool supervisorRequestArming(const bool doArm);
95+
96+
/**
97+
* @brief Query if the system can be armed
98+
*
99+
* @return true
100+
* @return false
101+
*/
102+
bool supervisorCanArm();
103+
104+
/**
105+
* @brief Query if the system is armed
106+
*
107+
* @return true
108+
* @return false
109+
*/
110+
bool supervisorIsArmed();

src/modules/interface/system.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* || ____ _ __
3-
* +------+ / __ )(_) /_______________ _____ ___
2+
* || ____ _ __
3+
* +------+ / __ )(_) /_______________ _____ ___
44
* | 0xBC | / __ / / __/ ___/ ___/ __ `/_ / / _ \
55
* +------+ / /_/ / / /_/ /__/ / / /_/ / / /_/ __/
66
* || || /_____/_/\__/\___/_/ \__,_/ /___/\___/
@@ -38,8 +38,6 @@ void systemLaunch(void);
3838

3939
void systemStart();
4040
void systemWaitStart(void);
41-
void systemSetArmed(bool val);
42-
bool systemIsArmed();
4341

4442
void systemRequestShutdown();
4543
void systemRequestNRFVersion();

0 commit comments

Comments
 (0)