AR_AttitudeControl: add get_desired_pitch accessor

This commit is contained in:
Randy Mackay 2018-08-04 15:22:23 +09:00
parent 56a89c0a1c
commit 9b60e0844b
2 changed files with 14 additions and 0 deletions

View File

@ -522,6 +522,17 @@ float AR_AttitudeControl::get_throttle_out_from_pitch(float desired_pitch, bool
return constrain_float(_pitch_to_throttle_pid.get_pid(), -1.0f, +1.0f); return constrain_float(_pitch_to_throttle_pid.get_pid(), -1.0f, +1.0f);
} }
// get latest desired pitch in radians for reporting purposes
float AR_AttitudeControl::get_desired_pitch() const
{
// if not called recently, return 0
if ((_balance_last_ms == 0) || ((AP_HAL::millis() - _balance_last_ms) > AR_ATTCONTROL_TIMEOUT_MS)) {
return 0.0f;
}
return _pitch_to_throttle_pid.get_pid_info().desired;
}
// get forward speed in m/s (earth-frame horizontal velocity but only along vehicle x-axis). returns true on success // get forward speed in m/s (earth-frame horizontal velocity but only along vehicle x-axis). returns true on success
bool AR_AttitudeControl::get_forward_speed(float &speed) const bool AR_AttitudeControl::get_forward_speed(float &speed) const
{ {

View File

@ -94,6 +94,9 @@ public:
// desired_pitch is in radians // desired_pitch is in radians
float get_throttle_out_from_pitch(float desired_pitch, bool armed, float dt); float get_throttle_out_from_pitch(float desired_pitch, bool armed, float dt);
// get latest desired pitch in radians for reporting purposes
float get_desired_pitch() const;
// low level control accessors for reporting and logging // low level control accessors for reporting and logging
AC_P& get_steering_angle_p() { return _steer_angle_p; } AC_P& get_steering_angle_p() { return _steer_angle_p; }
AC_PID& get_steering_rate_pid() { return _steer_rate_pid; } AC_PID& get_steering_rate_pid() { return _steer_rate_pid; }