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

Camera: switch to new REQUEST_MESSAGE commands #11571

Closed
wants to merge 4 commits into from

Conversation

julianoes
Copy link
Contributor

Description

The used commands like REQUEST_CAMERA_SETTINGS and REQUEST_CAMERA_INFORMATION are deprecated. Therefore, we should gradually try to move to the new REQUEST_MESSAGE commands.

This commit does so by sending REQUEST_MESSAGE by default but falling back to the previous commands on the second try and every other retry after that.

Test Steps

Need to test it manually with one of my camera-manager example.

Checklist:

@julianoes julianoes requested a review from HTRamsey May 30, 2024 03:21
@julianoes julianoes changed the base branch from master to pr-fixup-sensors May 30, 2024 03:45
Base automatically changed from pr-fixup-sensors to master May 30, 2024 04:17
Copy link
Collaborator

Choose a reason for hiding this comment

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

I may be mistaken, but I believe Ardupilot would return MAV_RESULT_UNSUPPORTED which would just exit out silently here right?

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 can't have a close look now but I Randy tested it and it worked apparently. If your testing is different, then we have to address it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh nvm if it doesn't support the REQUEST_MESSAGE msgid then it will return MAV_RESULT_FAILED. At some point we should handle MAV_RESULT_UNSUPPORTED somewhere but doesn't matter for this PR.

The used commands like REQUEST_CAMERA_SETTINGS and
REQUEST_CAMERA_INFORMATION are deprecated. Therefore, we should
gradually try to move to the new REQUEST_MESSAGE commands.

This commit does so by sending REQUEST_MESSAGE by default but falling
back to the previous commands on the second try and every other retry
after that.
This fixes getting the video stream.
By querying autopilot for the CAMERA_INFORMATION message, we allow an
autopilot to be a proxy for a MAVLink or non-MAVLink camera.

The idea is similar to a gimbal manager implemented by an autopilot.
Since we no longer request cameras to have specific camera component IDs
but allow the autopilot to "be" a camera as well, we need to adjust the
unit tests to account for that.
@DonLakeFlyer
Copy link
Contributor

Vehicle has built in request message with retries support:

    /// Requests the vehicle to send the specified message. Will retry a number of times.
    ///     @param resultHandler Callback for result
    ///     @param resultHandlerData Opaque data passed back to resultHandler
    void requestMessage(RequestMessageResultHandler resultHandler, void* resultHandlerData, int compId, int messageId, float param1 = 0.0f, float param2 = 0.0f, float param3 = 0.0f, float param4 = 0.0f, float param5 = 0.0f);

You should use that instead of building your own.

// are taking the response to that MAV_CMD_REQUEST_MESSAGE, we discard it and take the next
// Also, the camera manager requests MAVLINK_MSG_ID_CAMERA_INFORMATION on vehicle connection,
// so we need to ignore that as well.
while (arguments.at(2).toInt() == MAV_CMD_REQUEST_MESSAGE || arguments.at(2).toInt() == MAV_CMD_REQUEST_CAMERA_INFORMATION) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is kinda nasty and fragile. There is already the concept of creating a connect to a mock link vehicle which does not do the initial vehicle connect sequence. This is specifically for unit test problems like this. Would it be possible to hook in the gimbal request stuff into the vehicle initial connect sequence state machine so that a it only happens if that was run?

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 can try that but I will have to do a bit more reading to understand these tests. It's all a mystery to me.

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't worry about it. I'll clean this up after it's merged in. Will be easier for me to deal with it than have you figure out something new to you.

Copy link
Contributor

Choose a reason for hiding this comment

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

Same thing the the request message stuff. I can switch that over as well.

@DonLakeFlyer
Copy link
Contributor

DonLakeFlyer commented Aug 19, 2024 via email

@DonLakeFlyer
Copy link
Contributor

@julianoes So in looking through these changes the main functional change is the checking of compids is a little different on the camera manager. The rest is to move to request message. Instead of merging this in and then me futzing with it. Can we instead just leave this pull here for now. And I will create a replacement pull for it. That will be easier.

@DonLakeFlyer
Copy link
Contributor

Ok, so I'm confused now. I just went to create a pull for this and it looks like this change is already in master:

https://github.com/mavlink/qgroundcontrol/blob/master/src/Camera/QGCCameraManager.cc#L406

@DonLakeFlyer
Copy link
Contributor

Didn't look at the date on this. This is super old. The changes in the pull are already in master. I'm working on cleaning up master per my above comments. @julianoes I think you can close this?

@julianoes
Copy link
Contributor Author

Oh, I'm sorry for the confusion. I didn't look at the date either.

@julianoes julianoes closed this Aug 20, 2024
@julianoes julianoes deleted the pr-camera-request-message branch August 20, 2024 01:32
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