dRonin
adbada4
dRonin firmware
|
Highest level control module which decides the control state. More...
Files | |
file | failsafe_control.c |
Failsafe controller when transmitter control is lost. | |
file | geofence_control.c |
Geofence controller that is enabled when out of zone. | |
file | failsafe_control.h |
Failsafe controller when transmitter control is lost. | |
file | geofence_control.h |
Geofence controller that is enabled when out of zone. | |
file | tablet_control.h |
Use tablet for control source. | |
file | transmitter_control.h |
Process transmitter inputs and use as control source. | |
file | manualcontrol.c |
ManualControl module. Handles safety R/C link and flight mode. | |
file | tablet_control.c |
Use tablet for control source. | |
file | transmitter_control.c |
Handles R/C link and flight mode. | |
Data Structures | |
struct | rcvr_activity_fsm |
Macros | |
#define | assumptions1 |
#define | assumptions3 |
#define | assumptions5 |
#define | assumptions_flightmode |
#define | assumptions_channelcount |
#define | NEQ(a, b) (((int) (a)) != ((int) (b))) |
#define | STACK_SIZE_BYTES 1200 |
#define | TASK_PRIORITY PIOS_THREAD_PRIO_HIGHEST |
#define | UPDATE_PERIOD_MS 20 |
#define | HOME_ALTITUDE_OFFSET 15 |
Private constants. More... | |
#define | FOLLOWME_RADIUS 20 |
#define | ARMED_THRESHOLD 0.50f |
#define | CONNECTION_OFFSET 250 |
#define | RCVR_ACTIVITY_MONITOR_CHANNELS_PER_GROUP 12 |
#define | RCVR_ACTIVITY_MONITOR_MIN_RANGE 20 |
#define | THRUST_BIDIR_THRESH 0.35f |
#define | MIN_MEANINGFUL_RANGE 40 |
#define | RECEIVER_TIMER_FIRED 0xffffffff |
Functions | |
int32_t | failsafe_control_initialize () |
Initialize the failsafe controller. More... | |
int32_t | failsafe_control_update () |
Perform any updates to the failsafe controller. More... | |
int32_t | failsafe_control_select (bool reset_controller) |
Use failsafe mode. More... | |
int32_t | geofence_control_initialize () |
Initialize the geofence controller. More... | |
int32_t | geofence_control_update () |
Perform any updates to the geofence controller. More... | |
int32_t | geofence_control_select (bool reset_controller) |
Use geofence control mode. More... | |
bool | geofence_control_activate () |
Query if out of bounds and the geofence controller should take over. More... | |
int32_t | tablet_control_initialize () |
Initialize the tablet controller. More... | |
int32_t | tablet_control_update () |
Process updates for the tablet controller. More... | |
int32_t | tablet_control_select (bool reset_controller) |
Use the values for the tablet controller. More... | |
DONT_BUILD_IF (!(assumptions1), TransmitterControlAssumptions1) | |
DONT_BUILD_IF (!(assumptions3), TransmitterControlAssumptions3) | |
DONT_BUILD_IF (!(assumptions5), TransmitterControlAssumptions5) | |
DONT_BUILD_IF (!(assumptions_flightmode), TransmitterControlAssumptions_fm) | |
DONT_BUILD_IF (!(assumptions_channelcount), TransmitterControlAssumptions_cc) | |
DONT_BUILD_IF (NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_ROLL, MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_ROLL)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_ROLL, STABILIZATIONSETTINGS_MANUALRATE_ROLL)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_ROLL, STABILIZATIONSETTINGS_RATEEXPO_ROLL)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_ROLL, STABILIZATIONSETTINGS_HORIZONEXPO_ROLL)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_ROLL, STABILIZATIONSETTINGS_DEADBANDWIDTH_ROLL)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_ROLL, STABILIZATIONSETTINGS_DEADBANDSLOPE_ROLL), ROLLIndicesMismatch) | |
DONT_BUILD_IF (NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_PITCH, MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_PITCH)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_PITCH, STABILIZATIONSETTINGS_MANUALRATE_PITCH)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_PITCH, STABILIZATIONSETTINGS_RATEEXPO_PITCH)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_PITCH, STABILIZATIONSETTINGS_HORIZONEXPO_PITCH)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_PITCH, STABILIZATIONSETTINGS_DEADBANDWIDTH_PITCH)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_PITCH, STABILIZATIONSETTINGS_DEADBANDSLOPE_PITCH), PITCHIndicesMismatch) | |
DONT_BUILD_IF (NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_YAW, MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_YAW)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_YAW, STABILIZATIONSETTINGS_MANUALRATE_YAW)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_YAW, STABILIZATIONSETTINGS_RATEEXPO_YAW)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_YAW, STABILIZATIONSETTINGS_HORIZONEXPO_YAW)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_YAW, STABILIZATIONSETTINGS_DEADBANDWIDTH_YAW)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_YAW, STABILIZATIONSETTINGS_DEADBANDSLOPE_YAW), YAWIndicesMismatch) | |
int32_t | transmitter_control_initialize () |
Initialize the transmitter control mode. More... | |
int32_t | transmitter_control_update () |
Process inputs and arming. More... | |
int32_t | transmitter_control_select (bool reset_controller) |
Select and use transmitter control. More... | |
uint8_t | transmitter_control_get_flight_mode () |
Query what the flight mode would be if this is selected. More... | |
enum control_status | transmitter_control_get_status () |
Get any control events. More... | |
static void | manualControlTask (void *parameters) |
static FlightStatusControlSourceOptions | control_source_select () |
control_source_select Determine which sub-module to use for the main control source of the flight controller. More... | |
bool | ok_to_arm (void) |
Determine if the aircraft is safe to arm based on alarms. More... | |
int32_t | ManualControlStart () |
int32_t | ManualControlInitialize () |
MODULE_HIPRI_INITCALL (ManualControlInitialize, ManualControlStart) | |
static int32_t | tabletInfo_to_ned (TabletInfoData *tabletInfo, float *NED) |
Private methods. More... | |
static float | get_thrust_source (ManualControlCommandData *manual_control_command, bool always_fullrange) |
static void | update_stabilization_desired (ManualControlCommandData *manual_control_command, ManualControlSettingsData *settings) |
In stabilization mode, set stabilization desired. More... | |
static void | set_flight_mode () |
Determine which of N positions the flight mode switch is in and set flight mode accordingly. More... | |
static void | process_transmitter_events (ManualControlCommandData *cmd, ManualControlSettingsData *settings, bool valid, bool settings_updated) |
Process the inputs and determine whether to arm or not. More... | |
static void | set_manual_control_error (SystemAlarmsManualControlOptions errorCode) |
static float | scaleChannel (int n, int16_t value) |
static bool | validInputRange (int n, uint16_t value, uint16_t offset) |
Determine if the manual input value is within acceptable limits. More... | |
static uint32_t | timeDifferenceMs (uint32_t start_time, uint32_t end_time) |
static void | resetRcvrActivity (struct rcvr_activity_fsm *fsm) |
static bool | updateRcvrActivity (struct rcvr_activity_fsm *fsm) |
static void | set_loiter_command (ManualControlCommandData *cmd) |
int | rssitype_to_channelgroup () |
Convert a rssi type to the associated channel group. More... | |
static bool | is_low_throttle_for_arming (ManualControlCommandData *manual_control_command) |
static bool | channel_is_configured (int channel_num) |
static void | perform_tc_settings_update () |
static bool | arming_position (ManualControlCommandData *cmd, ManualControlSettingsData *settings, bool low_throt) |
static bool | disarming_position (ManualControlCommandData *cmd, ManualControlSettingsData *settings, bool low_throt) |
static bool | disarm_commanded (ManualControlCommandData *cmd, ManualControlSettingsData *settings, bool low_throt) |
static void | reset_receiver_timer () |
static bool | check_receiver_timer (uint32_t threshold) |
static void | updateRcvrActivitySample (uintptr_t rcvr_id, uint16_t samples[], uint8_t max_channels) |
static bool | updateRcvrActivityCompare (uintptr_t rcvr_id, struct rcvr_activity_fsm *fsm) |
static float | scale_stabilization (StabilizationSettingsData *stabSettings, float cmd, SharedDefsStabilizationModeOptions mode, StabilizationDesiredStabilizationModeElem axis) |
Variables | |
static bool | armed_when_enabled |
static bool | geofence_armed_when_enabled |
static struct pios_thread * | taskHandle |
bool | vehicle_is_armed = false |
uintptr_t | pios_rcvr_group_map [] |
static ManualControlCommandData | cmd |
static ManualControlSettingsData | settings |
static uint8_t | disconnected_count = 0 |
static uint8_t | connected_count = 0 |
static struct rcvr_activity_fsm | activity_fsm |
static uint32_t | lastActivityTime |
static uint32_t | lastSysTime |
static float | flight_mode_value |
static enum control_status | control_status |
static bool | settings_updated |
static bool | thrust_is_bidir |
static bool | collective_is_thrust |
static uint32_t | receiver_timer = RECEIVER_TIMER_FIRED |
Highest level control module which decides the control state.
This module users the values from the transmitter and its settings to to determine if the system is currently controlled by failsafe, transmitter, or a tablet. The transmitter values are read out and stored in ManualControlCommand. The tablet sends values via TabletInfo which may be used if the flight mode switch is in the appropriate position. The transmitter settings come from ManualControlSettings.
#define ARMED_THRESHOLD 0.50f |
Definition at line 58 of file transmitter_control.c.
#define assumptions1 |
Definition at line 49 of file transmitter_control.h.
#define assumptions3 |
Definition at line 60 of file transmitter_control.h.
#define assumptions5 |
Definition at line 71 of file transmitter_control.h.
#define assumptions_channelcount |
Definition at line 96 of file transmitter_control.h.
#define assumptions_flightmode |
Definition at line 82 of file transmitter_control.h.
#define CONNECTION_OFFSET 250 |
Definition at line 64 of file transmitter_control.c.
#define FOLLOWME_RADIUS 20 |
Definition at line 55 of file tablet_control.c.
#define HOME_ALTITUDE_OFFSET 15 |
Private constants.
Definition at line 54 of file tablet_control.c.
#define MIN_MEANINGFUL_RANGE 40 |
Definition at line 77 of file transmitter_control.c.
#define NEQ | ( | a, | |
b | |||
) | (((int) (a)) != ((int) (b))) |
Definition at line 109 of file transmitter_control.h.
#define RCVR_ACTIVITY_MONITOR_CHANNELS_PER_GROUP 12 |
Definition at line 66 of file transmitter_control.c.
#define RCVR_ACTIVITY_MONITOR_MIN_RANGE 20 |
Definition at line 67 of file transmitter_control.c.
#define RECEIVER_TIMER_FIRED 0xffffffff |
Definition at line 700 of file transmitter_control.c.
#define STACK_SIZE_BYTES 1200 |
Definition at line 58 of file manualcontrol.c.
#define TASK_PRIORITY PIOS_THREAD_PRIO_HIGHEST |
Definition at line 61 of file manualcontrol.c.
#define THRUST_BIDIR_THRESH 0.35f |
Definition at line 71 of file transmitter_control.c.
#define UPDATE_PERIOD_MS 20 |
Definition at line 62 of file manualcontrol.c.
enum control_status |
|
static |
Check sticks to determine if they are in the arming position
Definition at line 606 of file transmitter_control.c.
|
static |
Definition at line 217 of file transmitter_control.c.
|
static |
Definition at line 708 of file transmitter_control.c.
|
static |
control_source_select Determine which sub-module to use for the main control source of the flight controller.
This function is the ultimate one that controls what happens and selects modes such as failsafe, transmitter control, geofencing and potentially other high level modes in the future
Definition at line 353 of file manualcontrol.c.
|
static |
Definition at line 669 of file transmitter_control.c.
|
static |
Check sticks to determine if they are in the disarmed position
Definition at line 642 of file transmitter_control.c.
DONT_BUILD_IF | ( | ! | assumptions1, |
TransmitterControlAssumptions1 | |||
) |
DONT_BUILD_IF | ( | ! | assumptions3, |
TransmitterControlAssumptions3 | |||
) |
DONT_BUILD_IF | ( | ! | assumptions5, |
TransmitterControlAssumptions5 | |||
) |
DONT_BUILD_IF | ( | ! | assumptions_flightmode, |
TransmitterControlAssumptions_fm | |||
) |
DONT_BUILD_IF | ( | ! | assumptions_channelcount, |
TransmitterControlAssumptions_cc | |||
) |
DONT_BUILD_IF | ( | NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_ROLL, MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_ROLL)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_ROLL, STABILIZATIONSETTINGS_MANUALRATE_ROLL)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_ROLL, STABILIZATIONSETTINGS_RATEEXPO_ROLL)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_ROLL, STABILIZATIONSETTINGS_HORIZONEXPO_ROLL)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_ROLL, STABILIZATIONSETTINGS_DEADBANDWIDTH_ROLL)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_ROLL, STABILIZATIONSETTINGS_DEADBANDSLOPE_ROLL) | , |
ROLLIndicesMismatch | |||
) |
DONT_BUILD_IF | ( | NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_PITCH, MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_PITCH)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_PITCH, STABILIZATIONSETTINGS_MANUALRATE_PITCH)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_PITCH, STABILIZATIONSETTINGS_RATEEXPO_PITCH)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_PITCH, STABILIZATIONSETTINGS_HORIZONEXPO_PITCH)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_PITCH, STABILIZATIONSETTINGS_DEADBANDWIDTH_PITCH)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_PITCH, STABILIZATIONSETTINGS_DEADBANDSLOPE_PITCH) | , |
PITCHIndicesMismatch | |||
) |
DONT_BUILD_IF | ( | NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_YAW, MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_YAW)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_YAW, STABILIZATIONSETTINGS_MANUALRATE_YAW)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_YAW, STABILIZATIONSETTINGS_RATEEXPO_YAW)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_YAW, STABILIZATIONSETTINGS_HORIZONEXPO_YAW)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_YAW, STABILIZATIONSETTINGS_DEADBANDWIDTH_YAW)||NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_YAW, STABILIZATIONSETTINGS_DEADBANDSLOPE_YAW) | , |
YAWIndicesMismatch | |||
) |
int32_t failsafe_control_initialize | ( | ) |
Initialize the failsafe controller.
Definition at line 45 of file failsafe_control.c.
int32_t failsafe_control_select | ( | bool | reset_controller | ) |
Use failsafe mode.
Select and use failsafe control
[in] | reset_controller | True if previously another controller was used |
Definition at line 61 of file failsafe_control.c.
int32_t failsafe_control_update | ( | ) |
Perform any updates to the failsafe controller.
Definition at line 51 of file failsafe_control.c.
bool geofence_control_activate | ( | ) |
Query if out of bounds and the geofence controller should take over.
Definition at line 108 of file geofence_control.c.
int32_t geofence_control_initialize | ( | ) |
Initialize the geofence controller.
Definition at line 47 of file geofence_control.c.
int32_t geofence_control_select | ( | bool | reset_controller | ) |
Use geofence control mode.
Definition at line 61 of file geofence_control.c.
int32_t geofence_control_update | ( | ) |
Perform any updates to the geofence controller.
Definition at line 53 of file geofence_control.c.
|
static |
Definition at line 167 of file transmitter_control.c.
|
static |
Definition at line 201 of file transmitter_control.c.
int32_t ManualControlInitialize | ( | ) |
Module initialization
Definition at line 94 of file manualcontrol.c.
int32_t ManualControlStart | ( | ) |
Module starting
Definition at line 79 of file manualcontrol.c.
|
static |
Module task
Definition at line 112 of file manualcontrol.c.
MODULE_HIPRI_INITCALL | ( | ManualControlInitialize | , |
ManualControlStart | |||
) |
bool ok_to_arm | ( | void | ) |
Determine if the aircraft is safe to arm based on alarms.
Definition at line 379 of file manualcontrol.c.
|
static |
Definition at line 232 of file transmitter_control.c.
|
static |
Process the inputs and determine whether to arm or not.
[in] | cmd | The manual control inputs |
[in] | settings | Settings indicating the necessary position |
[in] | scaled | The scaled channels, used for checking arming |
[in] | valid | If the input data is valid (i.e. transmitter is transmitting) |
[in] | settings_updated | True if settings changed this cycle |
Definition at line 746 of file transmitter_control.c.
|
static |
Definition at line 704 of file transmitter_control.c.
|
static |
Definition at line 879 of file transmitter_control.c.
int rssitype_to_channelgroup | ( | ) |
Convert a rssi type to the associated channel group.
Definition at line 120 of file transmitter_control.c.
|
inlinestatic |
Definition at line 1015 of file transmitter_control.c.
|
static |
Convert channel from servo pulse duration (microseconds) to scaled -1/+1 range.
Definition at line 1243 of file transmitter_control.c.
|
static |
Determine which of N positions the flight mode switch is in and set flight mode accordingly.
Definition at line 865 of file transmitter_control.c.
|
static |
Definition at line 1226 of file transmitter_control.c.
|
static |
Set the error code and alarm state
[in] | error | code |
Definition at line 1330 of file transmitter_control.c.
int32_t tablet_control_initialize | ( | ) |
Initialize the tablet controller.
Definition at line 58 of file tablet_control.c.
int32_t tablet_control_select | ( | bool | reset_controller | ) |
Use the values for the tablet controller.
Select and use tablet control
[in] | reset_controller | True if previously another controller was used |
Definition at line 79 of file tablet_control.c.
int32_t tablet_control_update | ( | ) |
Process updates for the tablet controller.
Definition at line 67 of file tablet_control.c.
|
static |
Private methods.
Convert the tablet information (in LLA * 10e6) to NED reference frame
[in] | tabletInfo | The information from the tablet |
[out] | NED | Computed NED values |
Definition at line 196 of file tablet_control.c.
|
static |
Definition at line 1276 of file transmitter_control.c.
uint8_t transmitter_control_get_flight_mode | ( | ) |
Query what the flight mode would be if this is selected.
Determine which of N positions the flight mode switch is in but do not set it.
Definition at line 593 of file transmitter_control.c.
enum control_status transmitter_control_get_status | ( | ) |
Get any control events.
Get the control & arming status.
Definition at line 587 of file transmitter_control.c.
int32_t transmitter_control_initialize | ( | ) |
Initialize the transmitter control mode.
Definition at line 140 of file transmitter_control.c.
int32_t transmitter_control_select | ( | bool | reset_controller | ) |
Select and use transmitter control.
Select and use transmitter control
[in] | reset_controller | True if previously another controller was used |
Definition at line 540 of file transmitter_control.c.
int32_t transmitter_control_update | ( | ) |
Process inputs and arming.
This will always process the arming signals as for now the transmitter is always in charge. When a transmitter is not detected control will fall back to the failsafe module. If the flight mode is in tablet control position then control will be ceeded to that module.
Definition at line 268 of file transmitter_control.c.
|
static |
In stabilization mode, set stabilization desired.
Definition at line 1056 of file transmitter_control.c.
|
static |
Definition at line 963 of file transmitter_control.c.
|
static |
Definition at line 908 of file transmitter_control.c.
|
static |
Definition at line 901 of file transmitter_control.c.
|
static |
Determine if the manual input value is within acceptable limits.
Definition at line 1287 of file transmitter_control.c.
|
static |
Definition at line 93 of file transmitter_control.c.
|
static |
Definition at line 56 of file failsafe_control.c.
|
static |
Definition at line 88 of file transmitter_control.c.
|
static |
Definition at line 100 of file transmitter_control.c.
|
static |
Definition at line 92 of file transmitter_control.c.
|
static |
Definition at line 97 of file transmitter_control.c.
|
static |
Definition at line 91 of file transmitter_control.c.
|
static |
Definition at line 96 of file transmitter_control.c.
|
static |
Definition at line 58 of file geofence_control.c.
|
static |
Definition at line 94 of file transmitter_control.c.
|
static |
Definition at line 95 of file transmitter_control.c.
uintptr_t pios_rcvr_group_map[] |
Definition at line 73 of file pios_hal.c.
|
static |
Definition at line 702 of file transmitter_control.c.
|
static |
Definition at line 89 of file transmitter_control.c.
|
static |
Definition at line 98 of file transmitter_control.c.
|
static |
Definition at line 65 of file manualcontrol.c.
|
static |
Definition at line 99 of file transmitter_control.c.
bool vehicle_is_armed = false |
Definition at line 71 of file manualcontrol.c.