dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Control Module

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
 

Enumerations

enum  control_status {
  STATUS_DISCONNECTED, STATUS_ERROR, STATUS_SAFETYTIMEOUT, STATUS_DISARM,
  STATUS_NORMAL, STATUS_TOGGLE_ARM, STATUS_ARM_INVALID, STATUS_ARM_VALID,
  STATUS_INVALID_FOR_DISARMED
}
 

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
 

Detailed Description

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.

Macro Definition Documentation

#define ARMED_THRESHOLD   0.50f

Definition at line 58 of file transmitter_control.c.

#define assumptions1
Value:
( \
((int)MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_DISABLED == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_DISABLED) && \
((int)MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_MANUAL == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_MANUAL) && \
((int)MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_RATE == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_RATE) && \
((int)MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_AXISLOCK == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_AXISLOCK) && \
((int)MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_WEAKLEVELING == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_WEAKLEVELING) && \
((int)MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_ATTITUDE == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_ATTITUDE) &&\
((int)MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_LQG == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_LQG) &&\
((int)MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_ATTITUDELQG == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_ATTITUDELQG) \
)

Definition at line 49 of file transmitter_control.h.

#define assumptions3
Value:
( \
((int)MANUALCONTROLSETTINGS_STABILIZATION2SETTINGS_DISABLED == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_DISABLED) && \
((int)MANUALCONTROLSETTINGS_STABILIZATION2SETTINGS_MANUAL == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_MANUAL) && \
((int)MANUALCONTROLSETTINGS_STABILIZATION2SETTINGS_RATE == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_RATE) && \
((int)MANUALCONTROLSETTINGS_STABILIZATION2SETTINGS_AXISLOCK == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_AXISLOCK) && \
((int)MANUALCONTROLSETTINGS_STABILIZATION2SETTINGS_WEAKLEVELING == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_WEAKLEVELING) && \
((int)MANUALCONTROLSETTINGS_STABILIZATION2SETTINGS_ATTITUDE == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_ATTITUDE) &&\
((int)MANUALCONTROLSETTINGS_STABILIZATION2SETTINGS_LQG == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_LQG) &&\
((int)MANUALCONTROLSETTINGS_STABILIZATION2SETTINGS_ATTITUDELQG == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_ATTITUDELQG) \
)

Definition at line 60 of file transmitter_control.h.

#define assumptions5
Value:
( \
((int)MANUALCONTROLSETTINGS_STABILIZATION3SETTINGS_DISABLED == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_DISABLED) && \
((int)MANUALCONTROLSETTINGS_STABILIZATION3SETTINGS_MANUAL == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_MANUAL) && \
((int)MANUALCONTROLSETTINGS_STABILIZATION3SETTINGS_RATE == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_RATE) && \
((int)MANUALCONTROLSETTINGS_STABILIZATION3SETTINGS_AXISLOCK == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_AXISLOCK) && \
((int)MANUALCONTROLSETTINGS_STABILIZATION3SETTINGS_WEAKLEVELING == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_WEAKLEVELING) && \
((int)MANUALCONTROLSETTINGS_STABILIZATION3SETTINGS_ATTITUDE == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_ATTITUDE) &&\
((int)MANUALCONTROLSETTINGS_STABILIZATION3SETTINGS_LQG == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_LQG) &&\
((int)MANUALCONTROLSETTINGS_STABILIZATION3SETTINGS_ATTITUDELQG == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_ATTITUDELQG) \
)

Definition at line 71 of file transmitter_control.h.

#define assumptions_channelcount
Value:
( \
( (int)MANUALCONTROLCOMMAND_CHANNEL_NUMELEM == (int)MANUALCONTROLSETTINGS_CHANNELGROUPS_NUMELEM ) && \
( (int)MANUALCONTROLCOMMAND_CHANNEL_NUMELEM == (int)MANUALCONTROLSETTINGS_CHANNELNUMBER_NUMELEM ) && \
( (int)MANUALCONTROLCOMMAND_CHANNEL_NUMELEM == (int)MANUALCONTROLSETTINGS_CHANNELMIN_NUMELEM ) && \
( (int)MANUALCONTROLCOMMAND_CHANNEL_NUMELEM == (int)MANUALCONTROLSETTINGS_CHANNELMAX_NUMELEM ) && \
( (int)MANUALCONTROLCOMMAND_CHANNEL_NUMELEM == (int)MANUALCONTROLSETTINGS_CHANNELNEUTRAL_NUMELEM ) )

Definition at line 96 of file transmitter_control.h.

#define assumptions_flightmode
Value:
( \
( (int)MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_MANUAL == (int) FLIGHTSTATUS_FLIGHTMODE_MANUAL) && \
( (int)MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_ACRO == (int) FLIGHTSTATUS_FLIGHTMODE_ACRO) && \
( (int)MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_LEVELING == (int) FLIGHTSTATUS_FLIGHTMODE_LEVELING) && \
( (int)MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_HORIZON == (int) FLIGHTSTATUS_FLIGHTMODE_HORIZON) && \
( (int)MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_AXISLOCK == (int) FLIGHTSTATUS_FLIGHTMODE_AXISLOCK) && \
( (int)MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_VIRTUALBAR == (int) FLIGHTSTATUS_FLIGHTMODE_VIRTUALBAR) && \
( (int)MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_STABILIZED1 == (int) FLIGHTSTATUS_FLIGHTMODE_STABILIZED1) && \
( (int)MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_STABILIZED2 == (int) FLIGHTSTATUS_FLIGHTMODE_STABILIZED2) && \
( (int)MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_STABILIZED3 == (int) FLIGHTSTATUS_FLIGHTMODE_STABILIZED3) && \
( (int)MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_POSITIONHOLD == (int) FLIGHTSTATUS_FLIGHTMODE_POSITIONHOLD) && \
( (int)MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_RETURNTOHOME == (int) FLIGHTSTATUS_FLIGHTMODE_RETURNTOHOME) \
)

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,
 
)    (((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.

Enumeration Type Documentation

Enumerator
STATUS_DISCONNECTED 

RX is disconnected.

STATUS_ERROR 

Something is fundamentally wrong.

STATUS_SAFETYTIMEOUT 

Disconnected timeout has occurred.

STATUS_DISARM 

User requested disarm, or low throt timeout.

STATUS_NORMAL 

Things are "normal".

STATUS_TOGGLE_ARM 

For corners. Request we be the "opposite" mode.

STATUS_ARM_INVALID 

User requested arm, controls in invalid pos.

STATUS_ARM_VALID 

User requested arm, controls in valid pos.

STATUS_INVALID_FOR_DISARMED 

Arming switch is in a state that doesn't.

Definition at line 33 of file control.h.

Function Documentation

static bool arming_position ( ManualControlCommandData *  cmd,
ManualControlSettingsData *  settings,
bool  low_throt 
)
static

Check sticks to determine if they are in the arming position

Definition at line 606 of file transmitter_control.c.

static bool channel_is_configured ( int  channel_num)
static

Definition at line 217 of file transmitter_control.c.

static bool check_receiver_timer ( uint32_t  threshold)
static

Definition at line 708 of file transmitter_control.c.

static FlightStatusControlSourceOptions control_source_select ( )
static

control_source_select Determine which sub-module to use for the main control source of the flight controller.

Returns
FlightStatusControlSourceOptions indicating the selected mode

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 bool disarm_commanded ( ManualControlCommandData *  cmd,
ManualControlSettingsData *  settings,
bool  low_throt 
)
static

Definition at line 669 of file transmitter_control.c.

static bool disarming_position ( ManualControlCommandData *  cmd,
ManualControlSettingsData *  settings,
bool  low_throt 
)
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

Parameters
[in]reset_controllerTrue 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 float get_thrust_source ( ManualControlCommandData *  manual_control_command,
bool  always_fullrange 
)
static

Definition at line 167 of file transmitter_control.c.

static bool is_low_throttle_for_arming ( ManualControlCommandData *  manual_control_command)
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 void manualControlTask ( void *  parameters)
static

Module task

Todo:
could consider having a maximum time before we go to safety

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.

Returns
True if safe to arm, false otherwise

Definition at line 379 of file manualcontrol.c.

static void perform_tc_settings_update ( )
static

Definition at line 232 of file transmitter_control.c.

static void process_transmitter_events ( ManualControlCommandData *  cmd,
ManualControlSettingsData *  settings,
bool  valid,
bool  settings_updated 
)
static

Process the inputs and determine whether to arm or not.

Parameters
[in]cmdThe manual control inputs
[in]settingsSettings indicating the necessary position
[in]scaledThe scaled channels, used for checking arming
[in]validIf the input data is valid (i.e. transmitter is transmitting)
[in]settings_updatedTrue if settings changed this cycle

Definition at line 746 of file transmitter_control.c.

static void reset_receiver_timer ( )
static

Definition at line 704 of file transmitter_control.c.

static void resetRcvrActivity ( struct rcvr_activity_fsm fsm)
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.

static float scale_stabilization ( StabilizationSettingsData *  stabSettings,
float  cmd,
SharedDefsStabilizationModeOptions  mode,
StabilizationDesiredStabilizationModeElem  axis 
)
inlinestatic

Definition at line 1015 of file transmitter_control.c.

static float scaleChannel ( int  n,
int16_t  value 
)
static

Convert channel from servo pulse duration (microseconds) to scaled -1/+1 range.

Definition at line 1243 of file transmitter_control.c.

static void set_flight_mode ( )
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 void set_loiter_command ( ManualControlCommandData *  cmd)
static

Definition at line 1226 of file transmitter_control.c.

static void set_manual_control_error ( SystemAlarmsManualControlOptions  error_code)
static

Set the error code and alarm state

Parameters
[in]errorcode

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

Parameters
[in]reset_controllerTrue if previously another controller was used
Todo:
unsafe!

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 int32_t tabletInfo_to_ned ( TabletInfoData *  tabletInfo,
float *  NED 
)
static

Private methods.

Convert the tablet information (in LLA * 10e6) to NED reference frame

Parameters
[in]tabletInfoThe information from the tablet
[out]NEDComputed NED values

Definition at line 196 of file tablet_control.c.

static uint32_t timeDifferenceMs ( uint32_t  start_time,
uint32_t  end_time 
)
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

Parameters
[in]reset_controllerTrue 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.

Todo:
Factor more of the valid-configuration checks up here, so they don't need to be performed each time. Also do additonal validation .. e.g. a mostly-negative throttle range doesn't make sense!

Definition at line 268 of file transmitter_control.c.

static void update_stabilization_desired ( ManualControlCommandData *  manual_control_command,
ManualControlSettingsData *  settings 
)
static

In stabilization mode, set stabilization desired.

Definition at line 1056 of file transmitter_control.c.

static bool updateRcvrActivity ( struct rcvr_activity_fsm fsm)
static

Definition at line 963 of file transmitter_control.c.

static bool updateRcvrActivityCompare ( uintptr_t  rcvr_id,
struct rcvr_activity_fsm fsm 
)
static

Definition at line 908 of file transmitter_control.c.

static void updateRcvrActivitySample ( uintptr_t  rcvr_id,
uint16_t  samples[],
uint8_t  max_channels 
)
static

Definition at line 901 of file transmitter_control.c.

bool validInputRange ( int  n,
uint16_t  value,
uint16_t  offset 
)
static

Determine if the manual input value is within acceptable limits.

Returns
return TRUE if so, otherwise return FALSE

Definition at line 1287 of file transmitter_control.c.

Variable Documentation

struct rcvr_activity_fsm activity_fsm
static

Definition at line 93 of file transmitter_control.c.

bool armed_when_enabled
static

Definition at line 56 of file failsafe_control.c.

ManualControlCommandData cmd
static

Definition at line 88 of file transmitter_control.c.

bool collective_is_thrust
static

Definition at line 100 of file transmitter_control.c.

uint8_t connected_count = 0
static

Definition at line 92 of file transmitter_control.c.

Definition at line 97 of file transmitter_control.c.

uint8_t disconnected_count = 0
static

Definition at line 91 of file transmitter_control.c.

float flight_mode_value
static

Definition at line 96 of file transmitter_control.c.

bool geofence_armed_when_enabled
static

Definition at line 58 of file geofence_control.c.

uint32_t lastActivityTime
static

Definition at line 94 of file transmitter_control.c.

uint32_t lastSysTime
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.

uint32_t receiver_timer = RECEIVER_TIMER_FIRED
static

Definition at line 702 of file transmitter_control.c.

ManualControlSettingsData settings
static

Definition at line 89 of file transmitter_control.c.

bool settings_updated
static

Definition at line 98 of file transmitter_control.c.

struct pios_thread* taskHandle
static

Definition at line 65 of file manualcontrol.c.

bool thrust_is_bidir
static

Definition at line 99 of file transmitter_control.c.

bool vehicle_is_armed = false

Definition at line 71 of file manualcontrol.c.