APM:Copter
mode.cpp
Go to the documentation of this file.
1 #include "Copter.h"
2 
3 /*
4  * High level calls to set and update flight modes logic for individual
5  * flight modes is in control_acro.cpp, control_stabilize.cpp, etc
6  */
7 
8 /*
9  constructor for Mode object
10  */
12  g(copter.g),
13  g2(copter.g2),
14  wp_nav(copter.wp_nav),
15  loiter_nav(copter.loiter_nav),
16  pos_control(copter.pos_control),
17  inertial_nav(copter.inertial_nav),
18  ahrs(copter.ahrs),
19  attitude_control(copter.attitude_control),
21  channel_roll(copter.channel_roll),
22  channel_pitch(copter.channel_pitch),
23  channel_throttle(copter.channel_throttle),
24  channel_yaw(copter.channel_yaw),
25  G_Dt(copter.G_Dt),
26  ap(copter.ap),
27  takeoff_state(copter.takeoff_state),
28  ekfGndSpdLimit(copter.ekfGndSpdLimit),
30  heli_flags(copter.heli_flags),
31 #endif
32  ekfNavVelGainScaler(copter.ekfNavVelGainScaler)
33 { };
34 
35 // return the static controller object corresponding to supplied mode
37 {
38  Copter::Mode *ret = nullptr;
39 
40  switch (mode) {
41 #if MODE_ACRO_ENABLED == ENABLED
42  case ACRO:
43  ret = &mode_acro;
44  break;
45 #endif
46 
47  case STABILIZE:
48  ret = &mode_stabilize;
49  break;
50 
51  case ALT_HOLD:
52  ret = &mode_althold;
53  break;
54 
55 #if MODE_AUTO_ENABLED == ENABLED
56  case AUTO:
57  ret = &mode_auto;
58  break;
59 #endif
60 
61 #if MODE_CIRCLE_ENABLED == ENABLED
62  case CIRCLE:
63  ret = &mode_circle;
64  break;
65 #endif
66 
67 #if MODE_LOITER_ENABLED == ENABLED
68  case LOITER:
69  ret = &mode_loiter;
70  break;
71 #endif
72 
73 #if MODE_GUIDED_ENABLED == ENABLED
74  case GUIDED:
75  ret = &mode_guided;
76  break;
77 #endif
78 
79  case LAND:
80  ret = &mode_land;
81  break;
82 
83 #if MODE_RTL_ENABLED == ENABLED
84  case RTL:
85  ret = &mode_rtl;
86  break;
87 #endif
88 
89 #if MODE_DRIFT_ENABLED == ENABLED
90  case DRIFT:
91  ret = &mode_drift;
92  break;
93 #endif
94 
95 #if MODE_SPORT_ENABLED == ENABLED
96  case SPORT:
97  ret = &mode_sport;
98  break;
99 #endif
100 
101  case FLIP:
102  ret = &mode_flip;
103  break;
104 
105 #if AUTOTUNE_ENABLED == ENABLED
106  case AUTOTUNE:
107  ret = &mode_autotune;
108  break;
109 #endif
110 
111 #if MODE_POSHOLD_ENABLED == ENABLED
112  case POSHOLD:
113  ret = &mode_poshold;
114  break;
115 #endif
116 
117 #if MODE_BRAKE_ENABLED == ENABLED
118  case BRAKE:
119  ret = &mode_brake;
120  break;
121 #endif
122 
123 #if MODE_THROW_ENABLED == ENABLED
124  case THROW:
125  ret = &mode_throw;
126  break;
127 #endif
128 
129 #if ADSB_ENABLED == ENABLED
130  case AVOID_ADSB:
131  ret = &mode_avoid_adsb;
132  break;
133 #endif
134 
135 #if MODE_GUIDED_NOGPS_ENABLED == ENABLED
136  case GUIDED_NOGPS:
137  ret = &mode_guided_nogps;
138  break;
139 #endif
140 
141 #if MODE_SMARTRTL_ENABLED == ENABLED
142  case SMART_RTL:
143  ret = &mode_smartrtl;
144  break;
145 #endif
146 
147 #if OPTFLOW == ENABLED
148  case FLOWHOLD:
150  break;
151 #endif
152 
154  case FOLLOW:
155  ret = &mode_follow;
156  break;
157 #endif
158 
159  default:
160  break;
161  }
162 
163  return ret;
164 }
165 
166 
167 // set_mode - change flight mode and perform any necessary initialisation
168 // optional force parameter used to force the flight mode change (used only first time mode is set)
169 // returns true if mode was successfully set
170 // ACRO, STABILIZE, ALTHOLD, LAND, DRIFT and SPORT can always be set successfully but the return state of other flight modes should be checked and the caller should deal with failures appropriately
172 {
173 
174  // return immediately if we are already in the desired mode
175  if (mode == control_mode) {
176  control_mode_reason = reason;
177  return true;
178  }
179 
180  Copter::Mode *new_flightmode = mode_from_mode_num(mode);
181  if (new_flightmode == nullptr) {
182  gcs().send_text(MAV_SEVERITY_WARNING,"No such mode");
184  return false;
185  }
186 
187  bool ignore_checks = !motors->armed(); // allow switching to any mode if disarmed. We rely on the arming check to perform
188 
189 #if FRAME_CONFIG == HELI_FRAME
190  // do not allow helis to enter a non-manual throttle mode if the
191  // rotor runup is not complete
192  if (!ignore_checks && !new_flightmode->has_manual_throttle() && !motors->rotor_runup_complete()){
193  gcs().send_text(MAV_SEVERITY_WARNING,"Flight mode change failed");
195  return false;
196  }
197 #endif
198 
199  if (!new_flightmode->init(ignore_checks)) {
200  gcs().send_text(MAV_SEVERITY_WARNING,"Flight mode change failed");
202  return false;
203  }
204 
205  // perform any cleanup required by previous flight mode
206  exit_mode(flightmode, new_flightmode);
207 
208  // update flight mode
209  flightmode = new_flightmode;
210  control_mode = mode;
211  control_mode_reason = reason;
213 
214 #if ADSB_ENABLED == ENABLED
215  adsb.set_is_auto_mode((mode == AUTO) || (mode == RTL) || (mode == GUIDED));
216 #endif
217 
218 #if AC_FENCE == ENABLED
219  // pilot requested flight mode change during a fence breach indicates pilot is attempting to manually recover
220  // this flight mode change could be automatic (i.e. fence, battery, GPS or GCS failsafe)
221  // but it should be harmless to disable the fence temporarily in these situations as well
223 #endif
224 
225 #if FRSKY_TELEM_ENABLED == ENABLED
227 #endif
228 #if DEVO_TELEM_ENABLED == ENABLED
230 #endif
231 
232 #if CAMERA == ENABLED
234 #endif
235 
236  // update notify object
238 
239  // return success
240  return true;
241 }
242 
243 // update_flight_mode - calls the appropriate attitude controllers based on flight mode
244 // called at 100hz or more
246 {
247  // Update EKF speed limit - used to limit speed when we are using optical flow
248  ahrs.getEkfControlLimits(ekfGndSpdLimit, ekfNavVelGainScaler);
249 
250  flightmode->run();
251 }
252 
253 // exit_mode - high level call to organise cleanup as a flight mode is exited
254 void Copter::exit_mode(Copter::Mode *&old_flightmode,
255  Copter::Mode *&new_flightmode)
256 {
257 #if AUTOTUNE_ENABLED == ENABLED
258  if (old_flightmode == &mode_autotune) {
260  }
261 #endif
262 
263  // stop mission when we leave auto mode
264 #if MODE_AUTO_ENABLED == ENABLED
265  if (old_flightmode == &mode_auto) {
267  mission.stop();
268  }
269 #if MOUNT == ENABLED
271 #endif // MOUNT == ENABLED
272  }
273 #endif
274 
275  // smooth throttle transition when switching from manual to automatic flight modes
276  if (old_flightmode->has_manual_throttle() && !new_flightmode->has_manual_throttle() && motors->armed() && !ap.land_complete) {
277  // this assumes all manual flight modes use get_pilot_desired_throttle to translate pilot input to output throttle
279  }
280 
281  // cancel any takeoffs in progress
282  takeoff_stop();
283 
284 #if MODE_SMARTRTL_ENABLED == ENABLED
285  // call smart_rtl cleanup
286  if (old_flightmode == &mode_smartrtl) {
288  }
289 #endif
290 
291 #if FRAME_CONFIG == HELI_FRAME
292  // firmly reset the flybar passthrough to false when exiting acro mode.
293  if (old_flightmode == &mode_acro) {
294  attitude_control->use_flybar_passthrough(false, false);
295  motors->set_acro_tail(false);
296  }
297 
298  // if we are changing from a mode that did not use manual throttle,
299  // stab col ramp value should be pre-loaded to the correct value to avoid a twitch
300  // heli_stab_col_ramp should really only be active switching between Stabilize and Acro modes
301  if (!old_flightmode->has_manual_throttle()){
302  if (new_flightmode == &mode_stabilize){
303  input_manager.set_stab_col_ramp(1.0);
304  } else if (new_flightmode == &mode_acro){
305  input_manager.set_stab_col_ramp(0.0);
306  }
307  }
308 #endif //HELI_FRAME
309 }
310 
311 // notify_flight_mode - sets notify object based on current flight mode. Only used for OreoLED notify device
316 }
317 
319 {
320  // run autopilot to make high level decisions about control modes
321  run_autopilot();
322 }
323 
324 // get_pilot_desired_angle - transform pilot's roll or pitch input into a desired lean angle
325 // returns desired angle in centi-degrees
326 void Copter::Mode::get_pilot_desired_lean_angles(float &roll_out, float &pitch_out, float angle_max, float angle_limit) const
327 {
328  // fetch roll and pitch inputs
329  roll_out = channel_roll->get_control_in();
330  pitch_out = channel_pitch->get_control_in();
331 
332  // limit max lean angle
333  angle_limit = constrain_float(angle_limit, 1000.0f, angle_max);
334 
335  // scale roll and pitch inputs to ANGLE_MAX parameter range
336  float scaler = angle_max/(float)ROLL_PITCH_YAW_INPUT_MAX;
337  roll_out *= scaler;
338  pitch_out *= scaler;
339 
340  // do circular limit
341  float total_in = norm(pitch_out, roll_out);
342  if (total_in > angle_limit) {
343  float ratio = angle_limit / total_in;
344  roll_out *= ratio;
345  pitch_out *= ratio;
346  }
347 
348  // do lateral tilt to euler roll conversion
349  roll_out = (18000/M_PI) * atanf(cosf(pitch_out*(M_PI/18000))*tanf(roll_out*(M_PI/18000)));
350 
351  // roll_out and pitch_out are returned
352 }
353 
354 bool Copter::Mode::takeoff_triggered(const float target_climb_rate) const
355 {
356  if (!ap.land_complete) {
357  // can't take off if we're already flying
358  return false;
359  }
360  if (target_climb_rate <= 0.0f) {
361  // can't takeoff unless we want to go up...
362  return false;
363  }
364 #if FRAME_CONFIG == HELI_FRAME
365  if (!motors->rotor_runup_complete()) {
366  // hold heli on the ground until rotor speed runup has finished
367  return false;
368  }
369 #endif
370  return true;
371 }
372 
374 {
375 #if FRAME_CONFIG == HELI_FRAME
376  // Helicopters always stabilize roll/pitch/yaw
377  attitude_control->input_euler_angle_roll_pitch_euler_rate_yaw(0.0f, 0.0f, 0.0f);
378  attitude_control->set_throttle_out(0.0f, false, copter.g.throttle_filt);
379 #else
380  motors->set_desired_spool_state(AP_Motors::DESIRED_SPIN_WHEN_ARMED);
381  // multicopters do not stabilize roll/pitch/yaw when disarmed
382  attitude_control->set_throttle_out_unstabilized(0.0f, true, copter.g.throttle_filt);
383 #endif
384 }
385 
386 /*
387  get a height above ground estimate for landing
388  */
390 {
391  int32_t alt_above_ground;
392  if (copter.rangefinder_alt_ok()) {
393  alt_above_ground = copter.rangefinder_state.alt_cm_filt.get();
394  } else {
395  bool navigating = pos_control->is_active_xy();
396  if (!navigating || !copter.current_loc.get_alt_cm(Location_Class::ALT_FRAME_ABOVE_TERRAIN, alt_above_ground)) {
397  alt_above_ground = copter.current_loc.alt;
398  }
399  }
400  return alt_above_ground;
401 }
402 
404 {
405 #if PRECISION_LANDING == ENABLED
406  AC_PrecLand &precland = copter.precland;
407 
408  const bool navigating = pos_control->is_active_xy();
409  bool doing_precision_landing = !ap.land_repo_active && precland.target_acquired() && navigating;
410 #else
411  bool doing_precision_landing = false;
412 #endif
413 
414  // compute desired velocity
415  const float precland_acceptable_error = 15.0f;
416  const float precland_min_descent_speed = 10.0f;
417  const int32_t alt_above_ground = get_alt_above_ground();
418 
419  float cmb_rate = 0;
420  if (!pause_descent) {
421  float max_land_descent_velocity;
422  if (g.land_speed_high > 0) {
423  max_land_descent_velocity = -g.land_speed_high;
424  } else {
425  max_land_descent_velocity = pos_control->get_speed_down();
426  }
427 
428  // Don't speed up for landing.
429  max_land_descent_velocity = MIN(max_land_descent_velocity, -abs(g.land_speed));
430 
431  // Compute a vertical velocity demand such that the vehicle approaches g2.land_alt_low. Without the below constraint, this would cause the vehicle to hover at g2.land_alt_low.
433 
434  // Constrain the demanded vertical velocity so that it is between the configured maximum descent speed and the configured minimum descent speed.
435  cmb_rate = constrain_float(cmb_rate, max_land_descent_velocity, -abs(g.land_speed));
436 
437  if (doing_precision_landing && copter.rangefinder_alt_ok() && copter.rangefinder_state.alt_cm > 35.0f && copter.rangefinder_state.alt_cm < 200.0f) {
438  float max_descent_speed = abs(g.land_speed)/2.0f;
439  float land_slowdown = MAX(0.0f, pos_control->get_horizontal_error()*(max_descent_speed/precland_acceptable_error));
440  cmb_rate = MIN(-precland_min_descent_speed, -max_descent_speed+land_slowdown);
441  }
442  }
443 
444  // update altitude target and call position controller
447 }
448 
450 {
451  LowPassFilterFloat &rc_throttle_control_in_filter = copter.rc_throttle_control_in_filter;
453 
454  float target_roll = 0.0f;
455  float target_pitch = 0.0f;
456  float target_yaw_rate = 0;
457 
458  // relax loiter target if we might be landed
459  if (ap.land_complete_maybe) {
461  }
462 
463  // process pilot inputs
464  if (!copter.failsafe.radio) {
465  if ((g.throttle_behavior & THR_BEHAVE_HIGH_THROTTLE_CANCELS_LAND) != 0 && rc_throttle_control_in_filter.get() > LAND_CANCEL_TRIGGER_THR){
466  copter.Log_Write_Event(DATA_LAND_CANCELLED_BY_PILOT);
467  // exit land if throttle is high
470  }
471  }
472 
473  if (g.land_repositioning) {
474  // apply SIMPLE mode transform to pilot inputs
476 
477  // convert pilot input to lean angles
478  get_pilot_desired_lean_angles(target_roll, target_pitch, loiter_nav->get_angle_max_cd(), attitude_control->get_althold_lean_angle_max());
479 
480  // record if pilot has overriden roll or pitch
481  if (!is_zero(target_roll) || !is_zero(target_pitch)) {
482  ap.land_repo_active = true;
483  }
484  }
485 
486  // get pilot's desired yaw rate
488  }
489 
490 #if PRECISION_LANDING == ENABLED
491  AC_PrecLand &precland = copter.precland;
492  bool doing_precision_landing = !ap.land_repo_active && precland.target_acquired();
493  // run precision landing
494  if (doing_precision_landing) {
495  Vector2f target_pos, target_vel_rel;
496  if (!precland.get_target_position_cm(target_pos)) {
497  target_pos.x = inertial_nav.get_position().x;
498  target_pos.y = inertial_nav.get_position().y;
499  }
500  if (!precland.get_target_velocity_relative_cms(target_vel_rel)) {
501  target_vel_rel.x = -inertial_nav.get_velocity().x;
502  target_vel_rel.y = -inertial_nav.get_velocity().y;
503  }
504  pos_control->set_xy_target(target_pos.x, target_pos.y);
505  pos_control->override_vehicle_velocity_xy(-target_vel_rel);
506  }
507 #endif
508 
509  // process roll, pitch inputs
510  loiter_nav->set_pilot_desired_acceleration(target_roll, target_pitch, G_Dt);
511 
512  // run loiter controller
514 
515  int32_t nav_roll = loiter_nav->get_roll();
516  int32_t nav_pitch = loiter_nav->get_pitch();
517 
518  if (g2.wp_navalt_min > 0) {
519  // user has requested an altitude below which navigation
520  // attitude is limited. This is used to prevent commanded roll
521  // over on landing, which particularly affects helicopters if
522  // there is any position estimate drift after touchdown. We
523  // limit attitude to 7 degrees below this limit and linearly
524  // interpolate for 1m above that
525  const int alt_above_ground = get_alt_above_ground();
526  float attitude_limit_cd = linear_interpolate(700, aparm.angle_max, alt_above_ground,
527  g2.wp_navalt_min*100U, (g2.wp_navalt_min+1)*100U);
528  float total_angle_cd = norm(nav_roll, nav_pitch);
529  if (total_angle_cd > attitude_limit_cd) {
530  float ratio = attitude_limit_cd / total_angle_cd;
531  nav_roll *= ratio;
532  nav_pitch *= ratio;
533 
534  // tell position controller we are applying an external limit
536  }
537  }
538 
539 
540  // call attitude controller
541  attitude_control->input_euler_angle_roll_pitch_euler_rate_yaw(nav_roll, nav_pitch, target_yaw_rate);
542 }
543 
544 // pass-through functions to reduce code churn on conversion;
545 // these are candidates for moving into the Mode base
546 // class.
547 
548 float Copter::Mode::get_surface_tracking_climb_rate(int16_t target_rate, float current_alt_target, float dt)
549 {
550  return copter.get_surface_tracking_climb_rate(target_rate, current_alt_target, dt);
551 }
552 
554 {
555  return copter.get_pilot_desired_yaw_rate(stick_angle);
556 }
557 
558 float Copter::Mode::get_pilot_desired_climb_rate(float throttle_control)
559 {
560  return copter.get_pilot_desired_climb_rate(throttle_control);
561 }
562 
563 float Copter::Mode::get_pilot_desired_throttle(int16_t throttle_control, float thr_mid)
564 {
565  return copter.get_pilot_desired_throttle(throttle_control, thr_mid);
566 }
567 
569 {
570  return copter.get_non_takeoff_throttle();
571 }
572 
574  copter.update_simple_mode();
575 }
576 
578 {
579  return copter.set_mode(mode, reason);
580 }
581 
583 {
584  return copter.set_land_complete(b);
585 }
586 
588 {
589  return copter.gcs();
590 }
591 
593 {
594  return copter.Log_Write_Event(id);
595 }
596 
598 {
599  return copter.set_throttle_takeoff();
600 }
601 
603 {
604  return copter.takeoff_timer_start(alt_cm);
605 }
606 
608 {
609  return copter.takeoff_stop();
610 }
611 
612 void Copter::Mode::takeoff_get_climb_rates(float& pilot_climb_rate, float& takeoff_climb_rate)
613 {
614  return copter.takeoff_get_climb_rates(pilot_climb_rate, takeoff_climb_rate);
615 }
616 
618 {
619  return copter.get_avoidance_adjusted_climbrate(target_rate);
620 }
621 
623 {
624  return copter.get_pilot_speed_dn();
625 }
float norm(const T first, const U second, const Params... parameters)
AP_DEVO_Telem devo_telemetry
Definition: Copter.h:454
#define HELI_FRAME
Definition: defines.h:84
DESIRED_SPIN_WHEN_ARMED
AC_Fence fence
Definition: Copter.h:527
void zero_throttle_and_relax_ac()
Definition: mode.cpp:373
bool set_mode(control_mode_t mode, mode_reason_t reason)
Definition: mode.cpp:577
LowPassFilterFloat rc_throttle_control_in_filter
Definition: Copter.h:471
#define ERROR_SUBSYSTEM_FLIGHT_MODE
Definition: defines.h:402
bool takeoff_triggered(float target_climb_rate) const
Definition: mode.cpp:354
control_mode_t
Definition: defines.h:91
virtual const Vector3f & get_position() const=0
void update_flight_mode()
Definition: mode.cpp:245
virtual void run_autopilot()
Definition: Copter.h:94
float get_surface_tracking_climb_rate(int16_t target_rate, float current_alt_target, float dt)
Definition: mode.cpp:548
AP_AHRS_NavEKF & ahrs
#define FRAME_CONFIG
Definition: config.h:59
AP_Int16 throttle_behavior
Definition: Parameters.h:387
ModeStabilize mode_stabilize
Definition: Copter.h:999
void takeoff_get_climb_rates(float &pilot_climb_rate, float &takeoff_climb_rate)
Definition: mode.cpp:612
float get_avoidance_adjusted_climbrate(float target_rate)
Definition: mode.cpp:617
virtual const char * name4() const =0
ModeCircle mode_circle
Definition: Copter.h:974
void notify_flight_mode()
Definition: mode.cpp:312
struct _USB_OTG_GOTGCTL_TypeDef::@51 b
ModeGuided mode_guided
Definition: Copter.h:984
void update_z_controller()
GCS_Copter & gcs()
Definition: mode.cpp:587
void Log_Write_Event(uint8_t id)
Definition: mode.cpp:592
void Log_Write_Mode(uint8_t mode, uint8_t reason)
int16_t alt_cm
Definition: Copter.h:242
ModeAuto mode_auto
Definition: Copter.h:965
Definition: defines.h:95
ModeThrow mode_throw
Definition: Copter.h:1008
Definition: defines.h:106
virtual bool init(bool ignore_checks)=0
uint16_t get_pilot_speed_dn(void)
Definition: mode.cpp:622
uint8_t adsb
Definition: Copter.h:401
void update_simple_mode(void)
Definition: mode.cpp:573
void set_limit_accel_xy(void)
Definition: defines.h:96
Definition: defines.h:100
float get_horizontal_error() const
Mode(void)
Definition: mode.cpp:11
AP_Frsky_Telem frsky_telemetry
Definition: Copter.h:451
void override_vehicle_velocity_xy(const Vector2f &vel_xy)
AC_AttitudeControl_t *& attitude_control
Definition: Copter.h:123
float get_pilot_desired_climb_rate(float throttle_control)
Definition: mode.cpp:558
ModeLand mode_land
Definition: Copter.h:986
ModeSmartRTL mode_smartrtl
Definition: Copter.h:1014
Definition: defines.h:101
ModeGuidedNoGPS mode_guided_nogps
Definition: Copter.h:1011
ModeLoiter mode_loiter
Definition: Copter.h:988
void takeoff_stop(void)
Definition: mode.cpp:607
float get_pilot_desired_yaw_rate(int16_t stick_angle)
Definition: mode.cpp:553
void soften_for_landing()
ModeFollow mode_follow
Definition: Copter.h:981
ModeBrake mode_brake
Definition: Copter.h:971
Definition: defines.h:102
mode_reason_t
Definition: defines.h:115
AP_Int8 land_repositioning
Definition: Parameters.h:452
bool target_acquired()
ModeAcro mode_acro
Definition: Copter.h:960
void land_run_horizontal_control()
Definition: mode.cpp:449
#define MIN(a, b)
Mode * mode_from_mode_num(const uint8_t mode)
Definition: mode.cpp:36
void land_run_vertical_control(bool pause_descent=false)
Definition: mode.cpp:403
AP_Int16 land_alt_low
Definition: Parameters.h:583
void set_xy_target(float x, float y)
AP_MotorsMatrix motors(400)
void stop()
bool is_active_xy() const
#define THR_BEHAVE_HIGH_THROTTLE_CANCELS_LAND
Definition: defines.h:484
ModeSport mode_sport
Definition: Copter.h:1002
mode_reason_t control_mode_reason
Definition: Copter.h:346
void Log_Write_Error(uint8_t sub_system, uint8_t error_code)
Definition: Log.cpp:328
#define MODE_FOLLOW_ENABLED
Definition: config.h:301
float linear_interpolate(float low_output, float high_output, float var_value, float var_low, float var_high)
int32_t get_alt_above_ground(void)
Definition: mode.cpp:389
void update(float ekfGndSpdLimit, float ekfNavVelGainScaler)
void takeoff_timer_start(float alt_cm)
Definition: mode.cpp:602
float get_non_takeoff_throttle(void)
Definition: mode.cpp:568
int16_t get_control_in() const
Definition: defines.h:93
AP_Mount camera_mount
Definition: Copter.h:522
void manual_recovery_start()
bool is_zero(const T fVal1)
Mode * flightmode
Definition: Copter.h:955
#define f(i)
ParametersG2 & g2
Definition: Copter.h:117
ModeDrift mode_drift
Definition: Copter.h:977
ModeAvoidADSB mode_avoid_adsb
Definition: Copter.h:1005
mission_state state() const
void update_control_mode(uint8_t mode)
AP_Int16 land_speed
Definition: Parameters.h:414
Definition: defines.h:103
AP_Notify notify
Definition: Copter.h:215
void set_throttle_takeoff(void)
Definition: mode.cpp:597
virtual bool is_autopilot() const
Definition: Copter.h:80
void update_control_mode(uint8_t mode)
void set_accel_throttle_I_from_pilot_throttle()
Definition: Attitude.cpp:234
ModeRTL mode_rtl
Definition: Copter.h:994
Definition: defines.h:99
float get_accel_z() const
ModeFlip mode_flip
Definition: Copter.h:979
#define DATA_LAND_CANCELLED_BY_PILOT
Definition: defines.h:381
bool set_mode(control_mode_t mode, mode_reason_t reason)
Definition: mode.cpp:171
Definition: defines.h:97
static float sqrt_controller(float error, float p, float second_ord_lim, float dt)
Definition: defines.h:107
AP_Camera camera
Definition: Copter.h:516
void send_text(MAV_SEVERITY severity, const char *fmt,...)
void get_pilot_desired_lean_angles(float &roll_out, float &pitch_out, float angle_max, float angle_limit) const
Definition: mode.cpp:326
AC_P & get_pos_z_p()
float get_pilot_desired_throttle(int16_t throttle_control, float thr_mid=0.0f)
Definition: mode.cpp:563
float get_speed_down() const
AC_PrecLand precland
Definition: Copter.h:566
virtual void set_alt_target_from_climb_rate_ff(float climb_rate_cms, float dt, bool force_descend)
DataFlash_Class DataFlash
Definition: Copter.h:227
RC_Channel *& channel_roll
Definition: Copter.h:125
AC_PosControl *& pos_control
Definition: Copter.h:120
const float & get() const
void set_flight_mode_str(const char *str)
float constrain_float(const float amt, const float low, const float high)
ModeAutoTune mode_autotune
Definition: Copter.h:968
static struct notify_flags_and_values_type flags
MOTOR_CLASS *& motors
Definition: Copter.h:124
#define ROLL_PITCH_YAW_INPUT_MAX
Definition: config.h:545
ModePosHold mode_poshold
Definition: Copter.h:991
AP_HAL_MAIN_CALLBACKS & copter
Definition: ArduCopter.cpp:581
float & G_Dt
Definition: Copter.h:129
#define LAND_CANCEL_TRIGGER_THR
Definition: config.h:416
virtual bool has_manual_throttle() const =0
void set_pilot_desired_acceleration(float euler_roll_angle_cd, float euler_pitch_angle_cd, float dt)
void exit_mode(Mode *&old_flightmode, Mode *&new_flightmode)
Definition: mode.cpp:254
float & ekfNavVelGainScaler
Definition: Copter.h:137
AP_InertialNav & inertial_nav
Definition: Copter.h:121
void set_mode_to_default()
virtual const Vector3f & get_velocity() const=0
#define M_PI
#define ENABLED
Definition: defines.h:6
AP_AHRS & ahrs
Definition: Copter.h:122
RC_Channel *& channel_yaw
Definition: Copter.h:128
AP_Int16 land_speed_high
Definition: Parameters.h:415
void update_navigation()
Definition: mode.cpp:318
control_mode_t control_mode
Definition: Copter.h:345
int32_t get_pitch() const
Parameters & g
Definition: Copter.h:116
AP_Float & kP()
int32_t get_roll() const
float & ekfGndSpdLimit
Definition: Copter.h:134
void set_is_auto_mode(bool enable)
ModeAltHold mode_althold
Definition: Copter.h:963
AP_Mission mission
Definition: Copter.h:263
void set_land_complete(bool b)
Definition: mode.cpp:582
AP_Vehicle::MultiCopter aparm
Definition: Copter.h:205
virtual void run()=0
Definition: defines.h:98
AP_Float wp_navalt_min
Definition: Parameters.h:501
void * mode_flowhold_ptr
Definition: Parameters.h:591
AC_Loiter *& loiter_nav
Definition: Copter.h:119
RC_Channel *& channel_pitch
Definition: Copter.h:126
float get_angle_max_cd() const