mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 14:38:30 -04:00
Copter: rename FlightMode class to Mode
also remove unused print_FlightMode method
This commit is contained in:
parent
6e9de7e609
commit
06fbe8f3a7
@ -943,59 +943,59 @@ private:
|
||||
|
||||
#include "FlightMode.h"
|
||||
|
||||
Copter::FlightMode *flightmode;
|
||||
Copter::Mode *flightmode;
|
||||
|
||||
#if FRAME_CONFIG == HELI_FRAME
|
||||
Copter::FlightMode_Acro_Heli flightmode_acro{*this};
|
||||
Copter::ModeAcro_Heli flightmode_acro{*this};
|
||||
#else
|
||||
Copter::FlightMode_Acro flightmode_acro{*this};
|
||||
Copter::ModeAcro flightmode_acro{*this};
|
||||
#endif
|
||||
|
||||
Copter::FlightMode_AltHold flightmode_althold{*this};
|
||||
Copter::ModeAltHold flightmode_althold{*this};
|
||||
|
||||
Copter::FlightMode_Auto flightmode_auto{*this, mission, circle_nav};
|
||||
Copter::ModeAuto flightmode_auto{*this, mission, circle_nav};
|
||||
|
||||
#if AUTOTUNE_ENABLED == ENABLED
|
||||
Copter::FlightMode_AutoTune flightmode_autotune{*this};
|
||||
Copter::ModeAutoTune flightmode_autotune{*this};
|
||||
#endif
|
||||
|
||||
Copter::FlightMode_Brake flightmode_brake{*this};
|
||||
Copter::ModeBrake flightmode_brake{*this};
|
||||
|
||||
Copter::FlightMode_Circle flightmode_circle{*this, circle_nav};
|
||||
Copter::ModeCircle flightmode_circle{*this, circle_nav};
|
||||
|
||||
Copter::FlightMode_Drift flightmode_drift{*this};
|
||||
Copter::ModeDrift flightmode_drift{*this};
|
||||
|
||||
Copter::FlightMode_Flip flightmode_flip{*this};
|
||||
Copter::ModeFlip flightmode_flip{*this};
|
||||
|
||||
Copter::FlightMode_Guided flightmode_guided{*this};
|
||||
Copter::ModeGuided flightmode_guided{*this};
|
||||
|
||||
Copter::FlightMode_Land flightmode_land{*this};
|
||||
Copter::ModeLand flightmode_land{*this};
|
||||
|
||||
Copter::FlightMode_Loiter flightmode_loiter{*this};
|
||||
Copter::ModeLoiter flightmode_loiter{*this};
|
||||
|
||||
Copter::FlightMode_PosHold flightmode_poshold{*this};
|
||||
Copter::ModePosHold flightmode_poshold{*this};
|
||||
|
||||
Copter::FlightMode_RTL flightmode_rtl{*this};
|
||||
Copter::ModeRTL flightmode_rtl{*this};
|
||||
|
||||
#if FRAME_CONFIG == HELI_FRAME
|
||||
Copter::FlightMode_Stabilize_Heli flightmode_stabilize{*this};
|
||||
Copter::ModeStabilize_Heli flightmode_stabilize{*this};
|
||||
#else
|
||||
Copter::FlightMode_Stabilize flightmode_stabilize{*this};
|
||||
Copter::ModeStabilize flightmode_stabilize{*this};
|
||||
#endif
|
||||
|
||||
Copter::FlightMode_Sport flightmode_sport{*this};
|
||||
Copter::ModeSport flightmode_sport{*this};
|
||||
|
||||
Copter::FlightMode_Avoid_ADSB flightmode_avoid_adsb{*this};
|
||||
Copter::ModeAvoidADSB flightmode_avoid_adsb{*this};
|
||||
|
||||
Copter::FlightMode_Throw flightmode_throw{*this};
|
||||
Copter::ModeThrow flightmode_throw{*this};
|
||||
|
||||
Copter::FlightMode_Guided_NoGPS flightmode_guided_nogps{*this};
|
||||
Copter::ModeGuidedNoGPS flightmode_guided_nogps{*this};
|
||||
|
||||
Copter::FlightMode_SmartRTL flightmode_smartrtl{*this};
|
||||
Copter::ModeSmartRTL flightmode_smartrtl{*this};
|
||||
|
||||
Copter::FlightMode *flightmode_for_mode(const uint8_t mode);
|
||||
Copter::Mode *flightmode_for_mode(const uint8_t mode);
|
||||
|
||||
void exit_mode(FlightMode *&old_flightmode, FlightMode *&new_flightmode);
|
||||
void exit_mode(Mode *&old_flightmode, Mode *&new_flightmode);
|
||||
|
||||
public:
|
||||
void mavlink_delay_cb();
|
||||
|
@ -2,13 +2,13 @@
|
||||
|
||||
// this class is #included into the Copter:: namespace
|
||||
|
||||
class FlightMode {
|
||||
class Mode {
|
||||
friend class Copter;
|
||||
friend class AP_Arming_Copter;
|
||||
|
||||
public:
|
||||
|
||||
FlightMode(Copter &copter) :
|
||||
Mode(Copter &copter) :
|
||||
_copter(copter),
|
||||
g(copter.g),
|
||||
g2(copter.g2),
|
||||
@ -42,9 +42,6 @@ protected:
|
||||
virtual bool requires_GPS() const = 0;
|
||||
virtual bool has_manual_throttle() const = 0;
|
||||
virtual bool allows_arming(bool from_gcs) const = 0;
|
||||
void print_FlightMode(AP_HAL::BetterStream *port) const {
|
||||
port->print(name());
|
||||
}
|
||||
virtual const char *name() const = 0;
|
||||
|
||||
// returns a string for this flightmode, exactly 4 bytes
|
||||
@ -90,7 +87,7 @@ protected:
|
||||
#endif
|
||||
|
||||
// pass-through functions to reduce code churn on conversion;
|
||||
// these are candidates for moving into the FlightMode base
|
||||
// these are candidates for moving into the Mode base
|
||||
// class.
|
||||
void get_pilot_desired_lean_angles(float roll_in, float pitch_in, float &roll_out, float &pitch_out, float angle_max) {
|
||||
_copter.get_pilot_desired_lean_angles(roll_in, pitch_in, roll_out, pitch_out, angle_max);
|
||||
@ -166,12 +163,12 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
class FlightMode_Acro : public FlightMode {
|
||||
class ModeAcro : public Mode {
|
||||
|
||||
public:
|
||||
|
||||
FlightMode_Acro(Copter &copter) :
|
||||
Copter::FlightMode(copter)
|
||||
ModeAcro(Copter &copter) :
|
||||
Copter::Mode(copter)
|
||||
{ }
|
||||
virtual bool init(bool ignore_checks) override;
|
||||
virtual void run() override;
|
||||
@ -193,12 +190,12 @@ private:
|
||||
};
|
||||
|
||||
#if FRAME_CONFIG == HELI_FRAME
|
||||
class FlightMode_Acro_Heli : public FlightMode_Acro {
|
||||
class ModeAcro_Heli : public ModeAcro {
|
||||
|
||||
public:
|
||||
|
||||
FlightMode_Acro_Heli(Copter &copter) :
|
||||
Copter::FlightMode_Acro(copter)
|
||||
ModeAcro_Heli(Copter &copter) :
|
||||
Copter::ModeAcro(copter)
|
||||
{ }
|
||||
|
||||
bool init(bool ignore_checks) override;
|
||||
@ -210,12 +207,12 @@ private:
|
||||
#endif
|
||||
|
||||
|
||||
class FlightMode_AltHold : public FlightMode {
|
||||
class ModeAltHold : public Mode {
|
||||
|
||||
public:
|
||||
|
||||
FlightMode_AltHold(Copter &copter) :
|
||||
Copter::FlightMode(copter)
|
||||
ModeAltHold(Copter &copter) :
|
||||
Copter::Mode(copter)
|
||||
{ }
|
||||
|
||||
bool init(bool ignore_checks) override;
|
||||
@ -236,12 +233,12 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class FlightMode_Auto : public FlightMode {
|
||||
class ModeAuto : public Mode {
|
||||
|
||||
public:
|
||||
|
||||
FlightMode_Auto(Copter &copter, AP_Mission &_mission, AC_Circle *& _circle_nav) :
|
||||
Copter::FlightMode(copter),
|
||||
ModeAuto(Copter &copter, AP_Mission &_mission, AC_Circle *& _circle_nav) :
|
||||
Copter::Mode(copter),
|
||||
mission(_mission),
|
||||
circle_nav(_circle_nav)
|
||||
{ }
|
||||
@ -313,12 +310,12 @@ private:
|
||||
|
||||
|
||||
#if AUTOTUNE_ENABLED == ENABLED
|
||||
class FlightMode_AutoTune : public FlightMode {
|
||||
class ModeAutoTune : public Mode {
|
||||
|
||||
public:
|
||||
|
||||
FlightMode_AutoTune(Copter &copter) :
|
||||
Copter::FlightMode(copter)
|
||||
ModeAutoTune(Copter &copter) :
|
||||
Copter::Mode(copter)
|
||||
{ }
|
||||
|
||||
bool init(bool ignore_checks) override;
|
||||
@ -465,12 +462,12 @@ private:
|
||||
#endif
|
||||
|
||||
|
||||
class FlightMode_Brake : public FlightMode {
|
||||
class ModeBrake : public Mode {
|
||||
|
||||
public:
|
||||
|
||||
FlightMode_Brake(Copter &copter) :
|
||||
Copter::FlightMode(copter)
|
||||
ModeBrake(Copter &copter) :
|
||||
Copter::Mode(copter)
|
||||
{ }
|
||||
|
||||
bool init(bool ignore_checks) override;
|
||||
@ -496,12 +493,12 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class FlightMode_Circle : public FlightMode {
|
||||
class ModeCircle : public Mode {
|
||||
|
||||
public:
|
||||
|
||||
FlightMode_Circle(Copter &copter, AC_Circle *& _circle_nav) :
|
||||
Copter::FlightMode(copter),
|
||||
ModeCircle(Copter &copter, AC_Circle *& _circle_nav) :
|
||||
Copter::Mode(copter),
|
||||
circle_nav(_circle_nav)
|
||||
{ }
|
||||
|
||||
@ -534,12 +531,12 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class FlightMode_Drift : public FlightMode {
|
||||
class ModeDrift : public Mode {
|
||||
|
||||
public:
|
||||
|
||||
FlightMode_Drift(Copter &copter) :
|
||||
Copter::FlightMode(copter)
|
||||
ModeDrift(Copter &copter) :
|
||||
Copter::Mode(copter)
|
||||
{ }
|
||||
|
||||
virtual bool init(bool ignore_checks) override;
|
||||
@ -562,12 +559,12 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class FlightMode_Flip : public FlightMode {
|
||||
class ModeFlip : public Mode {
|
||||
|
||||
public:
|
||||
|
||||
FlightMode_Flip(Copter &copter) :
|
||||
Copter::FlightMode(copter)
|
||||
ModeFlip(Copter &copter) :
|
||||
Copter::Mode(copter)
|
||||
{ }
|
||||
|
||||
virtual bool init(bool ignore_checks) override;
|
||||
@ -591,12 +588,12 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class FlightMode_Guided : public FlightMode {
|
||||
class ModeGuided : public Mode {
|
||||
|
||||
public:
|
||||
|
||||
FlightMode_Guided(Copter &copter) :
|
||||
Copter::FlightMode(copter) { }
|
||||
ModeGuided(Copter &copter) :
|
||||
Copter::Mode(copter) { }
|
||||
|
||||
bool init(bool ignore_checks) override;
|
||||
void run() override;
|
||||
@ -650,12 +647,12 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class FlightMode_Guided_NoGPS : public FlightMode_Guided {
|
||||
class ModeGuidedNoGPS : public ModeGuided {
|
||||
|
||||
public:
|
||||
|
||||
FlightMode_Guided_NoGPS(Copter &copter) :
|
||||
Copter::FlightMode_Guided(copter) { }
|
||||
ModeGuidedNoGPS(Copter &copter) :
|
||||
Copter::ModeGuided(copter) { }
|
||||
|
||||
bool init(bool ignore_checks) override;
|
||||
void run() override;
|
||||
@ -675,12 +672,12 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class FlightMode_Land : public FlightMode {
|
||||
class ModeLand : public Mode {
|
||||
|
||||
public:
|
||||
|
||||
FlightMode_Land(Copter &copter) :
|
||||
Copter::FlightMode(copter)
|
||||
ModeLand(Copter &copter) :
|
||||
Copter::Mode(copter)
|
||||
{ }
|
||||
|
||||
bool init(bool ignore_checks) override;
|
||||
@ -709,12 +706,12 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class FlightMode_Loiter : public FlightMode {
|
||||
class ModeLoiter : public Mode {
|
||||
|
||||
public:
|
||||
|
||||
FlightMode_Loiter(Copter &copter) :
|
||||
Copter::FlightMode(copter)
|
||||
ModeLoiter(Copter &copter) :
|
||||
Copter::Mode(copter)
|
||||
{ }
|
||||
|
||||
bool init(bool ignore_checks) override;
|
||||
@ -755,12 +752,12 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class FlightMode_PosHold : public FlightMode {
|
||||
class ModePosHold : public Mode {
|
||||
|
||||
public:
|
||||
|
||||
FlightMode_PosHold(Copter &copter) :
|
||||
Copter::FlightMode(copter)
|
||||
ModePosHold(Copter &copter) :
|
||||
Copter::Mode(copter)
|
||||
{ }
|
||||
|
||||
bool init(bool ignore_checks) override;
|
||||
@ -789,12 +786,12 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class FlightMode_RTL : public FlightMode {
|
||||
class ModeRTL : public Mode {
|
||||
|
||||
public:
|
||||
|
||||
FlightMode_RTL(Copter &copter) :
|
||||
Copter::FlightMode(copter)
|
||||
ModeRTL(Copter &copter) :
|
||||
Copter::Mode(copter)
|
||||
{ }
|
||||
|
||||
bool init(bool ignore_checks) override;
|
||||
@ -865,12 +862,12 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class FlightMode_SmartRTL : public FlightMode_RTL {
|
||||
class ModeSmartRTL : public ModeRTL {
|
||||
|
||||
public:
|
||||
|
||||
FlightMode_SmartRTL(Copter &copter) :
|
||||
FlightMode_SmartRTL::FlightMode_RTL(copter)
|
||||
ModeSmartRTL(Copter &copter) :
|
||||
ModeSmartRTL::ModeRTL(copter)
|
||||
{ }
|
||||
|
||||
bool init(bool ignore_checks) override;
|
||||
@ -907,12 +904,12 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class FlightMode_Sport : public FlightMode {
|
||||
class ModeSport : public Mode {
|
||||
|
||||
public:
|
||||
|
||||
FlightMode_Sport(Copter &copter) :
|
||||
Copter::FlightMode(copter)
|
||||
ModeSport(Copter &copter) :
|
||||
Copter::Mode(copter)
|
||||
{ }
|
||||
|
||||
virtual bool init(bool ignore_checks) override;
|
||||
@ -933,12 +930,12 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class FlightMode_Stabilize : public FlightMode {
|
||||
class ModeStabilize : public Mode {
|
||||
|
||||
public:
|
||||
|
||||
FlightMode_Stabilize(Copter &copter) :
|
||||
Copter::FlightMode(copter)
|
||||
ModeStabilize(Copter &copter) :
|
||||
Copter::Mode(copter)
|
||||
{ }
|
||||
|
||||
virtual bool init(bool ignore_checks) override;
|
||||
@ -959,12 +956,12 @@ private:
|
||||
};
|
||||
|
||||
#if FRAME_CONFIG == HELI_FRAME
|
||||
class FlightMode_Stabilize_Heli : public FlightMode_Stabilize {
|
||||
class ModeStabilize_Heli : public ModeStabilize {
|
||||
|
||||
public:
|
||||
|
||||
FlightMode_Stabilize_Heli(Copter &copter) :
|
||||
Copter::FlightMode_Stabilize(copter)
|
||||
ModeStabilize_Heli(Copter &copter) :
|
||||
Copter::ModeStabilize(copter)
|
||||
{ }
|
||||
|
||||
bool init(bool ignore_checks) override;
|
||||
@ -978,12 +975,12 @@ private:
|
||||
#endif
|
||||
|
||||
|
||||
class FlightMode_Throw : public FlightMode {
|
||||
class ModeThrow : public Mode {
|
||||
|
||||
public:
|
||||
|
||||
FlightMode_Throw(Copter &copter) :
|
||||
Copter::FlightMode(copter)
|
||||
ModeThrow(Copter &copter) :
|
||||
Copter::Mode(copter)
|
||||
{ }
|
||||
|
||||
bool init(bool ignore_checks) override;
|
||||
@ -1017,12 +1014,12 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class FlightMode_Avoid_ADSB : public FlightMode_Guided {
|
||||
class ModeAvoidADSB : public ModeGuided {
|
||||
|
||||
public:
|
||||
|
||||
FlightMode_Avoid_ADSB(Copter &copter) :
|
||||
Copter::FlightMode_Guided(copter) { }
|
||||
ModeAvoidADSB(Copter &copter) :
|
||||
Copter::ModeGuided(copter) { }
|
||||
|
||||
bool init(bool ignore_checks) override;
|
||||
void run() override;
|
||||
|
@ -21,7 +21,7 @@ struct PACKED log_AutoTune {
|
||||
};
|
||||
|
||||
// Write an Autotune data packet
|
||||
void Copter::FlightMode_AutoTune::Log_Write_AutoTune(uint8_t _axis, uint8_t tune_step, float meas_target, float meas_min, float meas_max, float new_gain_rp, float new_gain_rd, float new_gain_sp, float new_ddt)
|
||||
void Copter::ModeAutoTune::Log_Write_AutoTune(uint8_t _axis, uint8_t tune_step, float meas_target, float meas_min, float meas_max, float new_gain_rp, float new_gain_rd, float new_gain_sp, float new_ddt)
|
||||
{
|
||||
struct log_AutoTune pkt = {
|
||||
LOG_PACKET_HEADER_INIT(LOG_AUTOTUNE_MSG),
|
||||
@ -47,7 +47,7 @@ struct PACKED log_AutoTuneDetails {
|
||||
};
|
||||
|
||||
// Write an Autotune data packet
|
||||
void Copter::FlightMode_AutoTune::Log_Write_AutoTuneDetails(float angle_cd, float rate_cds)
|
||||
void Copter::ModeAutoTune::Log_Write_AutoTuneDetails(float angle_cd, float rate_cds)
|
||||
{
|
||||
struct log_AutoTuneDetails pkt = {
|
||||
LOG_PACKET_HEADER_INIT(LOG_AUTOTUNEDETAILS_MSG),
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Init and run calls for acro flight mode
|
||||
*/
|
||||
|
||||
bool Copter::FlightMode_Acro::init(bool ignore_checks)
|
||||
bool Copter::ModeAcro::init(bool ignore_checks)
|
||||
{
|
||||
// if landed and the mode we're switching from does not have manual throttle and the throttle stick is too high
|
||||
if (motors->armed() && ap.land_complete && !_copter.flightmode->has_manual_throttle() &&
|
||||
@ -19,7 +19,7 @@ bool Copter::FlightMode_Acro::init(bool ignore_checks)
|
||||
return true;
|
||||
}
|
||||
|
||||
void Copter::FlightMode_Acro::run()
|
||||
void Copter::ModeAcro::run()
|
||||
{
|
||||
float target_roll, target_pitch, target_yaw;
|
||||
float pilot_throttle_scaled;
|
||||
@ -52,7 +52,7 @@ void Copter::FlightMode_Acro::run()
|
||||
|
||||
// get_pilot_desired_angle_rates - transform pilot's roll pitch and yaw input into a desired lean angle rates
|
||||
// returns desired angle rates in centi-degrees-per-second
|
||||
void Copter::FlightMode_Acro::get_pilot_desired_angle_rates(int16_t roll_in, int16_t pitch_in, int16_t yaw_in, float &roll_out, float &pitch_out, float &yaw_out)
|
||||
void Copter::ModeAcro::get_pilot_desired_angle_rates(int16_t roll_in, int16_t pitch_in, int16_t yaw_in, float &roll_out, float &pitch_out, float &yaw_out)
|
||||
{
|
||||
float rate_limit;
|
||||
Vector3f rate_ef_level, rate_bf_level, rate_bf_request;
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
// althold_init - initialise althold controller
|
||||
bool Copter::FlightMode_AltHold::init(bool ignore_checks)
|
||||
bool Copter::ModeAltHold::init(bool ignore_checks)
|
||||
{
|
||||
// initialize vertical speeds and leash lengths
|
||||
pos_control->set_speed_z(-get_pilot_speed_dn(), g.pilot_speed_up);
|
||||
@ -26,7 +26,7 @@ bool Copter::FlightMode_AltHold::init(bool ignore_checks)
|
||||
|
||||
// althold_run - runs the althold controller
|
||||
// should be called at 100hz or more
|
||||
void Copter::FlightMode_AltHold::run()
|
||||
void Copter::ModeAltHold::run()
|
||||
{
|
||||
AltHoldModeState althold_state;
|
||||
float takeoff_climb_rate = 0.0f;
|
||||
|
@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
// auto_init - initialise auto controller
|
||||
bool Copter::FlightMode_Auto::init(bool ignore_checks)
|
||||
bool Copter::ModeAuto::init(bool ignore_checks)
|
||||
{
|
||||
if ((_copter.position_ok() && mission.num_commands() > 1) || ignore_checks) {
|
||||
_mode = Auto_Loiter;
|
||||
@ -52,7 +52,7 @@ bool Copter::FlightMode_Auto::init(bool ignore_checks)
|
||||
// auto_run - runs the auto controller
|
||||
// should be called at 100hz or more
|
||||
// relies on run_autopilot being called at 10hz which handles decision making and non-navigation related commands
|
||||
void Copter::FlightMode_Auto::run()
|
||||
void Copter::ModeAuto::run()
|
||||
{
|
||||
// call the correct auto controller
|
||||
switch (_mode) {
|
||||
@ -99,7 +99,7 @@ void Copter::FlightMode_Auto::run()
|
||||
}
|
||||
|
||||
// auto_takeoff_start - initialises waypoint controller to implement take-off
|
||||
void Copter::FlightMode_Auto::takeoff_start(const Location& dest_loc)
|
||||
void Copter::ModeAuto::takeoff_start(const Location& dest_loc)
|
||||
{
|
||||
_mode = Auto_TakeOff;
|
||||
|
||||
@ -147,7 +147,7 @@ void Copter::FlightMode_Auto::takeoff_start(const Location& dest_loc)
|
||||
|
||||
// auto_takeoff_run - takeoff in auto mode
|
||||
// called by auto_run at 100hz or more
|
||||
void Copter::FlightMode_Auto::takeoff_run()
|
||||
void Copter::ModeAuto::takeoff_run()
|
||||
{
|
||||
// if not auto armed or motor interlock not enabled set throttle to zero and exit immediately
|
||||
if (!motors->armed() || !ap.auto_armed || !motors->get_interlock()) {
|
||||
@ -200,7 +200,7 @@ void Copter::FlightMode_Auto::takeoff_run()
|
||||
}
|
||||
|
||||
// auto_wp_start - initialises waypoint controller to implement flying to a particular destination
|
||||
void Copter::FlightMode_Auto::wp_start(const Vector3f& destination)
|
||||
void Copter::ModeAuto::wp_start(const Vector3f& destination)
|
||||
{
|
||||
_mode = Auto_WP;
|
||||
|
||||
@ -215,7 +215,7 @@ void Copter::FlightMode_Auto::wp_start(const Vector3f& destination)
|
||||
}
|
||||
|
||||
// auto_wp_start - initialises waypoint controller to implement flying to a particular destination
|
||||
void Copter::FlightMode_Auto::wp_start(const Location_Class& dest_loc)
|
||||
void Copter::ModeAuto::wp_start(const Location_Class& dest_loc)
|
||||
{
|
||||
_mode = Auto_WP;
|
||||
|
||||
@ -235,7 +235,7 @@ void Copter::FlightMode_Auto::wp_start(const Location_Class& dest_loc)
|
||||
|
||||
// auto_wp_run - runs the auto waypoint controller
|
||||
// called by auto_run at 100hz or more
|
||||
void Copter::FlightMode_Auto::wp_run()
|
||||
void Copter::ModeAuto::wp_run()
|
||||
{
|
||||
// if not auto armed or motor interlock not enabled set throttle to zero and exit immediately
|
||||
if (!motors->armed() || !ap.auto_armed || !motors->get_interlock()) {
|
||||
@ -285,7 +285,7 @@ void Copter::FlightMode_Auto::wp_run()
|
||||
|
||||
// auto_spline_start - initialises waypoint controller to implement flying to a particular destination using the spline controller
|
||||
// seg_end_type can be SEGMENT_END_STOP, SEGMENT_END_STRAIGHT or SEGMENT_END_SPLINE. If Straight or Spline the next_destination should be provided
|
||||
void Copter::FlightMode_Auto::spline_start(const Location_Class& destination, bool stopped_at_start,
|
||||
void Copter::ModeAuto::spline_start(const Location_Class& destination, bool stopped_at_start,
|
||||
AC_WPNav::spline_segment_end_type seg_end_type,
|
||||
const Location_Class& next_destination)
|
||||
{
|
||||
@ -307,7 +307,7 @@ void Copter::FlightMode_Auto::spline_start(const Location_Class& destination, bo
|
||||
|
||||
// auto_spline_run - runs the auto spline controller
|
||||
// called by auto_run at 100hz or more
|
||||
void Copter::FlightMode_Auto::spline_run()
|
||||
void Copter::ModeAuto::spline_run()
|
||||
{
|
||||
// if not auto armed or motor interlock not enabled set throttle to zero and exit immediately
|
||||
if (!motors->armed() || !ap.auto_armed || !motors->get_interlock()) {
|
||||
@ -356,7 +356,7 @@ void Copter::FlightMode_Auto::spline_run()
|
||||
}
|
||||
|
||||
// auto_land_start - initialises controller to implement a landing
|
||||
void Copter::FlightMode_Auto::land_start()
|
||||
void Copter::ModeAuto::land_start()
|
||||
{
|
||||
// set target to stopping point
|
||||
Vector3f stopping_point;
|
||||
@ -367,7 +367,7 @@ void Copter::FlightMode_Auto::land_start()
|
||||
}
|
||||
|
||||
// auto_land_start - initialises controller to implement a landing
|
||||
void Copter::FlightMode_Auto::land_start(const Vector3f& destination)
|
||||
void Copter::ModeAuto::land_start(const Vector3f& destination)
|
||||
{
|
||||
_mode = Auto_Land;
|
||||
|
||||
@ -386,7 +386,7 @@ void Copter::FlightMode_Auto::land_start(const Vector3f& destination)
|
||||
|
||||
// auto_land_run - lands in auto mode
|
||||
// called by auto_run at 100hz or more
|
||||
void Copter::FlightMode_Auto::land_run()
|
||||
void Copter::ModeAuto::land_run()
|
||||
{
|
||||
// if not auto armed or landed or motor interlock not enabled set throttle to zero and exit immediately
|
||||
if (!motors->armed() || !ap.auto_armed || ap.land_complete || !motors->get_interlock()) {
|
||||
@ -411,7 +411,7 @@ void Copter::FlightMode_Auto::land_run()
|
||||
_copter.land_run_vertical_control();
|
||||
}
|
||||
|
||||
bool Copter::FlightMode_Auto::landing_gear_should_be_deployed()
|
||||
bool Copter::ModeAuto::landing_gear_should_be_deployed()
|
||||
{
|
||||
switch(_mode) {
|
||||
case Auto_Land:
|
||||
@ -433,7 +433,7 @@ bool Copter::FlightMode_Auto::landing_gear_should_be_deployed()
|
||||
}
|
||||
|
||||
// auto_rtl_start - initialises RTL in AUTO flight mode
|
||||
void Copter::FlightMode_Auto::rtl_start()
|
||||
void Copter::ModeAuto::rtl_start()
|
||||
{
|
||||
_mode = Auto_RTL;
|
||||
|
||||
@ -443,7 +443,7 @@ void Copter::FlightMode_Auto::rtl_start()
|
||||
|
||||
// auto_rtl_run - rtl in AUTO flight mode
|
||||
// called by auto_run at 100hz or more
|
||||
void Copter::FlightMode_Auto::rtl_run()
|
||||
void Copter::ModeAuto::rtl_run()
|
||||
{
|
||||
// call regular rtl flight mode run function
|
||||
_copter.flightmode_rtl.run(false);
|
||||
@ -451,7 +451,7 @@ void Copter::FlightMode_Auto::rtl_run()
|
||||
|
||||
// auto_circle_movetoedge_start - initialise waypoint controller to move to edge of a circle with it's center at the specified location
|
||||
// we assume the caller has performed all required GPS_ok checks
|
||||
void Copter::FlightMode_Auto::circle_movetoedge_start(const Location_Class &circle_center, float radius_m)
|
||||
void Copter::ModeAuto::circle_movetoedge_start(const Location_Class &circle_center, float radius_m)
|
||||
{
|
||||
// convert location to vector from ekf origin
|
||||
Vector3f circle_center_neu;
|
||||
@ -505,7 +505,7 @@ void Copter::FlightMode_Auto::circle_movetoedge_start(const Location_Class &circ
|
||||
|
||||
// auto_circle_start - initialises controller to fly a circle in AUTO flight mode
|
||||
// assumes that circle_nav object has already been initialised with circle center and radius
|
||||
void Copter::FlightMode_Auto::circle_start()
|
||||
void Copter::ModeAuto::circle_start()
|
||||
{
|
||||
_mode = Auto_Circle;
|
||||
|
||||
@ -515,7 +515,7 @@ void Copter::FlightMode_Auto::circle_start()
|
||||
|
||||
// auto_circle_run - circle in AUTO flight mode
|
||||
// called by auto_run at 100hz or more
|
||||
void Copter::FlightMode_Auto::circle_run()
|
||||
void Copter::ModeAuto::circle_run()
|
||||
{
|
||||
// call circle controller
|
||||
circle_nav->update();
|
||||
@ -529,7 +529,7 @@ void Copter::FlightMode_Auto::circle_run()
|
||||
|
||||
#if NAV_GUIDED == ENABLED
|
||||
// auto_nav_guided_start - hand over control to external navigation controller in AUTO mode
|
||||
void Copter::FlightMode_Auto::nav_guided_start()
|
||||
void Copter::ModeAuto::nav_guided_start()
|
||||
{
|
||||
_mode = Auto_NavGuided;
|
||||
|
||||
@ -542,7 +542,7 @@ void Copter::FlightMode_Auto::nav_guided_start()
|
||||
|
||||
// auto_nav_guided_run - allows control by external navigation controller
|
||||
// called by auto_run at 100hz or more
|
||||
void Copter::FlightMode_Auto::nav_guided_run()
|
||||
void Copter::ModeAuto::nav_guided_run()
|
||||
{
|
||||
// call regular guided flight mode run function
|
||||
_copter.flightmode_guided.run();
|
||||
@ -551,7 +551,7 @@ void Copter::FlightMode_Auto::nav_guided_run()
|
||||
|
||||
// auto_loiter_start - initialises loitering in auto mode
|
||||
// returns success/failure because this can be called by exit_mission
|
||||
bool Copter::FlightMode_Auto::loiter_start()
|
||||
bool Copter::ModeAuto::loiter_start()
|
||||
{
|
||||
// return failure if GPS is bad
|
||||
if (!_copter.position_ok()) {
|
||||
@ -574,7 +574,7 @@ bool Copter::FlightMode_Auto::loiter_start()
|
||||
|
||||
// auto_loiter_run - loiter in AUTO flight mode
|
||||
// called by auto_run at 100hz or more
|
||||
void Copter::FlightMode_Auto::loiter_run()
|
||||
void Copter::ModeAuto::loiter_run()
|
||||
{
|
||||
// if not auto armed or motor interlock not enabled set throttle to zero and exit immediately
|
||||
if (!motors->armed() || !ap.auto_armed || ap.land_complete || !motors->get_interlock()) {
|
||||
@ -792,7 +792,7 @@ float Copter::get_auto_yaw_rate_cds(void)
|
||||
}
|
||||
|
||||
// auto_payload_place_start - initialises controller to implement a placing
|
||||
void Copter::FlightMode_Auto::payload_place_start()
|
||||
void Copter::ModeAuto::payload_place_start()
|
||||
{
|
||||
// set target to stopping point
|
||||
Vector3f stopping_point;
|
||||
@ -804,7 +804,7 @@ void Copter::FlightMode_Auto::payload_place_start()
|
||||
}
|
||||
|
||||
// auto_payload_place_start - initialises controller to implement placement of a load
|
||||
void Copter::FlightMode_Auto::payload_place_start(const Vector3f& destination)
|
||||
void Copter::ModeAuto::payload_place_start(const Vector3f& destination)
|
||||
{
|
||||
_mode = Auto_NavPayloadPlace;
|
||||
_copter.nav_payload_place.state = PayloadPlaceStateType_Calibrating_Hover_Start;
|
||||
@ -822,7 +822,7 @@ void Copter::FlightMode_Auto::payload_place_start(const Vector3f& destination)
|
||||
set_auto_yaw_mode(AUTO_YAW_HOLD);
|
||||
}
|
||||
|
||||
bool Copter::FlightMode_Auto::payload_place_run_should_run()
|
||||
bool Copter::ModeAuto::payload_place_run_should_run()
|
||||
{
|
||||
// muts be armed
|
||||
if (!motors->armed()) {
|
||||
@ -846,7 +846,7 @@ bool Copter::FlightMode_Auto::payload_place_run_should_run()
|
||||
|
||||
// auto_payload_place_run - places an object in auto mode
|
||||
// called by auto_run at 100hz or more
|
||||
void Copter::FlightMode_Auto::payload_place_run()
|
||||
void Copter::ModeAuto::payload_place_run()
|
||||
{
|
||||
if (!payload_place_run_should_run()) {
|
||||
#if FRAME_CONFIG == HELI_FRAME // Helicopters always stabilize roll/pitch/yaw
|
||||
@ -884,7 +884,7 @@ void Copter::FlightMode_Auto::payload_place_run()
|
||||
}
|
||||
}
|
||||
|
||||
void Copter::FlightMode_Auto::payload_place_run_loiter()
|
||||
void Copter::ModeAuto::payload_place_run_loiter()
|
||||
{
|
||||
// loiter...
|
||||
_copter.land_run_horizontal_control();
|
||||
@ -900,7 +900,7 @@ void Copter::FlightMode_Auto::payload_place_run_loiter()
|
||||
pos_control->update_z_controller();
|
||||
}
|
||||
|
||||
void Copter::FlightMode_Auto::payload_place_run_descend()
|
||||
void Copter::ModeAuto::payload_place_run_descend()
|
||||
{
|
||||
_copter.land_run_horizontal_control();
|
||||
_copter.land_run_vertical_control();
|
||||
|
@ -93,7 +93,7 @@
|
||||
#define AUTOTUNE_ANNOUNCE_INTERVAL_MS 2000
|
||||
|
||||
// autotune_init - should be called when autotune mode is selected
|
||||
bool Copter::FlightMode_AutoTune::init(bool ignore_checks)
|
||||
bool Copter::ModeAutoTune::init(bool ignore_checks)
|
||||
{
|
||||
bool success = true;
|
||||
|
||||
@ -145,7 +145,7 @@ bool Copter::FlightMode_AutoTune::init(bool ignore_checks)
|
||||
}
|
||||
|
||||
// stop - should be called when the ch7/ch8 switch is switched OFF
|
||||
void Copter::FlightMode_AutoTune::stop()
|
||||
void Copter::ModeAutoTune::stop()
|
||||
{
|
||||
// set gains to their original values
|
||||
load_orig_gains();
|
||||
@ -162,7 +162,7 @@ void Copter::FlightMode_AutoTune::stop()
|
||||
}
|
||||
|
||||
// start - Initialize autotune flight mode
|
||||
bool Copter::FlightMode_AutoTune::start(bool ignore_checks)
|
||||
bool Copter::ModeAutoTune::start(bool ignore_checks)
|
||||
{
|
||||
// only allow flip from Stabilize, AltHold, PosHold or Loiter modes
|
||||
if (_copter.control_mode != STABILIZE && _copter.control_mode != ALT_HOLD &&
|
||||
@ -193,7 +193,7 @@ bool Copter::FlightMode_AutoTune::start(bool ignore_checks)
|
||||
return true;
|
||||
}
|
||||
|
||||
const char *Copter::FlightMode_AutoTune::level_issue_string() const
|
||||
const char *Copter::ModeAutoTune::level_issue_string() const
|
||||
{
|
||||
switch (level_problem.issue) {
|
||||
case LEVEL_ISSUE_NONE:
|
||||
@ -214,7 +214,7 @@ const char *Copter::FlightMode_AutoTune::level_issue_string() const
|
||||
return "Bug";
|
||||
}
|
||||
|
||||
void Copter::FlightMode_AutoTune::send_step_string()
|
||||
void Copter::ModeAutoTune::send_step_string()
|
||||
{
|
||||
if (pilot_override) {
|
||||
gcs().send_text(MAV_SEVERITY_INFO, "AutoTune: Paused: Pilot Override Active");
|
||||
@ -234,7 +234,7 @@ void Copter::FlightMode_AutoTune::send_step_string()
|
||||
gcs().send_text(MAV_SEVERITY_INFO, "AutoTune: unknown step");
|
||||
}
|
||||
|
||||
const char *Copter::FlightMode_AutoTune::type_string() const
|
||||
const char *Copter::ModeAutoTune::type_string() const
|
||||
{
|
||||
switch (tune_type) {
|
||||
case RD_UP:
|
||||
@ -251,7 +251,7 @@ const char *Copter::FlightMode_AutoTune::type_string() const
|
||||
return "Bug";
|
||||
}
|
||||
|
||||
void Copter::FlightMode_AutoTune::do_gcs_announcements()
|
||||
void Copter::ModeAutoTune::do_gcs_announcements()
|
||||
{
|
||||
const uint32_t now = millis();
|
||||
if (now - announce_time < AUTOTUNE_ANNOUNCE_INTERVAL_MS) {
|
||||
@ -312,7 +312,7 @@ void Copter::FlightMode_AutoTune::do_gcs_announcements()
|
||||
|
||||
// run - runs the autotune flight mode
|
||||
// should be called at 100hz or more
|
||||
void Copter::FlightMode_AutoTune::run()
|
||||
void Copter::ModeAutoTune::run()
|
||||
{
|
||||
float target_roll, target_pitch;
|
||||
float target_yaw_rate;
|
||||
@ -419,7 +419,7 @@ void Copter::FlightMode_AutoTune::run()
|
||||
}
|
||||
}
|
||||
|
||||
bool Copter::FlightMode_AutoTune::check_level(const LEVEL_ISSUE issue, const float current, const float maximum)
|
||||
bool Copter::ModeAutoTune::check_level(const LEVEL_ISSUE issue, const float current, const float maximum)
|
||||
{
|
||||
if (current > maximum) {
|
||||
level_problem.current = current;
|
||||
@ -430,7 +430,7 @@ bool Copter::FlightMode_AutoTune::check_level(const LEVEL_ISSUE issue, const flo
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Copter::FlightMode_AutoTune::currently_level()
|
||||
bool Copter::ModeAutoTune::currently_level()
|
||||
{
|
||||
if (!check_level(LEVEL_ISSUE_ANGLE_ROLL,
|
||||
labs(ahrs.roll_sensor - roll_cd),
|
||||
@ -467,7 +467,7 @@ bool Copter::FlightMode_AutoTune::currently_level()
|
||||
}
|
||||
|
||||
// attitude_controller - sets attitude control targets during tuning
|
||||
void Copter::FlightMode_AutoTune::autotune_attitude_control()
|
||||
void Copter::ModeAutoTune::autotune_attitude_control()
|
||||
{
|
||||
rotation_rate = 0.0f; // rotation rate in radians/second
|
||||
lean_angle = 0.0f;
|
||||
@ -871,7 +871,7 @@ void Copter::FlightMode_AutoTune::autotune_attitude_control()
|
||||
|
||||
// backup_gains_and_initialise - store current gains as originals
|
||||
// called before tuning starts to backup original gains
|
||||
void Copter::FlightMode_AutoTune::backup_gains_and_initialise()
|
||||
void Copter::ModeAutoTune::backup_gains_and_initialise()
|
||||
{
|
||||
// initialise state because this is our first time
|
||||
if (roll_enabled()) {
|
||||
@ -929,7 +929,7 @@ void Copter::FlightMode_AutoTune::backup_gains_and_initialise()
|
||||
|
||||
// load_orig_gains - set gains to their original values
|
||||
// called by stop and failed functions
|
||||
void Copter::FlightMode_AutoTune::load_orig_gains()
|
||||
void Copter::ModeAutoTune::load_orig_gains()
|
||||
{
|
||||
attitude_control->bf_feedforward(orig_bf_feedforward);
|
||||
if (roll_enabled()) {
|
||||
@ -963,7 +963,7 @@ void Copter::FlightMode_AutoTune::load_orig_gains()
|
||||
}
|
||||
|
||||
// load_tuned_gains - load tuned gains
|
||||
void Copter::FlightMode_AutoTune::load_tuned_gains()
|
||||
void Copter::ModeAutoTune::load_tuned_gains()
|
||||
{
|
||||
if (!attitude_control->get_bf_feedforward()) {
|
||||
attitude_control->bf_feedforward(true);
|
||||
@ -1002,7 +1002,7 @@ void Copter::FlightMode_AutoTune::load_tuned_gains()
|
||||
|
||||
// load_intra_test_gains - gains used between tests
|
||||
// called during testing mode's update-gains step to set gains ahead of return-to-level step
|
||||
void Copter::FlightMode_AutoTune::load_intra_test_gains()
|
||||
void Copter::ModeAutoTune::load_intra_test_gains()
|
||||
{
|
||||
// we are restarting tuning so reset gains to tuning-start gains (i.e. low I term)
|
||||
// sanity check the gains
|
||||
@ -1030,7 +1030,7 @@ void Copter::FlightMode_AutoTune::load_intra_test_gains()
|
||||
|
||||
// load_twitch_gains - load the to-be-tested gains for a single axis
|
||||
// called by attitude_control() just before it beings testing a gain (i.e. just before it twitches)
|
||||
void Copter::FlightMode_AutoTune::load_twitch_gains()
|
||||
void Copter::ModeAutoTune::load_twitch_gains()
|
||||
{
|
||||
switch (axis) {
|
||||
case ROLL:
|
||||
@ -1057,7 +1057,7 @@ void Copter::FlightMode_AutoTune::load_twitch_gains()
|
||||
|
||||
// save_tuning_gains - save the final tuned gains for each axis
|
||||
// save discovered gains to eeprom if autotuner is enabled (i.e. switch is in the high position)
|
||||
void Copter::FlightMode_AutoTune::save_tuning_gains()
|
||||
void Copter::ModeAutoTune::save_tuning_gains()
|
||||
{
|
||||
// if we successfully completed tuning
|
||||
if (mode == SUCCESS) {
|
||||
@ -1145,7 +1145,7 @@ void Copter::FlightMode_AutoTune::save_tuning_gains()
|
||||
}
|
||||
|
||||
// update_gcs - send message to ground station
|
||||
void Copter::FlightMode_AutoTune::update_gcs(uint8_t message_id)
|
||||
void Copter::ModeAutoTune::update_gcs(uint8_t message_id)
|
||||
{
|
||||
switch (message_id) {
|
||||
case AUTOTUNE_MESSAGE_STARTED:
|
||||
@ -1167,21 +1167,21 @@ void Copter::FlightMode_AutoTune::update_gcs(uint8_t message_id)
|
||||
}
|
||||
|
||||
// axis helper functions
|
||||
inline bool Copter::FlightMode_AutoTune::roll_enabled() {
|
||||
inline bool Copter::ModeAutoTune::roll_enabled() {
|
||||
return g.autotune_axis_bitmask & AUTOTUNE_AXIS_BITMASK_ROLL;
|
||||
}
|
||||
|
||||
inline bool Copter::FlightMode_AutoTune::pitch_enabled() {
|
||||
inline bool Copter::ModeAutoTune::pitch_enabled() {
|
||||
return g.autotune_axis_bitmask & AUTOTUNE_AXIS_BITMASK_PITCH;
|
||||
}
|
||||
|
||||
inline bool Copter::FlightMode_AutoTune::yaw_enabled() {
|
||||
inline bool Copter::ModeAutoTune::yaw_enabled() {
|
||||
return g.autotune_axis_bitmask & AUTOTUNE_AXIS_BITMASK_YAW;
|
||||
}
|
||||
|
||||
// twitching_test - twitching tests
|
||||
// update min and max and test for end conditions
|
||||
void Copter::FlightMode_AutoTune::twitching_test(float measurement, float target, float &measurement_min, float &measurement_max)
|
||||
void Copter::ModeAutoTune::twitching_test(float measurement, float target, float &measurement_min, float &measurement_max)
|
||||
{
|
||||
// capture maximum measurement
|
||||
if (measurement > measurement_max) {
|
||||
@ -1221,7 +1221,7 @@ void Copter::FlightMode_AutoTune::twitching_test(float measurement, float target
|
||||
|
||||
// updating_d_up - increase D and adjust P to optimize the D term for a little bounce back
|
||||
// optimize D term while keeping the maximum just below the target by adjusting P
|
||||
void Copter::FlightMode_AutoTune::updating_d_up(float &tune_d, float tune_d_min, float tune_d_max, float tune_d_step_ratio, float &tune_p, float tune_p_min, float tune_p_max, float tune_p_step_ratio, float target, float measurement_min, float measurement_max)
|
||||
void Copter::ModeAutoTune::updating_d_up(float &tune_d, float tune_d_min, float tune_d_max, float tune_d_step_ratio, float &tune_p, float tune_p_min, float tune_p_max, float tune_p_step_ratio, float target, float measurement_min, float measurement_max)
|
||||
{
|
||||
if (measurement_max > target) {
|
||||
// if maximum measurement was higher than target
|
||||
@ -1276,7 +1276,7 @@ void Copter::FlightMode_AutoTune::updating_d_up(float &tune_d, float tune_d_min,
|
||||
|
||||
// updating_d_down - decrease D and adjust P to optimize the D term for no bounce back
|
||||
// optimize D term while keeping the maximum just below the target by adjusting P
|
||||
void Copter::FlightMode_AutoTune::updating_d_down(float &tune_d, float tune_d_min, float tune_d_step_ratio, float &tune_p, float tune_p_min, float tune_p_max, float tune_p_step_ratio, float target, float measurement_min, float measurement_max)
|
||||
void Copter::ModeAutoTune::updating_d_down(float &tune_d, float tune_d_min, float tune_d_step_ratio, float &tune_p, float tune_p_min, float tune_p_max, float tune_p_step_ratio, float target, float measurement_min, float measurement_max)
|
||||
{
|
||||
if (measurement_max > target) {
|
||||
// if maximum measurement was higher than target
|
||||
@ -1331,7 +1331,7 @@ void Copter::FlightMode_AutoTune::updating_d_down(float &tune_d, float tune_d_mi
|
||||
|
||||
// updating_p_down - decrease P until we don't reach the target before time out
|
||||
// P is decreased to ensure we are not overshooting the target
|
||||
void Copter::FlightMode_AutoTune::updating_p_down(float &tune_p, float tune_p_min, float tune_p_step_ratio, float target, float measurement_max)
|
||||
void Copter::ModeAutoTune::updating_p_down(float &tune_p, float tune_p_min, float tune_p_step_ratio, float target, float measurement_max)
|
||||
{
|
||||
if (measurement_max < target*(1+0.5f*g.autotune_aggressiveness)) {
|
||||
if (ignore_next == false) {
|
||||
@ -1360,7 +1360,7 @@ void Copter::FlightMode_AutoTune::updating_p_down(float &tune_p, float tune_p_mi
|
||||
|
||||
// updating_p_up - increase P to ensure the target is reached
|
||||
// P is increased until we achieve our target within a reasonable time
|
||||
void Copter::FlightMode_AutoTune::updating_p_up(float &tune_p, float tune_p_max, float tune_p_step_ratio, float target, float measurement_max)
|
||||
void Copter::ModeAutoTune::updating_p_up(float &tune_p, float tune_p_max, float tune_p_step_ratio, float target, float measurement_max)
|
||||
{
|
||||
if (measurement_max > target*(1+0.5f*g.autotune_aggressiveness)) {
|
||||
// ignore the next result unless it is the same as this one
|
||||
@ -1389,7 +1389,7 @@ void Copter::FlightMode_AutoTune::updating_p_up(float &tune_p, float tune_p_max,
|
||||
|
||||
// updating_p_up - increase P to ensure the target is reached while checking bounce back isn't increasing
|
||||
// P is increased until we achieve our target within a reasonable time while reducing D if bounce back increases above the threshold
|
||||
void Copter::FlightMode_AutoTune::updating_p_up_d_down(float &tune_d, float tune_d_min, float tune_d_step_ratio, float &tune_p, float tune_p_min, float tune_p_max, float tune_p_step_ratio, float target, float measurement_min, float measurement_max)
|
||||
void Copter::ModeAutoTune::updating_p_up_d_down(float &tune_d, float tune_d_min, float tune_d_step_ratio, float &tune_p, float tune_p_min, float tune_p_max, float tune_p_step_ratio, float target, float measurement_min, float measurement_max)
|
||||
{
|
||||
if (measurement_max > target*(1+0.5f*g.autotune_aggressiveness)) {
|
||||
// ignore the next result unless it is the same as this one
|
||||
@ -1438,7 +1438,7 @@ void Copter::FlightMode_AutoTune::updating_p_up_d_down(float &tune_d, float tune
|
||||
}
|
||||
|
||||
// twitching_measure_acceleration - measure rate of change of measurement
|
||||
void Copter::FlightMode_AutoTune::twitching_measure_acceleration(float &rate_of_change, float rate_measurement, float &rate_measurement_max)
|
||||
void Copter::ModeAutoTune::twitching_measure_acceleration(float &rate_of_change, float rate_measurement, float &rate_measurement_max)
|
||||
{
|
||||
if (rate_measurement_max < rate_measurement) {
|
||||
rate_measurement_max = rate_measurement;
|
||||
@ -1447,7 +1447,7 @@ void Copter::FlightMode_AutoTune::twitching_measure_acceleration(float &rate_of_
|
||||
}
|
||||
|
||||
// get attitude for slow position hold in autotune mode
|
||||
void Copter::FlightMode_AutoTune::get_poshold_attitude(float &roll_cd_out, float &pitch_cd_out, float &yaw_cd_out)
|
||||
void Copter::ModeAutoTune::get_poshold_attitude(float &roll_cd_out, float &pitch_cd_out, float &yaw_cd_out)
|
||||
{
|
||||
roll_cd_out = pitch_cd_out = 0;
|
||||
|
||||
|
@ -10,13 +10,13 @@
|
||||
*/
|
||||
|
||||
// initialise avoid_adsb controller
|
||||
bool Copter::FlightMode_Avoid_ADSB::init(const bool ignore_checks)
|
||||
bool Copter::ModeAvoidADSB::init(const bool ignore_checks)
|
||||
{
|
||||
// re-use guided mode
|
||||
return Copter::FlightMode_Guided::init(ignore_checks);
|
||||
return Copter::ModeGuided::init(ignore_checks);
|
||||
}
|
||||
|
||||
bool Copter::FlightMode_Avoid_ADSB::set_velocity(const Vector3f& velocity_neu)
|
||||
bool Copter::ModeAvoidADSB::set_velocity(const Vector3f& velocity_neu)
|
||||
{
|
||||
// check flight mode
|
||||
if (_copter.control_mode != AVOID_ADSB) {
|
||||
@ -24,15 +24,15 @@ bool Copter::FlightMode_Avoid_ADSB::set_velocity(const Vector3f& velocity_neu)
|
||||
}
|
||||
|
||||
// re-use guided mode's velocity controller
|
||||
Copter::FlightMode_Guided::set_velocity(velocity_neu);
|
||||
Copter::ModeGuided::set_velocity(velocity_neu);
|
||||
return true;
|
||||
}
|
||||
|
||||
// runs the AVOID_ADSB controller
|
||||
void Copter::FlightMode_Avoid_ADSB::run()
|
||||
void Copter::ModeAvoidADSB::run()
|
||||
{
|
||||
// re-use guided mode's velocity controller
|
||||
// Note: this is safe from interference from GCSs and companion computer's whose guided mode
|
||||
// position and velocity requests will be ignored while the vehicle is not in guided mode
|
||||
Copter::FlightMode_Guided::run();
|
||||
Copter::ModeGuided::run();
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
// brake_init - initialise brake controller
|
||||
bool Copter::FlightMode_Brake::init(bool ignore_checks)
|
||||
bool Copter::ModeBrake::init(bool ignore_checks)
|
||||
{
|
||||
if (_copter.position_ok() || ignore_checks) {
|
||||
|
||||
@ -35,7 +35,7 @@ bool Copter::FlightMode_Brake::init(bool ignore_checks)
|
||||
|
||||
// brake_run - runs the brake controller
|
||||
// should be called at 100hz or more
|
||||
void Copter::FlightMode_Brake::run()
|
||||
void Copter::ModeBrake::run()
|
||||
{
|
||||
// if not auto armed set throttle to zero and exit immediately
|
||||
if (!motors->armed() || !ap.auto_armed || !motors->get_interlock()) {
|
||||
@ -85,7 +85,7 @@ void Copter::FlightMode_Brake::run()
|
||||
}
|
||||
}
|
||||
|
||||
void Copter::FlightMode_Brake::timeout_to_loiter_ms(uint32_t timeout_ms)
|
||||
void Copter::ModeBrake::timeout_to_loiter_ms(uint32_t timeout_ms)
|
||||
{
|
||||
_timeout_start = millis();
|
||||
_timeout_ms = timeout_ms;
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
// circle_init - initialise circle controller flight mode
|
||||
bool Copter::FlightMode_Circle::init(bool ignore_checks)
|
||||
bool Copter::ModeCircle::init(bool ignore_checks)
|
||||
{
|
||||
if (_copter.position_ok() || ignore_checks) {
|
||||
pilot_yaw_override = false;
|
||||
@ -28,7 +28,7 @@ bool Copter::FlightMode_Circle::init(bool ignore_checks)
|
||||
|
||||
// circle_run - runs the circle flight mode
|
||||
// should be called at 100hz or more
|
||||
void Copter::FlightMode_Circle::run()
|
||||
void Copter::ModeCircle::run()
|
||||
{
|
||||
float target_yaw_rate = 0;
|
||||
float target_climb_rate = 0;
|
||||
|
@ -27,7 +27,7 @@
|
||||
#endif
|
||||
|
||||
// drift_init - initialise drift controller
|
||||
bool Copter::FlightMode_Drift::init(bool ignore_checks)
|
||||
bool Copter::ModeDrift::init(bool ignore_checks)
|
||||
{
|
||||
if (_copter.position_ok() || ignore_checks) {
|
||||
return true;
|
||||
@ -38,7 +38,7 @@ bool Copter::FlightMode_Drift::init(bool ignore_checks)
|
||||
|
||||
// drift_run - runs the drift controller
|
||||
// should be called at 100hz or more
|
||||
void Copter::FlightMode_Drift::run()
|
||||
void Copter::ModeDrift::run()
|
||||
{
|
||||
static float breaker = 0.0f;
|
||||
static float roll_input = 0.0f;
|
||||
@ -108,7 +108,7 @@ void Copter::FlightMode_Drift::run()
|
||||
}
|
||||
|
||||
// get_throttle_assist - return throttle output (range 0 ~ 1) based on pilot input and z-axis velocity
|
||||
float Copter::FlightMode_Drift::get_throttle_assist(float velz, float pilot_throttle_scaled)
|
||||
float Copter::ModeDrift::get_throttle_assist(float velz, float pilot_throttle_scaled)
|
||||
{
|
||||
// throttle assist - adjusts throttle to slow the vehicle's vertical velocity
|
||||
// Only active when pilot's throttle is between 213 ~ 787
|
||||
|
@ -38,7 +38,7 @@ int8_t flip_roll_dir; // roll direction (-1 = roll left, 1 = roll
|
||||
int8_t flip_pitch_dir; // pitch direction (-1 = pitch forward, 1 = pitch back)
|
||||
|
||||
// flip_init - initialise flip controller
|
||||
bool Copter::FlightMode_Flip::init(bool ignore_checks)
|
||||
bool Copter::ModeFlip::init(bool ignore_checks)
|
||||
{
|
||||
// only allow flip from ACRO, Stabilize, AltHold or Drift flight modes
|
||||
if (_copter.control_mode != ACRO && _copter.control_mode != STABILIZE && _copter.control_mode != ALT_HOLD) {
|
||||
@ -94,7 +94,7 @@ bool Copter::FlightMode_Flip::init(bool ignore_checks)
|
||||
|
||||
// flip_run - runs the flip controller
|
||||
// should be called at 100hz or more
|
||||
void Copter::FlightMode_Flip::run()
|
||||
void Copter::ModeFlip::run()
|
||||
{
|
||||
float throttle_out;
|
||||
float recovery_angle;
|
||||
|
@ -36,7 +36,7 @@ struct Guided_Limit {
|
||||
} guided_limit;
|
||||
|
||||
// guided_init - initialise guided controller
|
||||
bool Copter::FlightMode_Guided::init(bool ignore_checks)
|
||||
bool Copter::ModeGuided::init(bool ignore_checks)
|
||||
{
|
||||
if (_copter.position_ok() || ignore_checks) {
|
||||
// initialise yaw
|
||||
@ -51,7 +51,7 @@ bool Copter::FlightMode_Guided::init(bool ignore_checks)
|
||||
|
||||
|
||||
// guided_takeoff_start - initialises waypoint controller to implement take-off
|
||||
bool Copter::FlightMode_Guided::takeoff_start(float final_alt_above_home)
|
||||
bool Copter::ModeGuided::takeoff_start(float final_alt_above_home)
|
||||
{
|
||||
guided_mode = Guided_TakeOff;
|
||||
|
||||
@ -79,7 +79,7 @@ bool Copter::FlightMode_Guided::takeoff_start(float final_alt_above_home)
|
||||
}
|
||||
|
||||
// initialise guided mode's position controller
|
||||
void Copter::FlightMode_Guided::pos_control_start()
|
||||
void Copter::ModeGuided::pos_control_start()
|
||||
{
|
||||
// set to position control mode
|
||||
guided_mode = Guided_WP;
|
||||
@ -99,7 +99,7 @@ void Copter::FlightMode_Guided::pos_control_start()
|
||||
}
|
||||
|
||||
// initialise guided mode's velocity controller
|
||||
void Copter::FlightMode_Guided::vel_control_start()
|
||||
void Copter::ModeGuided::vel_control_start()
|
||||
{
|
||||
// set guided_mode to velocity controller
|
||||
guided_mode = Guided_Velocity;
|
||||
@ -118,7 +118,7 @@ void Copter::FlightMode_Guided::vel_control_start()
|
||||
}
|
||||
|
||||
// initialise guided mode's posvel controller
|
||||
void Copter::FlightMode_Guided::posvel_control_start()
|
||||
void Copter::ModeGuided::posvel_control_start()
|
||||
{
|
||||
// set guided_mode to velocity controller
|
||||
guided_mode = Guided_PosVel;
|
||||
@ -146,7 +146,7 @@ void Copter::FlightMode_Guided::posvel_control_start()
|
||||
}
|
||||
|
||||
// initialise guided mode's angle controller
|
||||
void Copter::FlightMode_Guided::angle_control_start()
|
||||
void Copter::ModeGuided::angle_control_start()
|
||||
{
|
||||
// set guided_mode to velocity controller
|
||||
guided_mode = Guided_Angle;
|
||||
@ -177,7 +177,7 @@ void Copter::FlightMode_Guided::angle_control_start()
|
||||
// guided_set_destination - sets guided mode's target destination
|
||||
// Returns true if the fence is enabled and guided waypoint is within the fence
|
||||
// else return false if the waypoint is outside the fence
|
||||
bool Copter::FlightMode_Guided::set_destination(const Vector3f& destination, bool use_yaw, float yaw_cd, bool use_yaw_rate, float yaw_rate_cds, bool relative_yaw)
|
||||
bool Copter::ModeGuided::set_destination(const Vector3f& destination, bool use_yaw, float yaw_cd, bool use_yaw_rate, float yaw_rate_cds, bool relative_yaw)
|
||||
{
|
||||
// ensure we are in position control mode
|
||||
if (guided_mode != Guided_WP) {
|
||||
@ -208,7 +208,7 @@ bool Copter::FlightMode_Guided::set_destination(const Vector3f& destination, boo
|
||||
// sets guided mode's target from a Location object
|
||||
// returns false if destination could not be set (probably caused by missing terrain data)
|
||||
// or if the fence is enabled and guided waypoint is outside the fence
|
||||
bool Copter::FlightMode_Guided::set_destination(const Location_Class& dest_loc, bool use_yaw, float yaw_cd, bool use_yaw_rate, float yaw_rate_cds, bool relative_yaw)
|
||||
bool Copter::ModeGuided::set_destination(const Location_Class& dest_loc, bool use_yaw, float yaw_cd, bool use_yaw_rate, float yaw_rate_cds, bool relative_yaw)
|
||||
{
|
||||
// ensure we are in position control mode
|
||||
if (guided_mode != Guided_WP) {
|
||||
@ -241,7 +241,7 @@ bool Copter::FlightMode_Guided::set_destination(const Location_Class& dest_loc,
|
||||
}
|
||||
|
||||
// guided_set_velocity - sets guided mode's target velocity
|
||||
void Copter::FlightMode_Guided::set_velocity(const Vector3f& velocity, bool use_yaw, float yaw_cd, bool use_yaw_rate, float yaw_rate_cds, bool relative_yaw)
|
||||
void Copter::ModeGuided::set_velocity(const Vector3f& velocity, bool use_yaw, float yaw_cd, bool use_yaw_rate, float yaw_rate_cds, bool relative_yaw)
|
||||
{
|
||||
// check we are in velocity control mode
|
||||
if (guided_mode != Guided_Velocity) {
|
||||
@ -260,7 +260,7 @@ void Copter::FlightMode_Guided::set_velocity(const Vector3f& velocity, bool use_
|
||||
}
|
||||
|
||||
// set guided mode posvel target
|
||||
bool Copter::FlightMode_Guided::set_destination_posvel(const Vector3f& destination, const Vector3f& velocity, bool use_yaw, float yaw_cd, bool use_yaw_rate, float yaw_rate_cds, bool relative_yaw)
|
||||
bool Copter::ModeGuided::set_destination_posvel(const Vector3f& destination, const Vector3f& velocity, bool use_yaw, float yaw_cd, bool use_yaw_rate, float yaw_rate_cds, bool relative_yaw)
|
||||
{
|
||||
// check we are in velocity control mode
|
||||
if (guided_mode != Guided_PosVel) {
|
||||
@ -292,7 +292,7 @@ bool Copter::FlightMode_Guided::set_destination_posvel(const Vector3f& destinati
|
||||
}
|
||||
|
||||
// set guided mode angle target
|
||||
void Copter::FlightMode_Guided::set_angle(const Quaternion &q, float climb_rate_cms, bool use_yaw_rate, float yaw_rate_rads)
|
||||
void Copter::ModeGuided::set_angle(const Quaternion &q, float climb_rate_cms, bool use_yaw_rate, float yaw_rate_rads)
|
||||
{
|
||||
// check we are in velocity control mode
|
||||
if (guided_mode != Guided_Angle) {
|
||||
@ -323,7 +323,7 @@ void Copter::FlightMode_Guided::set_angle(const Quaternion &q, float climb_rate_
|
||||
|
||||
// guided_run - runs the guided controller
|
||||
// should be called at 100hz or more
|
||||
void Copter::FlightMode_Guided::run()
|
||||
void Copter::ModeGuided::run()
|
||||
{
|
||||
// call the correct auto controller
|
||||
switch (guided_mode) {
|
||||
@ -357,7 +357,7 @@ void Copter::FlightMode_Guided::run()
|
||||
|
||||
// guided_takeoff_run - takeoff in guided mode
|
||||
// called by guided_run at 100hz or more
|
||||
void Copter::FlightMode_Guided::takeoff_run()
|
||||
void Copter::ModeGuided::takeoff_run()
|
||||
{
|
||||
// if not auto armed or motor interlock not enabled set throttle to zero and exit immediately
|
||||
if (!motors->armed() || !ap.auto_armed || !motors->get_interlock()) {
|
||||
@ -411,7 +411,7 @@ void Copter::FlightMode_Guided::takeoff_run()
|
||||
|
||||
// guided_pos_control_run - runs the guided position controller
|
||||
// called from guided_run
|
||||
void Copter::FlightMode_Guided::pos_control_run()
|
||||
void Copter::ModeGuided::pos_control_run()
|
||||
{
|
||||
// if not auto armed or motors not enabled set throttle to zero and exit immediately
|
||||
if (!motors->armed() || !ap.auto_armed || !motors->get_interlock() || ap.land_complete) {
|
||||
@ -461,7 +461,7 @@ void Copter::FlightMode_Guided::pos_control_run()
|
||||
|
||||
// guided_vel_control_run - runs the guided velocity controller
|
||||
// called from guided_run
|
||||
void Copter::FlightMode_Guided::vel_control_run()
|
||||
void Copter::ModeGuided::vel_control_run()
|
||||
{
|
||||
// if not auto armed or motors not enabled set throttle to zero and exit immediately
|
||||
if (!motors->armed() || !ap.auto_armed || !motors->get_interlock() || ap.land_complete) {
|
||||
@ -523,7 +523,7 @@ void Copter::FlightMode_Guided::vel_control_run()
|
||||
|
||||
// guided_posvel_control_run - runs the guided spline controller
|
||||
// called from guided_run
|
||||
void Copter::FlightMode_Guided::posvel_control_run()
|
||||
void Copter::ModeGuided::posvel_control_run()
|
||||
{
|
||||
// if not auto armed or motors not enabled set throttle to zero and exit immediately
|
||||
if (!motors->armed() || !ap.auto_armed || !motors->get_interlock() || ap.land_complete) {
|
||||
@ -603,7 +603,7 @@ void Copter::FlightMode_Guided::posvel_control_run()
|
||||
|
||||
// guided_angle_control_run - runs the guided angle controller
|
||||
// called from guided_run
|
||||
void Copter::FlightMode_Guided::angle_control_run()
|
||||
void Copter::ModeGuided::angle_control_run()
|
||||
{
|
||||
// if not auto armed or motors not enabled set throttle to zero and exit immediately
|
||||
if (!motors->armed() || !ap.auto_armed || !motors->get_interlock() || (ap.land_complete && guided_angle_state.climb_rate_cms <= 0.0f)) {
|
||||
@ -667,7 +667,7 @@ void Copter::FlightMode_Guided::angle_control_run()
|
||||
}
|
||||
|
||||
// helper function to update position controller's desired velocity while respecting acceleration limits
|
||||
void Copter::FlightMode_Guided::set_desired_velocity_with_accel_and_fence_limits(const Vector3f& vel_des)
|
||||
void Copter::ModeGuided::set_desired_velocity_with_accel_and_fence_limits(const Vector3f& vel_des)
|
||||
{
|
||||
// get current desired velocity
|
||||
Vector3f curr_vel_des = pos_control->get_desired_velocity();
|
||||
@ -701,7 +701,7 @@ void Copter::FlightMode_Guided::set_desired_velocity_with_accel_and_fence_limits
|
||||
}
|
||||
|
||||
// helper function to set yaw state and targets
|
||||
void Copter::FlightMode_Guided::set_yaw_state(bool use_yaw, float yaw_cd, bool use_yaw_rate, float yaw_rate_cds, bool relative_angle)
|
||||
void Copter::ModeGuided::set_yaw_state(bool use_yaw, float yaw_cd, bool use_yaw_rate, float yaw_rate_cds, bool relative_angle)
|
||||
{
|
||||
if (use_yaw) {
|
||||
set_auto_yaw_look_at_heading(yaw_cd / 100.0f, 0.0f, 0, relative_angle);
|
||||
@ -713,7 +713,7 @@ void Copter::FlightMode_Guided::set_yaw_state(bool use_yaw, float yaw_cd, bool u
|
||||
// Guided Limit code
|
||||
|
||||
// guided_limit_clear - clear/turn off guided limits
|
||||
void Copter::FlightMode_Guided::limit_clear()
|
||||
void Copter::ModeGuided::limit_clear()
|
||||
{
|
||||
guided_limit.timeout_ms = 0;
|
||||
guided_limit.alt_min_cm = 0.0f;
|
||||
@ -722,7 +722,7 @@ void Copter::FlightMode_Guided::limit_clear()
|
||||
}
|
||||
|
||||
// guided_limit_set - set guided timeout and movement limits
|
||||
void Copter::FlightMode_Guided::limit_set(uint32_t timeout_ms, float alt_min_cm, float alt_max_cm, float horiz_max_cm)
|
||||
void Copter::ModeGuided::limit_set(uint32_t timeout_ms, float alt_min_cm, float alt_max_cm, float horiz_max_cm)
|
||||
{
|
||||
guided_limit.timeout_ms = timeout_ms;
|
||||
guided_limit.alt_min_cm = alt_min_cm;
|
||||
@ -732,7 +732,7 @@ void Copter::FlightMode_Guided::limit_set(uint32_t timeout_ms, float alt_min_cm,
|
||||
|
||||
// guided_limit_init_time_and_pos - initialise guided start time and position as reference for limit checking
|
||||
// only called from AUTO mode's auto_nav_guided_start function
|
||||
void Copter::FlightMode_Guided::limit_init_time_and_pos()
|
||||
void Copter::ModeGuided::limit_init_time_and_pos()
|
||||
{
|
||||
// initialise start time
|
||||
guided_limit.start_time = AP_HAL::millis();
|
||||
@ -743,7 +743,7 @@ void Copter::FlightMode_Guided::limit_init_time_and_pos()
|
||||
|
||||
// guided_limit_check - returns true if guided mode has breached a limit
|
||||
// used when guided is invoked from the NAV_GUIDED_ENABLE mission command
|
||||
bool Copter::FlightMode_Guided::limit_check()
|
||||
bool Copter::ModeGuided::limit_check()
|
||||
{
|
||||
// check if we have passed the timeout
|
||||
if ((guided_limit.timeout_ms > 0) && (millis() - guided_limit.start_time >= guided_limit.timeout_ms)) {
|
||||
@ -776,7 +776,7 @@ bool Copter::FlightMode_Guided::limit_check()
|
||||
}
|
||||
|
||||
|
||||
uint32_t Copter::FlightMode_Guided::wp_distance() const
|
||||
uint32_t Copter::ModeGuided::wp_distance() const
|
||||
{
|
||||
switch(mode()) {
|
||||
case Guided_WP:
|
||||
@ -790,7 +790,7 @@ uint32_t Copter::FlightMode_Guided::wp_distance() const
|
||||
}
|
||||
}
|
||||
|
||||
int32_t Copter::FlightMode_Guided::wp_bearing() const
|
||||
int32_t Copter::ModeGuided::wp_bearing() const
|
||||
{
|
||||
switch(mode()) {
|
||||
case Guided_WP:
|
||||
|
@ -5,17 +5,17 @@
|
||||
*/
|
||||
|
||||
// initialise guided_nogps controller
|
||||
bool Copter::FlightMode_Guided_NoGPS::init(bool ignore_checks)
|
||||
bool Copter::ModeGuidedNoGPS::init(bool ignore_checks)
|
||||
{
|
||||
// start in angle control mode
|
||||
Copter::FlightMode_Guided::angle_control_start();
|
||||
Copter::ModeGuided::angle_control_start();
|
||||
return true;
|
||||
}
|
||||
|
||||
// guided_run - runs the guided controller
|
||||
// should be called at 100hz or more
|
||||
void Copter::FlightMode_Guided_NoGPS::run()
|
||||
void Copter::ModeGuidedNoGPS::run()
|
||||
{
|
||||
// run angle controller
|
||||
Copter::FlightMode_Guided::angle_control_run();
|
||||
Copter::ModeGuided::angle_control_run();
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ static uint32_t land_start_time;
|
||||
static bool land_pause;
|
||||
|
||||
// land_init - initialise land controller
|
||||
bool Copter::FlightMode_Land::init(bool ignore_checks)
|
||||
bool Copter::ModeLand::init(bool ignore_checks)
|
||||
{
|
||||
// check if we have GPS and decide which LAND we're going to do
|
||||
land_with_gps = _copter.position_ok();
|
||||
@ -40,7 +40,7 @@ bool Copter::FlightMode_Land::init(bool ignore_checks)
|
||||
|
||||
// land_run - runs the land controller
|
||||
// should be called at 100hz or more
|
||||
void Copter::FlightMode_Land::run()
|
||||
void Copter::ModeLand::run()
|
||||
{
|
||||
if (land_with_gps) {
|
||||
gps_run();
|
||||
@ -52,7 +52,7 @@ void Copter::FlightMode_Land::run()
|
||||
// land_gps_run - runs the land controller
|
||||
// horizontal position controlled with loiter controller
|
||||
// should be called at 100hz or more
|
||||
void Copter::FlightMode_Land::gps_run()
|
||||
void Copter::ModeLand::gps_run()
|
||||
{
|
||||
// if not auto armed or landed or motor interlock not enabled set throttle to zero and exit immediately
|
||||
if (!motors->armed() || !ap.auto_armed || ap.land_complete || !motors->get_interlock()) {
|
||||
@ -89,7 +89,7 @@ void Copter::FlightMode_Land::gps_run()
|
||||
// land_nogps_run - runs the land controller
|
||||
// pilot controls roll and pitch angles
|
||||
// should be called at 100hz or more
|
||||
void Copter::FlightMode_Land::nogps_run()
|
||||
void Copter::ModeLand::nogps_run()
|
||||
{
|
||||
float target_roll = 0.0f, target_pitch = 0.0f;
|
||||
float target_yaw_rate = 0;
|
||||
@ -150,7 +150,7 @@ void Copter::FlightMode_Land::nogps_run()
|
||||
/*
|
||||
get a height above ground estimate for landing
|
||||
*/
|
||||
int32_t Copter::FlightMode_Land::get_alt_above_ground(void)
|
||||
int32_t Copter::ModeLand::get_alt_above_ground(void)
|
||||
{
|
||||
int32_t alt_above_ground;
|
||||
if (_copter.rangefinder_alt_ok()) {
|
||||
@ -303,7 +303,7 @@ void Copter::land_run_horizontal_control()
|
||||
// do_not_use_GPS - forces land-mode to not use the GPS but instead rely on pilot input for roll and pitch
|
||||
// called during GPS failsafe to ensure that if we were already in LAND mode that we do not use the GPS
|
||||
// has no effect if we are not already in LAND mode
|
||||
void Copter::FlightMode_Land::do_not_use_GPS()
|
||||
void Copter::ModeLand::do_not_use_GPS()
|
||||
{
|
||||
land_with_gps = false;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
// loiter_init - initialise loiter controller
|
||||
bool Copter::FlightMode_Loiter::init(bool ignore_checks)
|
||||
bool Copter::ModeLoiter::init(bool ignore_checks)
|
||||
{
|
||||
if (_copter.position_ok() || ignore_checks) {
|
||||
|
||||
@ -29,7 +29,7 @@ bool Copter::FlightMode_Loiter::init(bool ignore_checks)
|
||||
}
|
||||
|
||||
#if PRECISION_LANDING == ENABLED
|
||||
bool Copter::FlightMode_Loiter::do_precision_loiter()
|
||||
bool Copter::ModeLoiter::do_precision_loiter()
|
||||
{
|
||||
if (!_precision_loiter_enabled) {
|
||||
return false;
|
||||
@ -47,7 +47,7 @@ bool Copter::FlightMode_Loiter::do_precision_loiter()
|
||||
return true;
|
||||
}
|
||||
|
||||
void Copter::FlightMode_Loiter::precision_loiter_xy()
|
||||
void Copter::ModeLoiter::precision_loiter_xy()
|
||||
{
|
||||
wp_nav->clear_pilot_desired_acceleration();
|
||||
Vector2f target_pos, target_vel_rel;
|
||||
@ -66,7 +66,7 @@ void Copter::FlightMode_Loiter::precision_loiter_xy()
|
||||
|
||||
// loiter_run - runs the loiter controller
|
||||
// should be called at 100hz or more
|
||||
void Copter::FlightMode_Loiter::run()
|
||||
void Copter::ModeLoiter::run()
|
||||
{
|
||||
LoiterModeState loiter_state;
|
||||
float target_yaw_rate = 0.0f;
|
||||
|
@ -71,7 +71,7 @@ static struct {
|
||||
} poshold;
|
||||
|
||||
// poshold_init - initialise PosHold controller
|
||||
bool Copter::FlightMode_PosHold::init(bool ignore_checks)
|
||||
bool Copter::ModePosHold::init(bool ignore_checks)
|
||||
{
|
||||
// fail to initialise PosHold mode if no GPS lock
|
||||
if (!_copter.position_ok() && !ignore_checks) {
|
||||
@ -122,7 +122,7 @@ bool Copter::FlightMode_PosHold::init(bool ignore_checks)
|
||||
|
||||
// poshold_run - runs the PosHold controller
|
||||
// should be called at 100hz or more
|
||||
void Copter::FlightMode_PosHold::run()
|
||||
void Copter::ModePosHold::run()
|
||||
{
|
||||
float target_roll, target_pitch; // pilot's roll and pitch angle inputs
|
||||
float target_yaw_rate = 0; // pilot desired yaw rate in centi-degrees/sec
|
||||
@ -542,7 +542,7 @@ void Copter::FlightMode_PosHold::run()
|
||||
}
|
||||
|
||||
// poshold_update_pilot_lean_angle - update the pilot's filtered lean angle with the latest raw input received
|
||||
void Copter::FlightMode_PosHold::poshold_update_pilot_lean_angle(float &lean_angle_filtered, float &lean_angle_raw)
|
||||
void Copter::ModePosHold::poshold_update_pilot_lean_angle(float &lean_angle_filtered, float &lean_angle_raw)
|
||||
{
|
||||
// if raw input is large or reversing the vehicle's lean angle immediately set the fitlered angle to the new raw angle
|
||||
if ((lean_angle_filtered > 0 && lean_angle_raw < 0) || (lean_angle_filtered < 0 && lean_angle_raw > 0) || (fabsf(lean_angle_raw) > POSHOLD_STICK_RELEASE_SMOOTH_ANGLE)) {
|
||||
@ -564,7 +564,7 @@ void Copter::FlightMode_PosHold::poshold_update_pilot_lean_angle(float &lean_ang
|
||||
|
||||
// poshold_mix_controls - mixes two controls based on the mix_ratio
|
||||
// mix_ratio of 1 = use first_control completely, 0 = use second_control completely, 0.5 = mix evenly
|
||||
int16_t Copter::FlightMode_PosHold::poshold_mix_controls(float mix_ratio, int16_t first_control, int16_t second_control)
|
||||
int16_t Copter::ModePosHold::poshold_mix_controls(float mix_ratio, int16_t first_control, int16_t second_control)
|
||||
{
|
||||
mix_ratio = constrain_float(mix_ratio, 0.0f, 1.0f);
|
||||
return (int16_t)((mix_ratio * first_control) + ((1.0f-mix_ratio)*second_control));
|
||||
@ -573,7 +573,7 @@ int16_t Copter::FlightMode_PosHold::poshold_mix_controls(float mix_ratio, int16_
|
||||
// poshold_update_brake_angle_from_velocity - updates the brake_angle based on the vehicle's velocity and brake_gain
|
||||
// brake_angle is slewed with the wpnav.poshold_brake_rate and constrained by the wpnav.poshold_braking_angle_max
|
||||
// velocity is assumed to be in the same direction as lean angle so for pitch you should provide the velocity backwards (i.e. -ve forward velocity)
|
||||
void Copter::FlightMode_PosHold::poshold_update_brake_angle_from_velocity(int16_t &brake_angle, float velocity)
|
||||
void Copter::ModePosHold::poshold_update_brake_angle_from_velocity(int16_t &brake_angle, float velocity)
|
||||
{
|
||||
float lean_angle;
|
||||
int16_t brake_rate = g.poshold_brake_rate;
|
||||
@ -599,7 +599,7 @@ void Copter::FlightMode_PosHold::poshold_update_brake_angle_from_velocity(int16_
|
||||
|
||||
// poshold_update_wind_comp_estimate - updates wind compensation estimate
|
||||
// should be called at the maximum loop rate when loiter is engaged
|
||||
void Copter::FlightMode_PosHold::poshold_update_wind_comp_estimate()
|
||||
void Copter::ModePosHold::poshold_update_wind_comp_estimate()
|
||||
{
|
||||
// check wind estimate start has not been delayed
|
||||
if (poshold.wind_comp_start_timer > 0) {
|
||||
@ -635,7 +635,7 @@ void Copter::FlightMode_PosHold::poshold_update_wind_comp_estimate()
|
||||
|
||||
// poshold_get_wind_comp_lean_angles - retrieve wind compensation angles in body frame roll and pitch angles
|
||||
// should be called at the maximum loop rate
|
||||
void Copter::FlightMode_PosHold::poshold_get_wind_comp_lean_angles(int16_t &roll_angle, int16_t &pitch_angle)
|
||||
void Copter::ModePosHold::poshold_get_wind_comp_lean_angles(int16_t &roll_angle, int16_t &pitch_angle)
|
||||
{
|
||||
// reduce rate to 10hz
|
||||
poshold.wind_comp_timer++;
|
||||
@ -650,7 +650,7 @@ void Copter::FlightMode_PosHold::poshold_get_wind_comp_lean_angles(int16_t &roll
|
||||
}
|
||||
|
||||
// poshold_roll_controller_to_pilot_override - initialises transition from a controller submode (brake or loiter) to a pilot override on roll axis
|
||||
void Copter::FlightMode_PosHold::poshold_roll_controller_to_pilot_override()
|
||||
void Copter::ModePosHold::poshold_roll_controller_to_pilot_override()
|
||||
{
|
||||
poshold.roll_mode = POSHOLD_CONTROLLER_TO_PILOT_OVERRIDE;
|
||||
poshold.controller_to_pilot_timer_roll = POSHOLD_CONTROLLER_TO_PILOT_MIX_TIMER;
|
||||
@ -661,7 +661,7 @@ void Copter::FlightMode_PosHold::poshold_roll_controller_to_pilot_override()
|
||||
}
|
||||
|
||||
// poshold_pitch_controller_to_pilot_override - initialises transition from a controller submode (brake or loiter) to a pilot override on roll axis
|
||||
void Copter::FlightMode_PosHold::poshold_pitch_controller_to_pilot_override()
|
||||
void Copter::ModePosHold::poshold_pitch_controller_to_pilot_override()
|
||||
{
|
||||
poshold.pitch_mode = POSHOLD_CONTROLLER_TO_PILOT_OVERRIDE;
|
||||
poshold.controller_to_pilot_timer_pitch = POSHOLD_CONTROLLER_TO_PILOT_MIX_TIMER;
|
||||
|
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
// rtl_init - initialise rtl controller
|
||||
bool Copter::FlightMode_RTL::init(bool ignore_checks)
|
||||
bool Copter::ModeRTL::init(bool ignore_checks)
|
||||
{
|
||||
if (_copter.position_ok() || ignore_checks) {
|
||||
// initialise waypoint and spline controller
|
||||
@ -22,7 +22,7 @@ bool Copter::FlightMode_RTL::init(bool ignore_checks)
|
||||
}
|
||||
|
||||
// re-start RTL with terrain following disabled
|
||||
void Copter::FlightMode_RTL::restart_without_terrain()
|
||||
void Copter::ModeRTL::restart_without_terrain()
|
||||
{
|
||||
// log an error
|
||||
_copter.Log_Write_Error(ERROR_SUBSYSTEM_NAVIGATION, ERROR_CODE_RESTARTED_RTL);
|
||||
@ -35,7 +35,7 @@ void Copter::FlightMode_RTL::restart_without_terrain()
|
||||
|
||||
// rtl_run - runs the return-to-launch controller
|
||||
// should be called at 100hz or more
|
||||
void Copter::FlightMode_RTL::run(bool disarm_on_land)
|
||||
void Copter::ModeRTL::run(bool disarm_on_land)
|
||||
{
|
||||
// check if we need to move to next state
|
||||
if (_state_complete) {
|
||||
@ -88,7 +88,7 @@ void Copter::FlightMode_RTL::run(bool disarm_on_land)
|
||||
}
|
||||
|
||||
// rtl_climb_start - initialise climb to RTL altitude
|
||||
void Copter::FlightMode_RTL::climb_start()
|
||||
void Copter::ModeRTL::climb_start()
|
||||
{
|
||||
_state = RTL_InitialClimb;
|
||||
_state_complete = false;
|
||||
@ -112,7 +112,7 @@ void Copter::FlightMode_RTL::climb_start()
|
||||
}
|
||||
|
||||
// rtl_return_start - initialise return to home
|
||||
void Copter::FlightMode_RTL::return_start()
|
||||
void Copter::ModeRTL::return_start()
|
||||
{
|
||||
_state = RTL_ReturnHome;
|
||||
_state_complete = false;
|
||||
@ -128,7 +128,7 @@ void Copter::FlightMode_RTL::return_start()
|
||||
|
||||
// rtl_climb_return_run - implements the initial climb, return home and descent portions of RTL which all rely on the wp controller
|
||||
// called by rtl_run at 100hz or more
|
||||
void Copter::FlightMode_RTL::climb_return_run()
|
||||
void Copter::ModeRTL::climb_return_run()
|
||||
{
|
||||
// if not auto armed or motor interlock not enabled set throttle to zero and exit immediately
|
||||
if (!motors->armed() || !ap.auto_armed || !motors->get_interlock()) {
|
||||
@ -179,7 +179,7 @@ void Copter::FlightMode_RTL::climb_return_run()
|
||||
}
|
||||
|
||||
// rtl_loiterathome_start - initialise return to home
|
||||
void Copter::FlightMode_RTL::loiterathome_start()
|
||||
void Copter::ModeRTL::loiterathome_start()
|
||||
{
|
||||
_state = RTL_LoiterAtHome;
|
||||
_state_complete = false;
|
||||
@ -195,7 +195,7 @@ void Copter::FlightMode_RTL::loiterathome_start()
|
||||
|
||||
// rtl_climb_return_descent_run - implements the initial climb, return home and descent portions of RTL which all rely on the wp controller
|
||||
// called by rtl_run at 100hz or more
|
||||
void Copter::FlightMode_RTL::loiterathome_run()
|
||||
void Copter::ModeRTL::loiterathome_run()
|
||||
{
|
||||
// if not auto armed or motor interlock not enabled set throttle to zero and exit immediately
|
||||
if (!motors->armed() || !ap.auto_armed || !motors->get_interlock()) {
|
||||
@ -256,7 +256,7 @@ void Copter::FlightMode_RTL::loiterathome_run()
|
||||
}
|
||||
|
||||
// rtl_descent_start - initialise descent to final alt
|
||||
void Copter::FlightMode_RTL::descent_start()
|
||||
void Copter::ModeRTL::descent_start()
|
||||
{
|
||||
_state = RTL_FinalDescent;
|
||||
_state_complete = false;
|
||||
@ -273,7 +273,7 @@ void Copter::FlightMode_RTL::descent_start()
|
||||
|
||||
// rtl_descent_run - implements the final descent to the RTL_ALT
|
||||
// called by rtl_run at 100hz or more
|
||||
void Copter::FlightMode_RTL::descent_run()
|
||||
void Copter::ModeRTL::descent_run()
|
||||
{
|
||||
int16_t roll_control = 0, pitch_control = 0;
|
||||
float target_yaw_rate = 0;
|
||||
@ -338,7 +338,7 @@ void Copter::FlightMode_RTL::descent_run()
|
||||
}
|
||||
|
||||
// rtl_loiterathome_start - initialise controllers to loiter over home
|
||||
void Copter::FlightMode_RTL::land_start()
|
||||
void Copter::ModeRTL::land_start()
|
||||
{
|
||||
_state = RTL_Land;
|
||||
_state_complete = false;
|
||||
@ -356,7 +356,7 @@ void Copter::FlightMode_RTL::land_start()
|
||||
set_auto_yaw_mode(AUTO_YAW_HOLD);
|
||||
}
|
||||
|
||||
bool Copter::FlightMode_RTL::landing_gear_should_be_deployed()
|
||||
bool Copter::ModeRTL::landing_gear_should_be_deployed()
|
||||
{
|
||||
switch(_state) {
|
||||
case RTL_LoiterAtHome:
|
||||
@ -371,7 +371,7 @@ bool Copter::FlightMode_RTL::landing_gear_should_be_deployed()
|
||||
|
||||
// rtl_returnhome_run - return home
|
||||
// called by rtl_run at 100hz or more
|
||||
void Copter::FlightMode_RTL::land_run(bool disarm_on_land)
|
||||
void Copter::ModeRTL::land_run(bool disarm_on_land)
|
||||
{
|
||||
// if not auto armed or landing completed or motor interlock not enabled set throttle to zero and exit immediately
|
||||
if (!motors->armed() || !ap.auto_armed || ap.land_complete || !motors->get_interlock()) {
|
||||
@ -407,7 +407,7 @@ void Copter::FlightMode_RTL::land_run(bool disarm_on_land)
|
||||
_state_complete = ap.land_complete;
|
||||
}
|
||||
|
||||
void Copter::FlightMode_RTL::build_path(bool terrain_following_allowed)
|
||||
void Copter::ModeRTL::build_path(bool terrain_following_allowed)
|
||||
{
|
||||
// origin point is our stopping point
|
||||
Vector3f stopping_point;
|
||||
@ -432,7 +432,7 @@ void Copter::FlightMode_RTL::build_path(bool terrain_following_allowed)
|
||||
// compute the return target - home or rally point
|
||||
// return altitude in cm above home at which vehicle should return home
|
||||
// return target's altitude is updated to a higher altitude that the vehicle can safely return at (frame may also be set)
|
||||
void Copter::FlightMode_RTL::compute_return_target(bool terrain_following_allowed)
|
||||
void Copter::ModeRTL::compute_return_target(bool terrain_following_allowed)
|
||||
{
|
||||
// set return target to nearest rally point or home position (Note: alt is absolute)
|
||||
#if AC_RALLY == ENABLED
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Once the copter is close to home, it will run a standard land controller.
|
||||
*/
|
||||
|
||||
bool Copter::FlightMode_SmartRTL::init(bool ignore_checks)
|
||||
bool Copter::ModeSmartRTL::init(bool ignore_checks)
|
||||
{
|
||||
if ((copter.position_ok() || ignore_checks) && g2.smart_rtl.is_active()) {
|
||||
// initialise waypoint and spline controller
|
||||
@ -31,12 +31,12 @@ bool Copter::FlightMode_SmartRTL::init(bool ignore_checks)
|
||||
}
|
||||
|
||||
// perform cleanup required when leaving smart_rtl
|
||||
void Copter::FlightMode_SmartRTL::exit()
|
||||
void Copter::ModeSmartRTL::exit()
|
||||
{
|
||||
g2.smart_rtl.cancel_request_for_thorough_cleanup();
|
||||
}
|
||||
|
||||
void Copter::FlightMode_SmartRTL::run()
|
||||
void Copter::ModeSmartRTL::run()
|
||||
{
|
||||
switch (smart_rtl_state) {
|
||||
case SmartRTL_WaitForPathCleanup:
|
||||
@ -57,7 +57,7 @@ void Copter::FlightMode_SmartRTL::run()
|
||||
}
|
||||
}
|
||||
|
||||
void Copter::FlightMode_SmartRTL::wait_cleanup_run()
|
||||
void Copter::ModeSmartRTL::wait_cleanup_run()
|
||||
{
|
||||
// hover at current target position
|
||||
motors->set_desired_spool_state(AP_Motors::DESIRED_THROTTLE_UNLIMITED);
|
||||
@ -71,7 +71,7 @@ void Copter::FlightMode_SmartRTL::wait_cleanup_run()
|
||||
}
|
||||
}
|
||||
|
||||
void Copter::FlightMode_SmartRTL::path_follow_run()
|
||||
void Copter::ModeSmartRTL::path_follow_run()
|
||||
{
|
||||
// if we are close to current target point, switch the next point to be our target.
|
||||
if (wp_nav->reached_wp_destination()) {
|
||||
@ -108,7 +108,7 @@ void Copter::FlightMode_SmartRTL::path_follow_run()
|
||||
}
|
||||
}
|
||||
|
||||
void Copter::FlightMode_SmartRTL::pre_land_position_run()
|
||||
void Copter::ModeSmartRTL::pre_land_position_run()
|
||||
{
|
||||
// if we are close to 2m above start point, we are ready to land.
|
||||
if (wp_nav->reached_wp_destination()) {
|
||||
@ -131,7 +131,7 @@ void Copter::FlightMode_SmartRTL::pre_land_position_run()
|
||||
}
|
||||
|
||||
// save current position for use by the smart_rtl flight mode
|
||||
void Copter::FlightMode_SmartRTL::save_position()
|
||||
void Copter::ModeSmartRTL::save_position()
|
||||
{
|
||||
const bool should_save_position = motors->armed() && (copter.control_mode != SMART_RTL);
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
// sport_init - initialise sport controller
|
||||
bool Copter::FlightMode_Sport::init(bool ignore_checks)
|
||||
bool Copter::ModeSport::init(bool ignore_checks)
|
||||
{
|
||||
// initialize vertical speed and acceleration
|
||||
pos_control->set_speed_z(-get_pilot_speed_dn(), g.pilot_speed_up);
|
||||
@ -22,7 +22,7 @@ bool Copter::FlightMode_Sport::init(bool ignore_checks)
|
||||
|
||||
// sport_run - runs the sport controller
|
||||
// should be called at 100hz or more
|
||||
void Copter::FlightMode_Sport::run()
|
||||
void Copter::ModeSport::run()
|
||||
{
|
||||
SportModeState sport_state;
|
||||
float takeoff_climb_rate = 0.0f;
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
// stabilize_init - initialise stabilize controller
|
||||
bool Copter::FlightMode_Stabilize::init(bool ignore_checks)
|
||||
bool Copter::ModeStabilize::init(bool ignore_checks)
|
||||
{
|
||||
// if landed and the mode we're switching from does not have manual throttle and the throttle stick is too high
|
||||
if (motors->armed() && ap.land_complete && !_copter.flightmode->has_manual_throttle() &&
|
||||
@ -20,7 +20,7 @@ bool Copter::FlightMode_Stabilize::init(bool ignore_checks)
|
||||
|
||||
// stabilize_run - runs the main stabilize controller
|
||||
// should be called at 100hz or more
|
||||
void Copter::FlightMode_Stabilize::run()
|
||||
void Copter::ModeStabilize::run()
|
||||
{
|
||||
float target_roll, target_pitch;
|
||||
float target_yaw_rate;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
// throw_init - initialise throw controller
|
||||
bool Copter::FlightMode_Throw::init(bool ignore_checks)
|
||||
bool Copter::ModeThrow::init(bool ignore_checks)
|
||||
{
|
||||
#if FRAME_CONFIG == HELI_FRAME
|
||||
// do not allow helis to use throw to start
|
||||
@ -23,7 +23,7 @@ bool Copter::FlightMode_Throw::init(bool ignore_checks)
|
||||
|
||||
// runs the throw to start controller
|
||||
// should be called at 100hz or more
|
||||
void Copter::FlightMode_Throw::run()
|
||||
void Copter::ModeThrow::run()
|
||||
{
|
||||
/* Throw State Machine
|
||||
Throw_Disarmed - motors are off
|
||||
@ -204,7 +204,7 @@ void Copter::FlightMode_Throw::run()
|
||||
}
|
||||
}
|
||||
|
||||
bool Copter::FlightMode_Throw::throw_detected()
|
||||
bool Copter::ModeThrow::throw_detected()
|
||||
{
|
||||
// Check that we have a valid navigation solution
|
||||
nav_filter_status filt_status = inertial_nav.get_filter_status();
|
||||
@ -249,20 +249,20 @@ bool Copter::FlightMode_Throw::throw_detected()
|
||||
}
|
||||
}
|
||||
|
||||
bool Copter::FlightMode_Throw::throw_attitude_good()
|
||||
bool Copter::ModeThrow::throw_attitude_good()
|
||||
{
|
||||
// Check that we have uprighted the copter
|
||||
const Matrix3f &rotMat = ahrs.get_rotation_body_to_ned();
|
||||
return (rotMat.c.z > 0.866f); // is_upright
|
||||
}
|
||||
|
||||
bool Copter::FlightMode_Throw::throw_height_good()
|
||||
bool Copter::ModeThrow::throw_height_good()
|
||||
{
|
||||
// Check that we are no more than 0.5m below the demanded height
|
||||
return (pos_control->get_alt_error() < 50.0f);
|
||||
}
|
||||
|
||||
bool Copter::FlightMode_Throw::throw_position_good()
|
||||
bool Copter::ModeThrow::throw_position_good()
|
||||
{
|
||||
// check that our horizontal position error is within 50cm
|
||||
return (pos_control->get_horizontal_error() < 50.0f);
|
||||
|
@ -6,9 +6,9 @@
|
||||
*/
|
||||
|
||||
// return the static controller object corresponding to supplied mode
|
||||
Copter::FlightMode *Copter::flightmode_for_mode(const uint8_t mode)
|
||||
Copter::Mode *Copter::flightmode_for_mode(const uint8_t mode)
|
||||
{
|
||||
Copter::FlightMode *ret = nullptr;
|
||||
Copter::Mode *ret = nullptr;
|
||||
|
||||
switch (mode) {
|
||||
case ACRO:
|
||||
@ -110,7 +110,7 @@ bool Copter::set_mode(control_mode_t mode, mode_reason_t reason)
|
||||
return true;
|
||||
}
|
||||
|
||||
Copter::FlightMode *new_flightmode = flightmode_for_mode(mode);
|
||||
Copter::Mode *new_flightmode = flightmode_for_mode(mode);
|
||||
if (new_flightmode == nullptr) {
|
||||
gcs().send_text(MAV_SEVERITY_WARNING,"No such mode");
|
||||
Log_Write_Error(ERROR_SUBSYSTEM_FLIGHT_MODE,mode);
|
||||
@ -176,8 +176,8 @@ void Copter::update_flight_mode()
|
||||
}
|
||||
|
||||
// exit_mode - high level call to organise cleanup as a flight mode is exited
|
||||
void Copter::exit_mode(Copter::FlightMode *&old_flightmode,
|
||||
Copter::FlightMode *&new_flightmode)
|
||||
void Copter::exit_mode(Copter::Mode *&old_flightmode,
|
||||
Copter::Mode *&new_flightmode)
|
||||
{
|
||||
#if AUTOTUNE_ENABLED == ENABLED
|
||||
if (old_flightmode == &flightmode_autotune) {
|
||||
@ -235,7 +235,7 @@ void Copter::notify_flight_mode() {
|
||||
notify.set_flight_mode_str(flightmode->name4());
|
||||
}
|
||||
|
||||
void Copter::FlightMode::update_navigation()
|
||||
void Copter::Mode::update_navigation()
|
||||
{
|
||||
// run autopilot to make high level decisions about control modes
|
||||
run_autopilot();
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
// heli_acro_init - initialise acro controller
|
||||
bool Copter::FlightMode_Acro_Heli::init(bool ignore_checks)
|
||||
bool Copter::ModeAcro_Heli::init(bool ignore_checks)
|
||||
{
|
||||
// if heli is equipped with a flybar, then tell the attitude controller to pass through controls directly to servos
|
||||
attitude_control->use_flybar_passthrough(motors->has_flybar(), motors->supports_yaw_passthrough());
|
||||
@ -22,7 +22,7 @@ bool Copter::FlightMode_Acro_Heli::init(bool ignore_checks)
|
||||
|
||||
// heli_acro_run - runs the acro controller
|
||||
// should be called at 100hz or more
|
||||
void Copter::FlightMode_Acro_Heli::run()
|
||||
void Copter::ModeAcro_Heli::run()
|
||||
{
|
||||
float target_roll, target_pitch, target_yaw;
|
||||
float pilot_throttle_scaled;
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
// stabilize_init - initialise stabilize controller
|
||||
bool Copter::FlightMode_Stabilize_Heli::init(bool ignore_checks)
|
||||
bool Copter::ModeStabilize_Heli::init(bool ignore_checks)
|
||||
{
|
||||
// set target altitude to zero for reporting
|
||||
// To-Do: make pos controller aware when it's active/inactive so it can always report the altitude error?
|
||||
@ -20,7 +20,7 @@ bool Copter::FlightMode_Stabilize_Heli::init(bool ignore_checks)
|
||||
|
||||
// stabilize_run - runs the main stabilize controller
|
||||
// should be called at 100hz or more
|
||||
void Copter::FlightMode_Stabilize_Heli::run()
|
||||
void Copter::ModeStabilize_Heli::run()
|
||||
{
|
||||
float target_roll, target_pitch;
|
||||
float target_yaw_rate;
|
||||
|
Loading…
Reference in New Issue
Block a user