Copter: add in_guided_mode mode callback

This commit is contained in:
Peter Barker 2018-02-22 12:49:47 +11:00 committed by Randy Mackay
parent e66034f183
commit eb9bbddcb7
2 changed files with 7 additions and 3 deletions

View File

@ -1342,7 +1342,7 @@ void GCS_MAVLINK_Copter::handleMessage(mavlink_message_t* msg)
mavlink_msg_set_attitude_target_decode(msg, &packet);
// exit if vehicle is not in Guided mode or Auto-Guided mode
if ((copter.control_mode != GUIDED) && (copter.control_mode != GUIDED_NOGPS) && !(copter.control_mode == AUTO && copter.mode_auto.mode() == Auto_NavGuided)) {
if (!copter.flightmode->in_guided_mode()) {
break;
}
@ -1384,7 +1384,7 @@ void GCS_MAVLINK_Copter::handleMessage(mavlink_message_t* msg)
mavlink_msg_set_position_target_local_ned_decode(msg, &packet);
// exit if vehicle is not in Guided mode or Auto-Guided mode
if ((copter.control_mode != GUIDED) && !(copter.control_mode == AUTO && copter.mode_auto.mode() == Auto_NavGuided)) {
if (!copter.flightmode->in_guided_mode()) {
break;
}
@ -1481,7 +1481,7 @@ void GCS_MAVLINK_Copter::handleMessage(mavlink_message_t* msg)
mavlink_msg_set_position_target_global_int_decode(msg, &packet);
// exit if vehicle is not in Guided mode or Auto-Guided mode
if ((copter.control_mode != GUIDED) && !(copter.control_mode == AUTO && copter.mode_auto.mode() == Auto_NavGuided)) {
if (!copter.flightmode->in_guided_mode()) {
break;
}

View File

@ -6,6 +6,7 @@ class Mode {
friend class Copter;
friend class AP_Arming_Copter;
friend class ToyMode;
friend class GCS_MAVLINK_Copter;
// constructor
Mode(void);
@ -32,6 +33,7 @@ protected:
virtual void run_autopilot() {}
virtual uint32_t wp_distance() const { return 0; }
virtual int32_t wp_bearing() const { return 0; }
virtual bool in_guided_mode() const { return false; }
// convenience references to avoid code churn in conversion:
Parameters &g;
@ -178,6 +180,7 @@ public:
bool requires_GPS() const override { return true; }
bool has_manual_throttle() const override { return false; }
bool allows_arming(bool from_gcs) const override { return false; };
bool in_guided_mode() const { return mode() == Auto_NavGuided; }
// Auto
AutoMode mode() const { return _mode; }
@ -682,6 +685,7 @@ public:
bool has_manual_throttle() const override { return false; }
bool allows_arming(bool from_gcs) const override { return from_gcs; }
bool is_autopilot() const override { return true; }
bool in_guided_mode() const { return true; }
void set_angle(const Quaternion &q, float climb_rate_cms, bool use_yaw_rate, float yaw_rate_rads);
bool set_destination(const Vector3f& destination, bool use_yaw = false, float yaw_cd = 0.0, bool use_yaw_rate = false, float yaw_rate_cds = 0.0, bool yaw_relative = false);