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

Provide more information about how Guided mode for plane works #6096

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

timtuxworth
Copy link
Contributor

While working on "plane follow" in Lua, I was puzzled by the behavior of the plane in Guided mode using mavlink commands

  • DO_REPOSITION
  • GUIDED_CHANGE_HEADING
  • GUIDED_CHANGE_ALTITUDE

and while digging into the code, I discovered that Guided seems to have two effectively mutually exclusive "sub modes" - Guided Heading and Guided Location, which treat altitude differently. This is me explaining what I think I can see because others might find this useful if I'm right, or to be corrected if I'm missing something.

stations support a "click to fly to" feature where you can click a point
on the map and the aircraft will fly to that location then loiter.
on the map and the aircraft will fly to that location then loiter. If an
altitude is requested, the aircraft will fly at the current altitude until
Copy link
Member

@IamPete1 IamPete1 Jul 6, 2024

Choose a reason for hiding this comment

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

It will fly to the new altitude immediately. The point has to be far enough away that it can finish the altitude change before it get there of course. You could double check in SITL.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've done extensive testing in SITL - this is what I'm seeing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also see ArduPlane/navigation.cpp:45 where the comment (and code) specifically says:

 // once we reach the position target we start checking the
 // altitude target

Copy link
Member

@IamPete1 IamPete1 Jul 6, 2024

Choose a reason for hiding this comment

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

I'm sure. To check I have also run in SITL. Very easy, mode takeoff arm (takes off to 50m), guided fly to somewhere a long way away at 100m. We get this:
image

Climb starts immediately, 100m is reached well before destination.

Note that if its a climb it will climb as fast as possible, where as a descent will glide such that it reaches the destination and the altitude at the same time.

The only case where it will still be changing altitude once it has reached the destination is if the change in altitude is sufficiently large it cannot be achieved in the available horizontal distance.

The code your looking at has nothing to do with the setting of target altitudes, it is what checks when we have reached the desired location so we can move on to the next waypoint for example.

How have you been testing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm running two arduplane SITL binaries, one of them is sending MAVLink updates to the other, the 2nd is using AP_Follow to receive the target plane info and then Lua script to call the new Lua run_command_int DO_REPOSITION command.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I see the problem I have @IamPete1 - my code calls DO_REPOSITION at 10Hz as it gets new position data from the plane it is following via MAVLink. I think this means it stays on the first part of your graph - where the altitude is level - and never gets a chance to head up before I hit it with a new position.

@timtuxworth timtuxworth force-pushed the guided_mode branch 2 times, most recently from abf5411 to ec6f61c Compare July 6, 2024 16:02
Copy link
Contributor Author

@timtuxworth timtuxworth left a comment

Choose a reason for hiding this comment

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

Not a review

stations support a "click to fly to" feature where you can click a point
on the map and the aircraft will fly to that location then loiter.
on the map and the aircraft will fly to that location then loiter. If an
altitude is requested, the aircraft will fly at the current altitude until
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've done extensive testing in SITL - this is what I'm seeing.

plane/source/docs/guided-mode.rst Outdated Show resolved Hide resolved
@timtuxworth timtuxworth force-pushed the guided_mode branch 2 times, most recently from b7f3fcb to e332431 Compare July 6, 2024 23:01
plane/source/docs/guided-mode.rst Show resolved Hide resolved
plane/source/docs/guided-mode.rst Show resolved Hide resolved
plane/source/docs/guided-mode.rst Outdated Show resolved Hide resolved
@Hwurzburg
Copy link
Contributor

@IamPete1 can you approve?

@timtuxworth
Copy link
Contributor Author

Could you recheck @Hwurzburg, @IamPete1?

Is this what you are seeing @EyesWider ?

Copy link
Contributor

@Hwurzburg Hwurzburg left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@Ryanf55 Ryanf55 left a comment

Choose a reason for hiding this comment

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

This is a nice improvement to the docs, can we merge?

@Hwurzburg
Copy link
Contributor

@IamPete1 needs to approve

stations support a "click to fly to" feature where you can click a point
on the map and the aircraft will fly to that location then loiter.
GUIDED mode is used when you want the aircraft to fly to a specific
point on the map, or in specific direction (heading) without setting up a mission.
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
point on the map, or in specific direction (heading) without setting up a mission.
point on the map, or in specific direction (heading) without setting up a mission.
GUIDED mode also supports overrides.

For more information about this, see the MAVLink GUIDED_CHANGE_HEADING documentation
https://mavlink.io/en/messages/ardupilotmega.html#MAV_CMD_GUIDED_CHANGE_HEADING


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
Atttitude Overrides
---------------------
These overrides take priority. `SET_ATTITUDE_TARGET` can command roll, pitch, yaw, and throttle overrides.
Guided Slew Commands
---------------------------
`GCS_MAVLINK_Plane::handle_command_int_guided_slew_commands` sets `plane.guided_state.target_airspeed_cm`, `plane.guided_state.target_alt_rate`, `plane.guided_state.target_heading`, and more.

While this PR does improve the docs by documenting more ways that guided works, it's missing a few of the other supported modes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, your "Atttitude" has an extra t

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.

5 participants