-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Feature Request: Add Mavlink Guided Mode via MAV_CMD Handling #10426
Comments
I'm wondering if the GCS ever gets any feature requests to use the MSP protocol? That would make the GCS more flexible. Instead, requests always go to the firmware, which is limited on space. The right solution to me, would be to use a GCS that works with MSP. Not force INAV to implement a protocol to work with ArduPilot's GCS. |
Space is an issue, which is definitely why there's a hard limit on mavlink implementation (although this specific feature wouldn't take much space at all), i've started a halfway compromise that is a translator/meta-controller running on a Pi that acts as mediator between MSP and Mavlink, but it's far from ideal or reliable. There are unfortunately no MSP GCS that run on android and no MSP SDKs at all (save for the one i am working on in my free time as an amateur, forked from a 10yo project) and can't possibly be trusted with real airframes). I think MWPtools is the only MSP GCS still alive, everything else is 10 years dead, and up to date documentation is pretty hard to find too. |
I have asked about that in the QGroundControl Discord. Note on GitHub, QGroundControl is under the Mavlink/ organization, so that may be a hint.
I've said the same many times. You've probably seen me say that in the INAV Discord. |
I somehow missed this notification. Thank you, yes that's basically the situation now. I didn't want to make this issue the central "Mavlink adoption question" debate stage but it's clear that Mavlink has imposed itself as the standard for GCS, APIs and even simulators. The more compatible we become with it, the more we can benefit from the mountain of work that's been done for APM and Pixhawk. It would allow us to use MAVSDK as an API and Airsim for quadcopter simulation, for example. MSP is absolutely fine for configuring the aircraft and simple tools, but for everything else we're really missing out which is a shame considering how great Inav has become. |
My 2 cents from a heavy user perspective: The problem is not the protocol itself but the way INAV Flight Modes work and are named. The same happens for WP missions. Ardupilot has dedicated WP functions for every action. INAV has Waypoints and WP additions, that are technically waypoints itself but act together with the previous waypoints to add functions. User-Actions are also not supported by any GCS applciation for Ardupilot. So the problem is NOT the protocol. the problem is that the GCS needs to support the features of the firmware and that is just not the case. We could add a few workarounds and translations in firmware to support a few more things but that would be a complete mess for the user as long as the GCS is not filtering out all unsupported functions. if QGC devs or MP devs would say "hey, lets add all the modes and functions that INAV supports in our application but we don't want to use MSP!" then it would be not a big deal to fully implement that on the INAV end. Right now that makes no sense at all. |
I think this nicely summarizes the problem. And much of the solution. It's not a really tidy translation where we have the exact same modes with the exact same names, but some are the the same and for others "that would be a combined ANGLE Mode with the ALTHOLD Modifier". It's not perfect, but it's likely doable - as doable as multirotor navigation without a compass or other things we've pulled off.
Meeting in the middle might be the way. They don't want to put in a bunch of work to do things the INAV way. There may be spots where we can't easily match up with what the GCS systems do. It may be easier to get them to change the 10% that we can't do on our side if we first do the parts we can. If there are folks who want to put in the time to do it. |
and to be fair. With all the Effort that Jonathan is putting in MWP now to bring it to windows and also supporting MacOS now... Where is the point? |
mwp provides support for "follow me", either by the user setting the desired point or from GCS GPS (at least on OS where |
I was referring to the "I put a gamepad to my Laptop and fly my Arduplane with that" kind of control :D |
It's true that MWP is making excellent progress, but i should point out that this wouldn't only help GCS software but also SDK compatibility, there are a lot more things that use mavlink apart from MP and QGC. |
Totally with you but as I pointed out above: speaking Mavlink does not mean they can communicate. If you have 2 persons talking, one is a Game developer and talks about lightning systems in game engines and the other one is a car mechanic and talks about fuel mixture levels. They can both speak English and still have no idea what the other person is talking about. Same happens here. the GCS needs to know what it can tell INAV to do. After that it does not matter if it tells INAV that over MSP or if we allow it to do that over Mavlink. |
Current Behavior
Currently INAV does not implement handling MAV_CMD messages (COMMAND_INT, COMMAND_LONG) which is how most Mavlink control is done, so most commands will fall on deaf ears. We say INAV "can't do" bi-directional MAVLINK control, but it's really just not implemented yet, there's nothing stopping us. A big portion of those commands are either not necessary for INAV or just untranslateable because of fundamental differences (ie, changing flight modes). One very useful mode is Guided mode, which already exists in INAV in the form of GCS NAV, but there is no way for now to use ie QGC or MP to control an INAV craft in Guided mode.
Desired Behavior
When the craft is in LOITER+GCS NAV mode, it should 1. return GUIDED as it's mavlink mode (PR already submitted), and 2. it should allow the GCS to command it by setting Waypoint 255.
Suggested Solution
Basically it needs to be able to handle MAV_CMD commands in processMAVLinkIncomingTelemetry(), namely COMMAND_INT messages. LONG vs INT is explained here
It would look something like this:
And then the main function to handle COMMAND_INT messages, which encapsulates many other types of messages, but namely handles MAV_CMD_DO_REPOSITION (for copters) and if BOXGCSNAV is active sets Waypoint 255 and returns the right message to the GCS (this Mavlink code might be wrong, i haven't completed it yet, it's for demonstration).
So the craft will be on it's way to the new position.
Who does this impact? Who is this for?
This is going to be a big improvement for people who want to use Mavlink with INAV, Guided mode is a very useful and popular way of controlling non-FPV planes and copters with a GCS or co-computers using Mavsdk or similar. The code to handle MAV_CMD messages is also going to be the entry point for implementing more and more Mavlink functionality as to make INAV more compatible and interoperable with many more types of GCS software including Mission Planner, QGC, APMPlanner, UASTOOL, etc. This will also make stuff like ELRS-Mavlink and mLRS a lot more useful with INAV.
Additional context
I already started the beginning of a (probably not the best) implementation here, i mostly covered the basis above
master...xznhj8129:inav:mavlink_gcs_nav
There is an additional small issue that in some GCS, namely QGC and MP, they do not correctly map the modes returned by INAV; ie they show "Custom mode 0x4" or something instead of the correct ie ACRO; and that locks out most of the mode-related commands (such as GOTO). I found that changing MAV_AUTOPILOT_GENERIC to MAV_AUTOPILOT_ARDUPILOTMEGA in mavlink_msg_heartbeat_pack will make them correctly recognize the modes and unlock the functionality, but it makes them very angry that they're not getting parameters. Interestingly, Mavproxy has no problem with that. I haven't PR'ed this change because i'm not sure if this causes effects i don't know about and i'm not sure where the problem lies exactly, in INAV or the GCS softwares; someone more knowledgeable could look into that.
Some other MAV_CMD commands (not this one) also take some time to complete, so you also need to send IN_PROGRESS messages while waiting for the result, see here https://mavlink.io/en/services/command.html#long_running_commands
The text was updated successfully, but these errors were encountered: