mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 17:43:34 +08:00
capture position once to rule out changes while function runs
This commit is contained in:
@@ -267,12 +267,13 @@ void FlightTaskAuto::_prepareLandSetpoints()
|
|||||||
Sticks::rotateIntoHeadingFrameXY(sticks_ne, _yaw, _land_heading);
|
Sticks::rotateIntoHeadingFrameXY(sticks_ne, _yaw, _land_heading);
|
||||||
|
|
||||||
const bool land_radius_enabled = _param_mpc_land_radius.get() > 0.0f;
|
const bool land_radius_enabled = _param_mpc_land_radius.get() > 0.0f;
|
||||||
const bool position_valid = Vector2f(_position).isAllFinite();
|
const Vector3f pos = _position; // To avoid it updating in between
|
||||||
|
const bool position_valid = Vector2f(pos).isAllFinite();
|
||||||
|
|
||||||
float max_speed = INFINITY;
|
float max_speed = INFINITY;
|
||||||
|
|
||||||
if (position_valid && land_radius_enabled) {
|
if (position_valid && land_radius_enabled) {
|
||||||
const float distance_to_circle = math::trajectory::getMaxDistanceToCircle(_position.xy(), _initial_land_position.xy(),
|
const float distance_to_circle = math::trajectory::getMaxDistanceToCircle(pos.xy(), _initial_land_position.xy(),
|
||||||
_param_mpc_land_radius.get(), sticks_ne);
|
_param_mpc_land_radius.get(), sticks_ne);
|
||||||
|
|
||||||
if (PX4_ISFINITE(distance_to_circle)) {
|
if (PX4_ISFINITE(distance_to_circle)) {
|
||||||
@@ -293,7 +294,7 @@ void FlightTaskAuto::_prepareLandSetpoints()
|
|||||||
PX4_INFO(" max speed: %.2f", (double) max_speed);
|
PX4_INFO(" max speed: %.2f", (double) max_speed);
|
||||||
|
|
||||||
_stick_acceleration_xy.setVelocityConstraint(max_speed);
|
_stick_acceleration_xy.setVelocityConstraint(max_speed);
|
||||||
_stick_acceleration_xy.generateSetpoints(sticks_xy, _yaw, _land_heading, _position,
|
_stick_acceleration_xy.generateSetpoints(sticks_xy, _yaw, _land_heading, pos,
|
||||||
_velocity_setpoint_feedback.xy(), _deltatime);
|
_velocity_setpoint_feedback.xy(), _deltatime);
|
||||||
_stick_acceleration_xy.getSetpoints(_land_position, _velocity_setpoint, _acceleration_setpoint);
|
_stick_acceleration_xy.getSetpoints(_land_position, _velocity_setpoint, _acceleration_setpoint);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user