mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 19:07:45 +08:00
mc_pos_control: refactor the update of the desired waypoints for avoidance
to eliminate duplicated code
This commit is contained in:
@@ -3300,10 +3300,11 @@ MulticopterPositionControl::task_main()
|
|||||||
_local_pos_sp.vy = _vel_sp(1);
|
_local_pos_sp.vy = _vel_sp(1);
|
||||||
_local_pos_sp.vz = _vel_sp(2);
|
_local_pos_sp.vz = _vel_sp(2);
|
||||||
|
|
||||||
/* desired waypoints for obstacle avoidance */
|
/* desired waypoints for obstacle avoidance:
|
||||||
if (_pos_sp_triplet.current.valid) {
|
* point_0 containes the current position with the desired velocity
|
||||||
|
* point_1 containes _pos_sp_triplet.current if valid
|
||||||
|
* point_2 containes _pos_sp_triplet.next if valid */
|
||||||
|
|
||||||
/* point_0 containes the current position with the desired velocity */
|
|
||||||
update_avoidance_waypoint_desired(trajectory_waypoint_s::POINT_0, _pos(0), _pos(1), _pos(2), _vel_sp_desired(0),
|
update_avoidance_waypoint_desired(trajectory_waypoint_s::POINT_0, _pos(0), _pos(1), _pos(2), _vel_sp_desired(0),
|
||||||
_vel_sp_desired(1), _vel_sp_desired(2), NAN, NAN, NAN, _yaw, NAN);
|
_vel_sp_desired(1), _vel_sp_desired(2), NAN, NAN, NAN, _yaw, NAN);
|
||||||
|
|
||||||
@@ -3317,12 +3318,6 @@ MulticopterPositionControl::task_main()
|
|||||||
_pos_sp_triplet.next.z, NAN, NAN, NAN, NAN, NAN, NAN, _pos_sp_triplet.next.yaw, NAN);
|
_pos_sp_triplet.next.z, NAN, NAN, NAN, NAN, NAN, NAN, _pos_sp_triplet.next.yaw, NAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
update_avoidance_waypoint_desired(trajectory_waypoint_s::POINT_0, _pos(0), _pos(1), _pos(2), _vel_sp_desired(0),
|
|
||||||
_vel_sp_desired(1), _vel_sp_desired(2), NAN, NAN, NAN, _yaw, NAN);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* publish local position setpoint */
|
/* publish local position setpoint */
|
||||||
if (_local_pos_sp_pub != nullptr) {
|
if (_local_pos_sp_pub != nullptr) {
|
||||||
orb_publish(ORB_ID(vehicle_local_position_setpoint), _local_pos_sp_pub, &_local_pos_sp);
|
orb_publish(ORB_ID(vehicle_local_position_setpoint), _local_pos_sp_pub, &_local_pos_sp);
|
||||||
|
|||||||
Reference in New Issue
Block a user