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

Add support for multi-GCS operation #12410

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open

Conversation

Davidsastresas
Copy link
Member

@Davidsastresas Davidsastresas commented Feb 8, 2025

This PR adds support for the recently added multi-GCS mavlink subprotocol mavlink/mavlink#2158. This allows graceful change in control ownership on a system with multiple GCS. Please note this subprotocol does not attempt to cover security, it assumes all the operators are in contact between them and they work in a collaborative manner.

For more information about the protocol itself, please read that thread instead. Mavlink docs will be updated shortly, when we confirm all of this looks good.

On this PR, the implementation is as follows:

New top toolbar indicator

This indicator will be populated if the active vehicle is sending the new CONTROL_STATUS message. On this icon we can grasp:

  • System Id in control
  • If this GCS is currently in control
  • If takeover is allowed automatically, or we need to ask to the GCS in control first.

Note this icon will have an animation effect whenever the control status changes, whether it is because of a change in takeover allowed, or because of a change in system in control.

This way, we have some variants:

Screenshot from 2025-02-08 16-11-27
On this case this GCS (252) is in control, as we see the the sysId label green, and also the aircraft icon and the segment joining label and aircraft.

Screenshot from 2025-02-08 16-16-03
On this case, this GCS (252) is not in control ( label is white, not green ), and also the aircraft icon and segment joining is white, indicating automatic takeover is not allowed ( we need to ask to the GCS in control first )

Screenshot from 2025-02-08 16-18-01
On this case it is similar to the above situation, only automatic takeover is allowed ( aircraft icon in green ) so we don't need to request permission to the GCS in control, we can adquire control directly.

Expanded menu after clicking top toolbar indicator

After clicking the top toolbar icon, we see an expanded panel. This panel changes depending on the particular control situation. On this panel, we can:

  • See what system id is in control, and see it highlighted in green when it is us
  • See if automatic takeover is allowed, or the requesting GCS needs to ask permision first
  • Send control requests, in case we are not in control
  • If we are in control, we can change if automatic takeover is allowed or not
  • We can also change SystemID of this GCS from here, similar to how we usually do in the general settings -> telemetry settings
    Screenshot from 2025-02-08 16-19-49

Control request procedure when takeover is allowed

In the most simple case where we are not in control and takeover is allowed, just clicking "Acquire control" will grant us control of the vehicle.
Note that on this situation, we can choose before acquiring control if we want to allow automatic takeover or not, on the tickbox. If we want to change this after being in control it is possible too, see previous screenshot.
Screenshot from 2025-02-08 16-24-19

Control request procedure when takeover is not allowed

On this situation, we will have the following panel:
Screenshot from 2025-02-08 16-26-44
Clicking "send request" will send a control request to the GCS in control, with a timeout specified in "Request timeout (sec)", in this case 7 seconds. This timeout will be sent as a parameter in the command, to syncronize progress indicators in both GCS.
We can not sent another request until that timeout expires. This way, after clicking "send request", we will see the following:
Screenshot from 2025-02-08 16-28-14

And in the current GCS in control, a popup will appear indicating the request, with a syncronized countdown:
Screenshot from 2025-02-08 16-29-32
Clicking "Ignore" will just discard the popup, with no consequences, and if we click "allow takeover" the requestor GCS will be able to adquire control directly, as in the previous section "Control request procedure when takeover is allowed". However, we will see the following popup appear:

Screenshot from 2025-02-08 16-32-13
We have a timeout of 10 seconds after clicking "allow takeover" above. If after those 10 seconds the requestor GCS didn't take control, automatic takeover will be set to disabled again. This will happen regardless of discarding ( clicking Ignore ) on the panel above. This is done as a security measure so operators don't forget they accepted a takeover that was never fully completed.

Aditional comments

A couple of new command line arguments were added, in order to make testing easier:

  • Argument to specify system id con command line when launching the app, useful for sending 2 instances at the same time with different sysid regardless of offline settings
--system-id:254
  • Argument to be able to run multiple instances at the same time, by default only one instance of QGC can run
--allow-multiple

Using both arguments it is handier to test this in SITL

Testing status

This has been tested in SITL using the following Ardupilot branch ArduPilot/ardupilot#29252

Here is a short video showing this testing:

multi-GCS-demo-2025-02-08_17.12.46.mp4

For awareness @hamishwillee @rmackay9. Also @julianoes might want to take a look at it too, for Px4 support.

Thanks to https://harrisaerial.com and https://www.lincesystems.com for sponsoring this PR, and to @hamishwillee for his wise and valuable support, experience and patience during all the iterations that preceded this work.

Useful to test several instances of QGC on the same machine, to test
multi GCS setups
@HTRamsey
Copy link
Collaborator

HTRamsey commented Feb 8, 2025

--allow-multiple is only for testing right? There's probably a lot of potential issues with running multiple instances but I guess it doesn't matter that much if it's just meant for testing. https://github.com/itay-grudev/SingleApplication has a neat concept of primary/secondary instances that could be used to better support multiple instances in the future.

@Davidsastresas
Copy link
Member Author

Davidsastresas commented Feb 8, 2025

@HTRamsey Yes, it is only meant for testing. I really can not imagine a situation on real world usage where you would want to have 2 GCS instances.

As it is a command line argument, I doubt users will boot QGC with this option without noticing in a production GCS.

I would really like to leave that option, I don't need multiple QGC instances often, but every now and then it helps to have during development, I think it is handy to have. I checked the SingleApplication link you mentioned, it is very interesting, but I think it is overkill for us, at least for the moment. Thanks!

@DonLakeFlyer
Copy link
Contributor

DonLakeFlyer commented Feb 14, 2025

I haven't look in detail yet, but a few things:

  • development.xml things should only be supported in debug builds. So the addition of the indicator to the toolbar should be ifdef'ed.
  • What's your thinking around dim=false? Not so thrilled about some dropdowns dim and some not. If it makes sense then I think it would make sense for all of them to not be dim.
  • Similar to development.xml I would make --allow-multiple debug build only.
  • Can you update the docs for this as well (explaining debug only for now)

@Davidsastresas
Copy link
Member Author

@DonLakeFlyer

  • About dimming or not, first time we used that was for gimbal indicator, it is like that on Stable. I get your logic of doing all of them or none of them. If I had to choose I would choose to not dim. Sometimes it could be interesting for an operator to have one of those extended panels to visualize some extended telemetry, or in the case of gimbal control to have the controls handy.

My logic to not dim this one, together with gimbal control, is that users might want to eventually leave the panel open momentarily during some part of the operation, and dim is inconvenient on such scenarios.

I pushed a couple off commits addressing the QT_DEBUG matter for controlIndicator.qml and --allow-multiple argument.

@DonLakeFlyer
Copy link
Contributor

  • About dimming or not...

Reasonable. I didn't even know not dimming was an option. Can you make them all not dim by changing main popup in MainRootWindow and then remove the option of dim or not. I think that's better overall.

  • About docs

Make sense

@Davidsastresas
Copy link
Member Author

@DonLakeFlyer I applied your latest comments, thanks for the review!

@@ -109,4 +109,9 @@
<qresource prefix="/gimbal">
<file alias="payload.svg">resources/gimbal/payload.svg</file>
</qresource>
<qresource prefix="/controlIndicator">
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be more intuitive if there where gcscontrolindicator

@@ -13,6 +13,7 @@
<file alias="TelemetryRSSIIndicator.qml">src/UI/toolbar/TelemetryRSSIIndicator.qml</file>
<file alias="APMSupportForwardingIndicator.qml">src/UI/toolbar/APMSupportForwardingIndicator.qml</file>
<file alias="GimbalIndicator.qml">src/UI/toolbar/GimbalIndicator.qml</file>
<file alias="ControlIndicator.qml">src/UI/toolbar/ControlIndicator.qml</file>
Copy link
Contributor

Choose a reason for hiding this comment

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

Same things here: GCSControlIndicator

@@ -0,0 +1,74 @@
import QtQuick
Copy link
Contributor

Choose a reason for hiding this comment

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

I would rename this TimedProgressTracker

@@ -647,6 +651,16 @@ void Vehicle::_mavlinkMessageReceived(LinkInterface* link, mavlink_message_t mes
_handleMessageInterval(message);
break;
}
case MAVLINK_MSG_ID_CONTROL_STATUS:
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the scoping here? There are no additional variables defined in the scoping so it's not needed.

if (commandLong.target_system != MAVLinkProtocol::instance()->getSystemId()) {
return;
}
if (commandLong.command == MAV_CMD(32100)) { // MAV_CMD_REQUEST_OPERATOR_CONTROL
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the magic number here?

safeRequestTimeoutSecs = SettingsManager::instance()->flyViewSettings()->requestControlTimeout()->cookedDefaultValue().toInt();
}
sendMavCommand(_defaultComponentId,
MAV_CMD(32100), // MAV_CMD_REQUEST_OPERATOR_CONTROL
Copy link
Contributor

Choose a reason for hiding this comment

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

Magic number?

}
sendMavCommand(_defaultComponentId,
MAV_CMD(32100), // MAV_CMD_REQUEST_OPERATOR_CONTROL
false, // Don't show errors, as per Mavlink control protocol Autopilot will report result failed prior to forwarding the request to the GCS in control.
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if there is no response from the vehicle because the message never makes it to the vehicle.

@DonLakeFlyer
Copy link
Contributor

The other top level problem with this is that the toolbar indicator dropdown doesn't really match the new style of ui. That's fine for now. I can come in after this is merged in and clean it up.

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.

3 participants