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

PX4 in SITL mode is saying MAV_CMD_NAV_GUIDED_ENABLE is MAV_RESULT_UNSUPPORTED ? #17276

Closed
lovettchris opened this issue Mar 31, 2021 · 6 comments

Comments

@lovettchris
Copy link
Contributor

Describe the bug
AirSim uses MAV_CMD_NAV_GUIDED_ENABLE to request offboard mode, latest master bits are returning the MAV_RESULT::MAV_RESULT_UNSUPPORTED ? So how does one get the PX4 into offboard mode?

To Reproduce
Steps to reproduce the behavior:

  1. Connect a simulator to PX4
  2. Wait for it to have good GPS lock and a home position
  3. Arm the drone and take off
  4. Now try and send MAV_CMD_NAV_GUIDED_ENABLE requesting offboard mode.

Expected behavior
Should succeed.

Log Files and Screenshots
https://logs.px4.io/plot_app?log=cd71c873-321e-4514-8c3c-a3aaca0f459f

Additional context
Use this version of AirSim if you are so inclined:
microsoft/AirSim#3546

@dagar
Copy link
Member

dagar commented Mar 31, 2021

I removed this in d0c9a5f#diff-72c9e73ba02675201cb800fd25efcb3b3e52e2fb00d22b191ac16f6d886b7c2b because I couldn't find any existing usage, but apparently I didn't search hard enough.

The "normal" usage of OFFBOARD is that you start streaming your offboard setpoints then switch the mode. I can restore MAV_CMD_NAV_GUIDED_ENABLE if you think there's value.

@lovettchris
Copy link
Contributor Author

lovettchris commented Mar 31, 2021

I see well I'll try changing AirSim to the new way then, would be nice if there were better docs on this. I assume that means sending MAVLINK_MSG_ID_SET_MODE with custom_mode.main_mode set to PX4_CUSTOM_MAIN_MODE_OFFBOARD ? And I assume all the other parameters (base_mode, sub_mode) are copied from the previous heartbeat status fields?

@dagar
Copy link
Member

dagar commented Apr 1, 2021

Yes that sounds right.

Roughly what are you using OFFBOARD for? The usage is really geared towards people doing some kind of control via MAVROS and wanting to send setpoints straight into one of the controllers (rate, attitude, velocity, local position). That's why you need to be in OFFBOARD mode then send a continuous stream of setpoints.

If all you want to do is simply move a vehicle around I'd suggest taking a look at MAV_CMD_DO_REPOSITION instead.
https://mavlink.io/en/messages/common.html#MAV_CMD_DO_REPOSITION

@lovettchris
Copy link
Contributor Author

lovettchris commented Apr 1, 2021

AirSim uses offboard for advanced flight control programmed by python scripts mostly using MavLinkSetPositionTargetLocalNed. The python scripts can do fun things like flying in a perfect spiral pattern, etc.

@lovettchris
Copy link
Contributor Author

lovettchris commented Apr 1, 2021

I got it working now, thanks. See https://youtu.be/DiqgsWIOoW4. So I'm closing the issue.

@dagar
Copy link
Member

dagar commented Apr 1, 2021

Great, thanks for sharing.

The other thing to note with OFFBOARD is that the setpoints are going straight into the controllers. So if you want things like trajectory smoothing you'll need to do it "higher level" going through interfaces like MAV_CMD_DO_REPOSITION that use the same path as mission execution.

Let me know if there's anything we can expand on to improve your use case.

I aspire to one day have a workstation fast enough to start using AirSim. 😏

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

No branches or pull requests

2 participants