Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plane: ATT.DesPitch now reports actual target, not nav output (Float version) #29067

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Plane: ATT.DesPitch now reports actual target, not nav output
Also:
- Converted demanded_pitch_cd to float degrees.
- Initialized to NaN which will not show up in the ATT.DesPitch
plots, unless a mode (usually) overwrites it.
- Renamed demaned_pitch attribute into demanded_pitch_logged
Georacer committed Jan 28, 2025
commit c7512eb24dd8a2afe6cfd4232abaa23e48c1ff80
6 changes: 3 additions & 3 deletions ArduPlane/Attitude.cpp
Original file line number Diff line number Diff line change
@@ -209,7 +209,7 @@ float Plane::stabilize_pitch_get_pitch_out()
const bool quadplane_in_frwd_transition = false;
#endif

int32_t demanded_pitch = nav_pitch_cd + int32_t(g.pitch_trim * 100.0) + SRV_Channels::get_output_scaled(SRV_Channel::k_throttle) * g.kff_throttle_to_pitch;
demanded_pitch_logged = nav_pitch_cd*0.01f + g.pitch_trim + SRV_Channels::get_output_scaled(SRV_Channel::k_throttle)*0.01f*g.kff_throttle_to_pitch;
bool disable_integrator = false;
if (control_mode == &mode_stabilize && channel_pitch->get_control_in() != 0) {
disable_integrator = true;
@@ -224,10 +224,10 @@ float Plane::stabilize_pitch_get_pitch_out()
!control_mode->does_auto_throttle() &&
flare_mode == FlareMode::ENABLED_PITCH_TARGET &&
throttle_at_zero()) {
demanded_pitch = landing.get_pitch_cd();
demanded_pitch_logged = landing.get_pitch_cd()*0.01f;
}

return pitchController.get_servo_out(demanded_pitch - ahrs.pitch_sensor, speed_scaler, disable_integrator,
return pitchController.get_servo_out(demanded_pitch_logged*100 - ahrs.pitch_sensor, speed_scaler, disable_integrator,
ground_mode && !(plane.flight_option_enabled(FlightOptions::DISABLE_GROUND_PID_SUPPRESSION)));
}

2 changes: 1 addition & 1 deletion ArduPlane/Log.cpp
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ void Plane::Log_Write_Attitude(void)
{
Vector3f targets { // Package up the targets into a vector for commonality with Copter usage of Log_Wrote_Attitude
nav_roll_cd * 0.01f,
nav_pitch_cd * 0.01f,
demanded_pitch_logged,
0 //Plane does not have the concept of navyaw. This is a placeholder.
};

4 changes: 4 additions & 0 deletions ArduPlane/Plane.cpp
Original file line number Diff line number Diff line change
@@ -511,6 +511,10 @@ void Plane::update_control_mode(void)
takeoff_state.throttle_lim_max = 100.0f;
takeoff_state.throttle_lim_min = -100.0f;

// Preemptively set demanded pitch to NaN, so that it properly doesn't
// get logged. Modes ovewriting it (most modes do) will change it.
demanded_pitch_logged = logger.quiet_nanf();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
demanded_pitch_logged = logger.quiet_nanf();
demanded_pitch_logged = AP::logger().quiet_nanf();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peterbarker Why? I always assumed if we have access its better to go direct.


update_fly_forward();

control_mode->update();
5 changes: 4 additions & 1 deletion ArduPlane/Plane.h
Original file line number Diff line number Diff line change
@@ -668,9 +668,12 @@ class Plane : public AP_Vehicle {
// The instantaneous desired bank angle. Hundredths of a degree
int32_t nav_roll_cd;

// The instantaneous desired pitch angle. Hundredths of a degree
// The instantaneous navigator-commanded pitch angle. Hundredths of a degree
int32_t nav_pitch_cd;

// The instantaneous desired pitch angle in degrees.
float demanded_pitch_logged;

// the aerodynamic load factor. This is calculated from the demanded
// roll before the roll is clipped, using 1/sqrt(cos(nav_roll))
float aerodynamic_load_factor = 1.0f;