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

update mission after changing home position #22834

Merged
merged 4 commits into from
Mar 20, 2024
Merged

update mission after changing home position #22834

merged 4 commits into from
Mar 20, 2024

Conversation

Drone-Lab
Copy link
Contributor

@Drone-Lab Drone-Lab commented Mar 4, 2024

Solved Problem

fix the bug which cause drone can't finish mission after changing home altitude.Update mission after changing home position.

Summary

This state management bug will result in the drone being unable to reach the waypoint and thus continuing the mission.And continues to drift irregularly near the waypoints.

Details

  1. When the drone is executing a mission, PX4 calculates the distance between the drone and the current target waypoint, and checks if it has reached the vicinity.

    Here calculates the distance.

    dist = get_distance_to_point_global_wgs84(_mission_item.lat, _mission_item.lon, mission_item_altitude_amsl,
    _navigator->get_global_position()->lat,
    _navigator->get_global_position()->lon,
    _navigator->get_global_position()->alt,
    &dist_xy, &dist_z);

    When mission altitude mode is Relative to Launch mission_item_altitude_amsl=mission_item.altitude + home_alt

    And here checks whether it is less than the acceptable radius.

    if (dist_xy >= 0.0f && (dist_xy <= acceptance_radius || passed_curr_wp) && dist_z <= alt_acc_rad_m) {
    _waypoint_position_reached = true;
    }

  2. When the drone is executing a mission, if the user modifies the home point to a new location (with a different altitude), the value of 'dist' will immediately change based on the new home point's altitude (which determines the check for whether the drone has reached the waypoint). However, the current actual executed 'mission_item' does not get updated.

    This will result in a discrepancy between the actual executed target of the drone and the checked completion target, causing the drone to start randomly oscillating near the waypoint.

image

Verification

We added some debug output to watch the drone's state change,and found every time the user changes the home point, 'dist_z' (altitude) also changes accordingly, but the 'mission_item' does not.

Temporary Patch

There are currently two patching approaches based on the expectations for how the drone should operate after modifying the home point:

  1. After changing the drone's home point altitude, the currently executed mission target should also change immediately
  2. Once the mission is uploaded and completed, the 'mission_item' should no longer change, even if the home altitude changes; the waypoint altitude should remain relative to the altitude at the time of mission upload

Impact

  • This vulnerability could be exploited by attackers for covert attacks
  • When a benign user modifies the home point while the drone is executing a mission, the drone may oscillate, come into contact with surrounding obstacles, and ultimately crash
  • Modifying the home point to a new location during the mission execution will result in the drone randomly drifting near the next waypoint. This could lead to collisions and crashes.[Bug] Modifying home during Mission execution affects UAV's current Item completion detection #22576
can.t.reach.waypoint.mp4

Some bugs prevent you from directly viewing the video.You can download and check this vedio.

image

Solution

  • Add an update for the current setpoint altitude when the home point is changed.

Test coverage

@Drone-Lab
Copy link
Contributor Author

@bkueng Following your advice, I utilized _navigator->get_home_position()->update_count.

@Drone-Lab
Copy link
Contributor Author

Resolved Conflict Code

@Drone-Lab Drone-Lab reopened this Mar 11, 2024
@Drone-Lab
Copy link
Contributor Author

@KonradRudin Looking forward to receiving your advice.

Copy link
Contributor

@KonradRudin KonradRudin left a comment

Choose a reason for hiding this comment

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

Thansk for the bug fix. Looks fine to me, just extend it for the previous and next as well.

src/modules/navigator/mission_base.cpp Outdated Show resolved Hide resolved
@Drone-Lab
Copy link
Contributor Author

@KonradRudin How about this modification?

src/modules/navigator/mission_base.cpp Outdated Show resolved Hide resolved
src/modules/navigator/mission_base.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@KonradRudin KonradRudin left a comment

Choose a reason for hiding this comment

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

Thanks for the changes. Looking good for me, but there seems to be a conflict we recent changes. If you rebase it on newest main, i can approve.

@Drone-Lab
Copy link
Contributor Author

Thanks for the changes. Looking good for me, but there seems to be a conflict we recent changes. If you rebase it on newest main, i can approve.

@KonradRudin Thank you for your feedback! I've addressed the conflict and rebased the changes on the latest main branch.

KonradRudin
KonradRudin previously approved these changes Mar 14, 2024
@Drone-Lab
Copy link
Contributor Author

@bkueng it's ready to merge

@bkueng
Copy link
Member

bkueng commented Mar 18, 2024

Can you run make format, commit the result & rebase? CI should then pass.

@Drone-Lab
Copy link
Contributor Author

Can you run make format, commit the result & rebase? CI should then pass.

@bkueng OK ,I have finished it.

@Drone-Lab Drone-Lab changed the title fix the bug which cause drone can't finish mission after changing home altitude update mission after changing home position Mar 19, 2024
@bkueng bkueng merged commit 37cadde into PX4:main Mar 20, 2024
88 of 89 checks passed
Peize-Liu pushed a commit to Peize-Liu/PX4-Autopilot that referenced this pull request Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants