in update_throttle_hover() function:when I'm in loiter and leave all stick in mid ,I found I can not learn thr hover,I found the reason is
if (!is_zero(pos_control->get_desired_velocity().z))
{
return;
}
pos_control->get_desired_velocity().z: _vel_desired.z
in Loiter we get it from :
pos_control.set_alt_target_from_climb_rate_ff(target_climb_rate, G_Dt, false);
when stick is mid:target_climb_rate=0.0 but when target_climb_rate is in this function :
_vel_desired.z = constrain_float(climb_rate_cms, _vel_desired.z-vel_change_limit, _vel_desired.z+vel_change_limit);
_vel_desired.z can not always be 0.0!!!!!!, I think is constrain_float change _vel_desired.z and let it not the same with climb_rate_cms,
can someone explain?
I test here:
pos_control.set_alt_target_from_climb_rate_ff(target_climb_rate, G_Dt, false);
printf target_climb_rate and _vel_desired.z, target_climb_rate =0.0 but _vel_desired.z !=0.0
Replies
The real reason is when use rangefinder : target_climb_rate is changed by get_surface_tracking_climb_rate
target_climb_rate = get_surface_tracking_climb_rate(target_climb_rate, pos_control->get_alt_target(), G_Dt);
I found the reason maybe this:
_vel_desired.z = constrain_float(climb_rate_cms, _vel_desired.z-vel_change_limit, _vel_desired.z+vel_change_limit);
_vel_desired.z !=climb_rate_cms because is chaged by this
I printf the result when climb_rate_cms =0.0 _vel_desired.z is a value between 0.0 but nvener be 0!!!!!!!!
I test here in loiter code :pos_control.set_alt_target_from_climb_rate_ff(target_climb_rate, G_Dt, false);
I printf:target_climb_rate _vel_desired.z when target_climb_rate =0.0,but _vel_desired.z != 0.0!!!!!