mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-03-03 04:03:59 -04:00
Copter: integrate EPM library
This commit is contained in:
parent
c8aff81c48
commit
2b5d8aa5b7
@ -132,6 +132,9 @@
|
|||||||
#if SPRAYER == ENABLED
|
#if SPRAYER == ENABLED
|
||||||
#include <AC_Sprayer.h> // crop sprayer library
|
#include <AC_Sprayer.h> // crop sprayer library
|
||||||
#endif
|
#endif
|
||||||
|
#if EPM_ENABLED == ENABLED
|
||||||
|
#include <AP_EPM.h> // EPM cargo gripper stuff
|
||||||
|
#endif
|
||||||
|
|
||||||
// AP_HAL to Arduino compatibility layer
|
// AP_HAL to Arduino compatibility layer
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
@ -829,6 +832,13 @@ AC_Fence fence(&inertial_nav);
|
|||||||
static AC_Sprayer sprayer(&inertial_nav);
|
static AC_Sprayer sprayer(&inertial_nav);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// EPM Cargo Griper
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
#if EPM_ENABLED == ENABLED
|
||||||
|
static AP_EPM epm;
|
||||||
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// function definitions to keep compiler from complaining about undeclared functions
|
// function definitions to keep compiler from complaining about undeclared functions
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -898,6 +908,9 @@ static const AP_Scheduler::Task scheduler_tasks[] PROGMEM = {
|
|||||||
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|
||||||
|
bool enable_external_leds = true;
|
||||||
|
|
||||||
// this needs to be the first call, as it fills memory with
|
// this needs to be the first call, as it fills memory with
|
||||||
// sentinel values
|
// sentinel values
|
||||||
memcheck_init();
|
memcheck_init();
|
||||||
@ -906,12 +919,19 @@ void setup() {
|
|||||||
// Load the default values of variables listed in var_info[]s
|
// Load the default values of variables listed in var_info[]s
|
||||||
AP_Param::setup_sketch_defaults();
|
AP_Param::setup_sketch_defaults();
|
||||||
|
|
||||||
|
// init EPM cargo gripper
|
||||||
|
#if EPM_ENABLED == ENABLED
|
||||||
|
epm.init();
|
||||||
|
enable_external_leds = !epm.enabled();
|
||||||
|
#endif
|
||||||
|
|
||||||
// initialise notify system
|
// initialise notify system
|
||||||
notify.init(true);
|
// disable external leds if epm is enabled because of pin conflict on the APM
|
||||||
|
notify.init(enable_external_leds);
|
||||||
|
|
||||||
// initialise battery monitor
|
// initialise battery monitor
|
||||||
battery.init();
|
battery.init();
|
||||||
|
|
||||||
#if CONFIG_SONAR == ENABLED
|
#if CONFIG_SONAR == ENABLED
|
||||||
#if CONFIG_SONAR_SOURCE == SONAR_SOURCE_ADC
|
#if CONFIG_SONAR_SOURCE == SONAR_SOURCE_ADC
|
||||||
sonar_analog_source = new AP_ADC_AnalogSource(
|
sonar_analog_source = new AP_ADC_AnalogSource(
|
||||||
@ -1006,6 +1026,7 @@ void loop()
|
|||||||
// Main loop - 100hz
|
// Main loop - 100hz
|
||||||
static void fast_loop()
|
static void fast_loop()
|
||||||
{
|
{
|
||||||
|
|
||||||
// IMU DCM Algorithm
|
// IMU DCM Algorithm
|
||||||
// --------------------
|
// --------------------
|
||||||
read_AHRS();
|
read_AHRS();
|
||||||
|
@ -67,6 +67,9 @@ public:
|
|||||||
// relay object
|
// relay object
|
||||||
k_param_relay,
|
k_param_relay,
|
||||||
|
|
||||||
|
// EPM object
|
||||||
|
k_param_epm,
|
||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
//
|
//
|
||||||
k_param_log_bitmask = 20,
|
k_param_log_bitmask = 20,
|
||||||
@ -313,7 +316,7 @@ public:
|
|||||||
AP_Int8 wp_yaw_behavior; // controls how the autopilot controls yaw during missions
|
AP_Int8 wp_yaw_behavior; // controls how the autopilot controls yaw during missions
|
||||||
AP_Int16 angle_max; // maximum lean angle of the copter in centi-degrees
|
AP_Int16 angle_max; // maximum lean angle of the copter in centi-degrees
|
||||||
AP_Int32 angle_rate_max; // maximum rotation rate in roll/pitch axis requested by angle controller used in stabilize, loiter, rtl, auto flight modes
|
AP_Int32 angle_rate_max; // maximum rotation rate in roll/pitch axis requested by angle controller used in stabilize, loiter, rtl, auto flight modes
|
||||||
|
|
||||||
// Waypoints
|
// Waypoints
|
||||||
//
|
//
|
||||||
AP_Int8 command_total;
|
AP_Int8 command_total;
|
||||||
|
@ -394,14 +394,14 @@ const AP_Param::Info var_info[] PROGMEM = {
|
|||||||
// @Param: CH7_OPT
|
// @Param: CH7_OPT
|
||||||
// @DisplayName: Channel 7 option
|
// @DisplayName: Channel 7 option
|
||||||
// @Description: Select which function if performed when CH7 is above 1800 pwm
|
// @Description: Select which function if performed when CH7 is above 1800 pwm
|
||||||
// @Values: 0:Do Nothing, 2:Flip, 3:Simple Mode, 4:RTL, 5:Save Trim, 7:Save WP, 8:Multi Mode, 9:Camera Trigger, 10:Sonar, 11:Fence, 12:ResetToArmedYaw, 13:Super Simple Mode, 14:Acro Trainer, 16:Auto, 17:AutoTune, 18:Land
|
// @Values: 0:Do Nothing, 2:Flip, 3:Simple Mode, 4:RTL, 5:Save Trim, 7:Save WP, 8:Multi Mode, 9:Camera Trigger, 10:Sonar, 11:Fence, 12:ResetToArmedYaw, 13:Super Simple Mode, 14:Acro Trainer, 16:Auto, 17:AutoTune, 18:Land, 19:EPM
|
||||||
// @User: Standard
|
// @User: Standard
|
||||||
GSCALAR(ch7_option, "CH7_OPT", CH7_OPTION),
|
GSCALAR(ch7_option, "CH7_OPT", CH7_OPTION),
|
||||||
|
|
||||||
// @Param: CH8_OPT
|
// @Param: CH8_OPT
|
||||||
// @DisplayName: Channel 8 option
|
// @DisplayName: Channel 8 option
|
||||||
// @Description: Select which function if performed when CH8 is above 1800 pwm
|
// @Description: Select which function if performed when CH8 is above 1800 pwm
|
||||||
// @Values: 0:Do Nothing, 2:Flip, 3:Simple Mode, 4:RTL, 5:Save Trim, 7:Save WP, 8:Multi Mode, 9:Camera Trigger, 10:Sonar, 11:Fence, 12:ResetToArmedYaw, 13:Super Simple Mode, 14:Acro Trainer, 16:Auto, 17:AutoTune, 18:Land
|
// @Values: 0:Do Nothing, 2:Flip, 3:Simple Mode, 4:RTL, 5:Save Trim, 7:Save WP, 8:Multi Mode, 9:Camera Trigger, 10:Sonar, 11:Fence, 12:ResetToArmedYaw, 13:Super Simple Mode, 14:Acro Trainer, 16:Auto, 17:AutoTune, 18:Land, 19:EPM
|
||||||
// @User: Standard
|
// @User: Standard
|
||||||
GSCALAR(ch8_option, "CH8_OPT", CH8_OPTION),
|
GSCALAR(ch8_option, "CH8_OPT", CH8_OPTION),
|
||||||
|
|
||||||
@ -425,7 +425,7 @@ const AP_Param::Info var_info[] PROGMEM = {
|
|||||||
// @Range 90000 250000
|
// @Range 90000 250000
|
||||||
// @User: Advanced
|
// @User: Advanced
|
||||||
GSCALAR(angle_rate_max, "ANGLE_RATE_MAX", ANGLE_RATE_MAX),
|
GSCALAR(angle_rate_max, "ANGLE_RATE_MAX", ANGLE_RATE_MAX),
|
||||||
|
|
||||||
#if FRAME_CONFIG == HELI_FRAME
|
#if FRAME_CONFIG == HELI_FRAME
|
||||||
// @Group: HS1_
|
// @Group: HS1_
|
||||||
// @Path: ../libraries/RC_Channel/RC_Channel.cpp
|
// @Path: ../libraries/RC_Channel/RC_Channel.cpp
|
||||||
@ -981,6 +981,12 @@ const AP_Param::Info var_info[] PROGMEM = {
|
|||||||
// @Path: ../libraries/AP_Relay/AP_Relay.cpp
|
// @Path: ../libraries/AP_Relay/AP_Relay.cpp
|
||||||
GOBJECT(relay, "RELAY_", AP_Relay),
|
GOBJECT(relay, "RELAY_", AP_Relay),
|
||||||
|
|
||||||
|
#if EPM_ENABLED == ENABLED
|
||||||
|
// @Group: EPM_
|
||||||
|
// @Path: ../libraries/AP_EPM/AP_EPM.cpp
|
||||||
|
GOBJECT(epm, "EPM_", AP_EPM),
|
||||||
|
#endif
|
||||||
|
|
||||||
// @Group: COMPASS_
|
// @Group: COMPASS_
|
||||||
// @Path: ../libraries/AP_Compass/Compass.cpp
|
// @Path: ../libraries/AP_Compass/Compass.cpp
|
||||||
GOBJECT(compass, "COMPASS_", Compass),
|
GOBJECT(compass, "COMPASS_", Compass),
|
||||||
|
@ -413,6 +413,12 @@
|
|||||||
# define SPRAYER DISABLED
|
# define SPRAYER DISABLED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
// EPM cargo gripper
|
||||||
|
#ifndef EPM_ENABLED
|
||||||
|
# define EPM_ENABLED DISABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
// RADIO CONFIGURATION
|
// RADIO CONFIGURATION
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -107,6 +107,7 @@ static void init_aux_switches()
|
|||||||
case AUX_SWITCH_RESETTOARMEDYAW:
|
case AUX_SWITCH_RESETTOARMEDYAW:
|
||||||
case AUX_SWITCH_SUPERSIMPLE_MODE:
|
case AUX_SWITCH_SUPERSIMPLE_MODE:
|
||||||
case AUX_SWITCH_ACRO_TRAINER:
|
case AUX_SWITCH_ACRO_TRAINER:
|
||||||
|
case AUX_SWITCH_EPM:
|
||||||
case AUX_SWITCH_SPRAYER:
|
case AUX_SWITCH_SPRAYER:
|
||||||
do_aux_switch_function(g.ch7_option, ap.CH7_flag);
|
do_aux_switch_function(g.ch7_option, ap.CH7_flag);
|
||||||
break;
|
break;
|
||||||
@ -119,6 +120,7 @@ static void init_aux_switches()
|
|||||||
case AUX_SWITCH_RESETTOARMEDYAW:
|
case AUX_SWITCH_RESETTOARMEDYAW:
|
||||||
case AUX_SWITCH_SUPERSIMPLE_MODE:
|
case AUX_SWITCH_SUPERSIMPLE_MODE:
|
||||||
case AUX_SWITCH_ACRO_TRAINER:
|
case AUX_SWITCH_ACRO_TRAINER:
|
||||||
|
case AUX_SWITCH_EPM:
|
||||||
case AUX_SWITCH_SPRAYER:
|
case AUX_SWITCH_SPRAYER:
|
||||||
do_aux_switch_function(g.ch8_option, ap.CH8_flag);
|
do_aux_switch_function(g.ch8_option, ap.CH8_flag);
|
||||||
break;
|
break;
|
||||||
@ -298,7 +300,24 @@ static void do_aux_switch_function(int8_t ch_function, uint8_t ch_flag)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#if EPM_ENABLED == ENABLED
|
||||||
|
case AUX_SWITCH_EPM:
|
||||||
|
switch(ch_flag) {
|
||||||
|
case AUX_SWITCH_LOW:
|
||||||
|
epm.off();
|
||||||
|
Log_Write_Event(DATA_EPM_OFF);
|
||||||
|
break;
|
||||||
|
case AUX_SWITCH_MIDDLE:
|
||||||
|
epm.neutral();
|
||||||
|
Log_Write_Event(DATA_EPM_NEUTRAL);
|
||||||
|
break;
|
||||||
|
case AUX_SWITCH_HIGH:
|
||||||
|
epm.on();
|
||||||
|
Log_Write_Event(DATA_EPM_ON);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
#if SPRAYER == ENABLED
|
#if SPRAYER == ENABLED
|
||||||
case AUX_SWITCH_SPRAYER:
|
case AUX_SWITCH_SPRAYER:
|
||||||
sprayer.enable(ch_flag == AUX_SWITCH_HIGH);
|
sprayer.enable(ch_flag == AUX_SWITCH_HIGH);
|
||||||
|
@ -72,6 +72,7 @@
|
|||||||
#define AUX_SWITCH_AUTO 16 // change to auto flight mode
|
#define AUX_SWITCH_AUTO 16 // change to auto flight mode
|
||||||
#define AUX_SWITCH_AUTOTUNE 17 // auto tune
|
#define AUX_SWITCH_AUTOTUNE 17 // auto tune
|
||||||
#define AUX_SWITCH_LAND 18 // change to LAND flight mode
|
#define AUX_SWITCH_LAND 18 // change to LAND flight mode
|
||||||
|
#define AUX_SWITCH_EPM 19 // Operate the EPM cargo gripper low=off, middle=neutral, high=on
|
||||||
|
|
||||||
// values used by the ap.ch7_opt and ap.ch8_opt flags
|
// values used by the ap.ch7_opt and ap.ch8_opt flags
|
||||||
#define AUX_SWITCH_LOW 0 // indicates auxiliar switch is in the low position (pwm <1200)
|
#define AUX_SWITCH_LOW 0 // indicates auxiliar switch is in the low position (pwm <1200)
|
||||||
@ -319,7 +320,9 @@
|
|||||||
#define DATA_ACRO_TRAINER_DISABLED 43
|
#define DATA_ACRO_TRAINER_DISABLED 43
|
||||||
#define DATA_ACRO_TRAINER_LEVELING 44
|
#define DATA_ACRO_TRAINER_LEVELING 44
|
||||||
#define DATA_ACRO_TRAINER_LIMITED 45
|
#define DATA_ACRO_TRAINER_LIMITED 45
|
||||||
|
#define DATA_EPM_ON 46
|
||||||
|
#define DATA_EPM_OFF 47
|
||||||
|
#define DATA_EPM_NEUTRAL 48
|
||||||
// RADIANS
|
// RADIANS
|
||||||
#define RADX100 0.000174532925f
|
#define RADX100 0.000174532925f
|
||||||
#define DEGX100 5729.57795f
|
#define DEGX100 5729.57795f
|
||||||
|
Loading…
Reference in New Issue
Block a user