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

Handle GoPro mavlink heartbeat, shutter toggle, and capture mode toggle #13528

Merged
merged 4 commits into from
Feb 18, 2020

Conversation

Pedals2Paddles
Copy link
Contributor

@Pedals2Paddles Pedals2Paddles commented Feb 9, 2020

This enables the use of a Solo gimbal on a vehicle other than a Solo. Also has some use on the Solo itself to allow mission/gcs camera triggers to work out of the box.

Updated 2/11/2020 after much debate over library location

GCS_Mavlink:

  • Routing of the GoPro/Gimbal heartbeat to the AP_Camera library.
  • This gives us the camera's status, mode, and recording flag to be consumed by other new functions.
  • This was not previously handled or consumed, but has always been there going nowhere.

AP_Camera:

  • Creates AP_Camera/AP_Camera_SoloGimbal to handle the camera on the gimbal.
  • Parse the gimbal's heartbeat for status, mode, and recording state.
  • Added function to toggle the shutter command. This will take a photo, or start/stop video depending on what mode you're in.
  • Added a function to toggle the capture mode between photo and video.
  • GCS text tells the operator what it's doing.
  • Added option 2 for parameter CAM_TRIGG_TYPE. Will trigger the GoPro shutter toggle rather than servo or relay shutters.
  • This also ends up getting called by anything using mav_cmd_do_digicam_control, such as auto mode missions and GCS camera trigger buttons. So those functions will now work on the Solo as well.

RC_Channel:

  • Added RC aux switch option 102 to toggle the GoPro mode. So for example a momentary switch on RC8 could be set with RC8_OPTION=102
  • Momentary switch calls into the mount library to toggle modes between photo and video.

Tested and working on my quad with a solo gimbal strapped to the bottom of it.

@khancyr
Copy link
Contributor

khancyr commented Feb 9, 2020

Hello,
Why put this into ap_mount and not all in ap_camera?

@andyp1per
Copy link
Collaborator

andyp1per commented Feb 9, 2020 via email

@Pedals2Paddles
Copy link
Contributor Author

Mainly because it's all a function of the gimbal, not the camera. The mount library is already doing lots of exising mavlink communication with this gimbal. It is also not communication that would ever take place without that gimbal. So the mount library is the appropriate place for it.

@khancyr
Copy link
Contributor

khancyr commented Feb 9, 2020

wait ? That isn't to control the gopro but a gimbal? Then the name isn't the right one... that is confusing. If we aren't controling a gopro, that shouldn't be named gopro ... and it should then belong to AP_Mount_SoloGimbal and not the main class

@Pedals2Paddles
Copy link
Contributor Author

It controls the GoPro, and only a GoPro, which is a function of the Solo Gimbal, and only the Solo Gimbal. The title is correct because all these mavlink messages are gopro messages, such as mavlink_msg_gopro_set_request_send. Everything is in the correct libraries.

@Pedals2Paddles Pedals2Paddles changed the title Handle GoPro mavlink heartbeat and shutter commands Handle GoPro mavlink heartbeat, shutter toggle, and capture mode toggle Feb 9, 2020
Copy link
Contributor

@khancyr khancyr left a comment

Choose a reason for hiding this comment

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

Solo and gopro stuff shouldn't be spread on main class.

Solo gopro control has nothing to do with AP_mount, the control should be in ap_camera or restrain to ap_mount_sologimbal

@Pedals2Paddles
Copy link
Contributor Author

Solo and gopro stuff shouldn't be spread on main class.

It is required to be in the main class. The main class is how anything gets into the mount instances. As is the case for all the existing mount library functions accessed from outside the library...

Solo gopro control has nothing to do with AP_mount, the control should be in ap_camera or restrain to ap_mount_sologimbal

As previously described, it has everything to do with it. Everything is in the appropriate place. Mount drivers do not go in the camera library.

@khancyr
Copy link
Contributor

khancyr commented Feb 9, 2020

You add 3 functions and any of them is related to mount...
If it is just because ap_mount can handle mavlink, add mavlink handle on ap_camera but don't spread unessary code on ap_mount.

@Pedals2Paddles
Copy link
Contributor Author

Pierre, it is absolutely 100% related to and specific to the mount library instance. There is no other place where it could or should be. I did this programatically exactly the same as all the other existing functions for that gimbal in the mount library driver instance. I think maybe you're just misunderstanding how this hardware works since it is rather unique.

AP_Mount > Mavlink > Solo Gimbal > process mavlink into controls > GoPro data bus & gimbal stabilization/control.

If this is still unclear, I ask that you take my word for it after many years of working with this hardware and this library, that I've done it the right way.

@peterbarker
Copy link
Contributor

This is definitely a case of "device has a foot in two worlds" problem.

Notionally you could have a Solo gimbal with no motors on it which you use just to trigger the camera.

Notionally you could also have a Solo gimbal that has a really bright light on it rather than a camera.

What this probably means is that if you want to have a "AP_TypicalSoloGimbal" - the thing you find on the bottom of a Solo with a camera in it - then that device should NOT be under AP_Mount because that's only half its job - the other half being taking video or photos. We don't cover these dual-backend-objects very well in ArduPilot.

Even in the case we did have an AP_TypicalSoloGimbal thing - we'd need a place in AP_Camera for the GoPro stuff.

We don't have a frontend/backend split for Camera. But an AP_Camera_SoloGoPro would appear to be appropriate.

@Pedals2Paddles you've obviously been playing in here. You've come to the conclusion that it's appropriate to be controlling a camera in the mount library. But what does an implementation look like of an AP_Camera_SoloGimbal? What coupling is there between that and AP_Mount_SoloGimbal? I'm guessing they'll both want the same mavlink channel, and that's about it.

@Pedals2Paddles
Copy link
Contributor Author

Pedals2Paddles commented Feb 10, 2020

One can't exist without the other, so it's not really a relevant thing IMO. The AP_Mount driver instance communicates with the gimbal and only the gimbal, including these gopro mavlink messages. AP does not and cannot communicate with the camera directly. The gimbal communicates with the camera directly using closed source proprietary licensed methods. There isn't really an "other than typical solo gimbal". It is what it is.

Since this has no application at all beyond the Solo Gimbal, spreading this out among multiple libraries, and re-engineering the camera library to accommodate it, is just not a reasonable or practical path.

@peterbarker
Copy link
Contributor

@Pedals2Paddles Perhaps an accessor on AP_Mount to explicitly get an AP_Mount_SoloGimbal would make this a bit cleaner.

@Pedals2Paddles
Copy link
Contributor Author

I'm not sure how to do that without guidance. But that would be handling this differently than everything else in the mount library, including all the other existing things that are specific to the solo gimbal working the same way. I would rather keep everything consistent then start making one-offs.

@peterbarker
Copy link
Contributor

@Pedals2Paddles Something like this: https://github.com/peterbarker/ardupilot/tree/gopro

That branch isn't mergeable as-is, it's just a refactoring of what you've done - and I've bodged things in with statics rather than creating a singleton, that sort of thing.

@Pedals2Paddles
Copy link
Contributor Author

Making a whole new library just for this? That all seems significantly unnecessary for what is a very simple enabling of existing gimbal functionality.

Honestly, I just want to keep it consistent and simple with what already exists. This is a 5-year-old camera, on a 5-year-old gimbal, with proprietary communication, that will never ever change or grow into anything more than it is. So reinventing and re-engineering things around it is just not a good use of my time or anyone else's.

Unless there is some compelling reason that doing it the way I've done it is forming a tear in space-time, I'm not going to go down the road of reinventing the wheel for this. So right now, I intend to keep it the way it is.

Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

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

The PR as it currently stands introduces unnecessary coupling between the Mount and Camera libraries.

It also pollutes both the AP_Mount and AP_Mount_Backend interfaces with code which is specifically introduced solely for the Solo Gimbal (but not marked as such).

An alternative approach which removes these issues has been supplied.

@Pedals2Paddles
Copy link
Contributor Author

Extending existing functionality in the location where it already exists, using the same methods that are already in use is pollution? But making it an entire new library to do the same thing is not pollution?

TBH I'm really perplexed by this and I just don't know what to say about this anymore.

@peterbarker
Copy link
Contributor

.... having said that, it appears that the gimbal and camera aspects of the SoloGimbal are actually completely disparate; there's no use of the solo-mount-backend-getter left in the library I created (which surprised me a little).

That being the case, it could probably all be contained within AP_Camera until there's some linkage between the Solo mount functionality and its camera functionality.

@peterbarker
Copy link
Contributor

I've reworked the branch I created to make this trigger type just another way AP_Camera triggers the camera.

@andyp1per You thoughts on manipulating whatever stuff we can on a Solo Camera using the RunCam-style controls?

@Pedals2Paddles
Copy link
Contributor Author

The existing methods handle_gimbal_report and handle_param_value in mount library work the same way, which is the code path I followed to make this consistent with the way the library already works. Several others exist as well, used by other mount drivers universally.

Adding this to AP_Camera instead is adding something that doesn't exist without this mount driver to begin with. All the communication in that new camera library is talking to the mount, not the camera. And it's more drivers filling up flash for every vehicle, including those without solo gimbals... which is most of them.

Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

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

Generally looks pretty good.

libraries/AP_Camera/AP_Camera.cpp Outdated Show resolved Hide resolved
libraries/AP_Camera/AP_Camera.cpp Outdated Show resolved Hide resolved
libraries/AP_Camera/AP_Camera.cpp Outdated Show resolved Hide resolved
libraries/AP_Camera/AP_Camera.cpp Outdated Show resolved Hide resolved
libraries/AP_Camera/AP_Camera.cpp Outdated Show resolved Hide resolved
libraries/AP_Camera/AP_Camera_SoloGimbal.h Outdated Show resolved Hide resolved
libraries/AP_Camera/AP_Camera_SoloGimbal.h Outdated Show resolved Hide resolved
libraries/AP_Camera/AP_Camera_SoloGimbal.cpp Show resolved Hide resolved
libraries/RC_Channel/RC_Channel.cpp Outdated Show resolved Hide resolved
libraries/RC_Channel/RC_Channel.cpp Outdated Show resolved Hide resolved
@peterbarker
Copy link
Contributor

peterbarker commented Feb 12, 2020 via email

@peterbarker
Copy link
Contributor

peterbarker commented Feb 12, 2020 via email

@peterbarker
Copy link
Contributor

peterbarker commented Feb 12, 2020 via email

@peterbarker
Copy link
Contributor

peterbarker commented Feb 12, 2020 via email

@Pedals2Paddles
Copy link
Contributor Author

Alright I think this is in good shape now. I made the RC Aux option a generic camera mode toggle, so @andyp1per can use it for the runcam too. Any other camera that may need it in the future.

@khancyr and @peterbarker can you give this a quick once over again?

Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

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

Should this new code go behind HAL_MINIMIZE_FEATURES? Do you know how much this new code impacts code size?

/me is wondering why the Solo Gimbal code isn't behind minimize-features - I believe the CubeSolos don't have the 1MB flaws.

libraries/AP_Camera/AP_Camera.cpp Outdated Show resolved Hide resolved
libraries/AP_Camera/AP_Camera.cpp Outdated Show resolved Hide resolved
libraries/AP_Camera/AP_Camera.h Outdated Show resolved Hide resolved
libraries/AP_Camera/AP_Camera_SoloGimbal.cpp Outdated Show resolved Hide resolved
libraries/AP_Camera/AP_Camera_SoloGimbal.cpp Outdated Show resolved Hide resolved
libraries/AP_Camera/AP_Camera_SoloGimbal.cpp Outdated Show resolved Hide resolved
libraries/AP_Camera/AP_Camera_SoloGimbal.cpp Outdated Show resolved Hide resolved
libraries/AP_Camera/AP_Camera_SoloGimbal.cpp Show resolved Hide resolved
@peterbarker
Copy link
Contributor

peterbarker commented Feb 13, 2020 via email

@tridge tridge merged commit 05b94de into ArduPilot:master Feb 18, 2020
@Pedals2Paddles Pedals2Paddles deleted the gopro branch February 18, 2020 01:14
@rmackay9
Copy link
Contributor

rmackay9 commented May 6, 2020

this has been added to Copter-4.0.4-rc1

@rmackay9 rmackay9 moved this from PRs to 4.0.4-rc1 in Copter 4.0 backports May 6, 2020
@Hwurzburg
Copy link
Collaborator

@Pedals2Paddles I need details for the wiki on this....how is it connected to the Solo gimbal, what params must be setup to use it....I ran across this just by accident trying to update the wiki on RC switch options which became very out of date, very fast recently....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

None yet

8 participants