dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
transmitter_control.c File Reference

Handles R/C link and flight mode. More...

#include "openpilot.h"
#include "control.h"
#include "transmitter_control.h"
#include "pios_thread.h"
#include "altitudeholdsettings.h"
#include "baroaltitude.h"
#include "flighttelemetrystats.h"
#include "flightstatus.h"
#include "loitercommand.h"
#include "pathdesired.h"
#include "positionactual.h"
#include "receiveractivity.h"
#include "systemsettings.h"
#include "misc_math.h"

Go to the source code of this file.

Data Structures

struct  rcvr_activity_fsm
 

Macros

#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

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)
 
bool ok_to_arm (void)
 Determine if the aircraft is safe to arm based on alarms. More...
 
int rssitype_to_channelgroup ()
 Convert a rssi type to the associated channel group. More...
 
int32_t transmitter_control_initialize ()
 Initialize the transmitter control mode. 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 ()
 
int32_t transmitter_control_update ()
 Process inputs and arming. More...
 
int32_t transmitter_control_select (bool reset_controller)
 Select and use transmitter control. More...
 
enum control_status transmitter_control_get_status ()
 Get any control events. More...
 
uint8_t transmitter_control_get_flight_mode ()
 Query what the flight mode would be if this is selected. More...
 
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

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

Handles R/C link and flight mode.

Author
dRonin, http://dRonin.org/, Copyright (C) 2015-2018
Tau Labs, http://taulabs.org, Copyright (C) 2012-2017
The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
See Also
The GNU Public License (GPL) Version 3

Definition in file transmitter_control.c.