@ -115,19 +115,12 @@ public:
@@ -115,19 +115,12 @@ public:
// true if vehicle has reached desired location. defaults to true because this is normally used by missions and we do not want the mission to become stuck
virtual bool reached_destination ( ) const { return true ; }
// set desired heading and speed - supported in Auto and Guided modes
virtual void set_desired_heading_and_speed ( float yaw_angle_cd , float target_speed ) ;
// get default speed for this mode (held in CRUISE_SPEED, WP_SPEED or RTL_SPEED)
// rtl argument should be true if called from RTL or SmartRTL modes (handled here to avoid duplication)
float get_speed_default ( bool rtl = false ) const ;
// set desired speed in m/s
bool set_desired_speed ( float speed ) ;
// restore desired speed to default from parameter values (CRUISE_SPEED or WP_SPEED)
// rtl argument should be true if called from RTL or SmartRTL modes (handled here to avoid duplication)
void set_desired_speed_to_default ( bool rtl = false ) ;
virtual bool set_desired_speed ( float speed ) { return false ; }
// execute the mission in reverse (i.e. backing up)
void set_reversed ( bool value ) ;
@ -207,7 +200,6 @@ protected:
@@ -207,7 +200,6 @@ protected:
float _distance_to_destination ; // distance from vehicle to final destination in meters
bool _reached_destination ; // true once the vehicle has reached the destination
float _desired_yaw_cd ; // desired yaw in centi-degrees. used in Auto, Guided and Loiter
float _desired_speed ; // desired speed in m/s
} ;
@ -258,9 +250,8 @@ public:
@@ -258,9 +250,8 @@ public:
bool set_desired_location ( const struct Location & destination , float next_leg_bearing_cd = AR_WPNAV_HEADING_UNKNOWN ) override WARN_IF_UNUSED ;
bool reached_destination ( ) const override ;
// heading and speed control
void set_desired_heading_and_speed ( float yaw_angle_cd , float target_speed ) override ;
bool reached_heading ( ) ;
// set desired speed in m/s
bool set_desired_speed ( float speed ) override ;
// start RTL (within auto)
void start_RTL ( ) ;
@ -325,6 +316,9 @@ private:
@@ -325,6 +316,9 @@ private:
} ;
bool auto_triggered ; // true when auto has been triggered to start
// HeadingAndSpeed sub mode variables
float _desired_speed ; // desired speed in HeadingAndSpeed submode
bool _reached_heading ; // true when vehicle has reached desired heading in TurnToHeading sub mode
// Loiter control
@ -376,12 +370,15 @@ public:
@@ -376,12 +370,15 @@ public:
// return true if vehicle has reached destination
bool reached_destination ( ) const override ;
// set desired speed in m/s
bool set_desired_speed ( float speed ) override ;
// get or set desired location
bool get_desired_location ( Location & destination ) const override WARN_IF_UNUSED ;
bool set_desired_location ( const struct Location & destination , float next_leg_bearing_cd = AR_WPNAV_HEADING_UNKNOWN ) override WARN_IF_UNUSED ;
// set desired heading and speed
void set_desired_heading_and_speed ( float yaw_angle_cd , float target_speed ) override ;
void set_desired_heading_and_speed ( float yaw_angle_cd , float target_speed ) ;
// set desired heading-delta, turn-rate and speed
void set_desired_heading_delta_and_speed ( float yaw_delta_cd , float target_speed ) ;
@ -414,6 +411,7 @@ protected:
@@ -414,6 +411,7 @@ protected:
uint32_t _des_att_time_ms ; // system time last call to set_desired_attitude was made (used for timeout)
float _desired_yaw_rate_cds ; // target turn rate centi-degrees per second
bool sent_notification ; // used to send one time notification to ground station
float _desired_speed ; // desired speed used only in HeadingAndSpeed submode
// limits
struct {
@ -472,6 +470,7 @@ protected:
@@ -472,6 +470,7 @@ protected:
bool _enter ( ) override ;
Location _destination ; // target location to hold position around
float _desired_speed ; // desired speed (ramped down from initial speed to zero)
} ;
class ModeManual : public Mode
@ -518,6 +517,9 @@ public:
@@ -518,6 +517,9 @@ public:
float get_distance_to_destination ( ) const override { return _distance_to_destination ; }
bool reached_destination ( ) const override ;
// set desired speed in m/s
bool set_desired_speed ( float speed ) override ;
protected :
bool _enter ( ) override ;
@ -547,6 +549,9 @@ public:
@@ -547,6 +549,9 @@ public:
float get_distance_to_destination ( ) const override { return _distance_to_destination ; }
bool reached_destination ( ) const override { return smart_rtl_state = = SmartRTL_StopAtHome ; }
// set desired speed in m/s
bool set_desired_speed ( float speed ) override ;
// save current position for use by the smart_rtl flight mode
void save_position ( ) ;
@ -631,10 +636,15 @@ public:
@@ -631,10 +636,15 @@ public:
// return distance (in meters) to destination
float get_distance_to_destination ( ) const override ;
// set desired speed in m/s
bool set_desired_speed ( float speed ) override ;
protected :
bool _enter ( ) override ;
void _exit ( ) override ;
float _desired_speed ; // desired speed in m/s
} ;
class ModeSimple : public Mode