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 camera zoom plugin #57

Merged
merged 1 commit into from Jan 14, 2024

Conversation

srmainwaring
Copy link
Collaborator

@srmainwaring srmainwaring commented May 12, 2023

Add a 3 axis gimbal and system plugin that attaches to a camera sensor and allows the camera to be zoomed.

Details

  • Add 3 axis version of the small gimbal.
  • Add example world with mount and objects of interest.
  • Add system plugin that subscribes to a zoom command topic (msgs::Double) and allows an existing camera sensor to be zoomed.

The plugin SDF has a single parameter setting the maximum zoom factor.

 <sensor name="camera" type="camera">
   ...
   <plugin filename="CameraZoomPlugin"
       name="CameraZoomPlugin">
     <max_zoom>15.0</max_zoom>
   </plugin>
</sensor>

Testing

camera_zoom.mov

The gimbal is position controlled and responds to roll, pitch and yaw commands.

gz topic -t "/gimbal/cmd_yaw" -m gz.msgs.Double -p "data: -1"

The camera zoom is similarly commanded.

gz topic -t "/model/gimbal/sensor/camera/zoom/cmd_zoom" -m gz.msgs.Double -p "data: 2"

Tasks

  • #include <gz/sim/Sensor.hh> is not available in the released version of gz-sim7 on Ubuntu.
  • Resolve segmentation fault on exit.

@srmainwaring srmainwaring added the enhancement New feature or request label May 12, 2023
@srmainwaring srmainwaring self-assigned this May 12, 2023
@srmainwaring srmainwaring marked this pull request as draft May 12, 2023 16:37
class CameraZoomPlugin::Impl
{
/// \brief Handle a zoom command.
public: void OnZoom(const msgs::Double &_msg);
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you considered specifying zoom as a focal length? It's more deterministic.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, could do. This is just a basic first pass to get the internal mechanics of the plugin working and a factor applied to HFOV was the method used in the PX4-SITL_Gazebo plugin for Gazebo Classic so I took my steer from that.

@rmackay9
Copy link

It's really great to see this, thanks so much!

@Ryanf55
Copy link
Contributor

Ryanf55 commented Dec 19, 2023

If you are still interested to get this merged, let me know! I think it's a great feature addition.

@srmainwaring
Copy link
Collaborator Author

If you are still interested to get this merged, let me know! I think it's a great feature addition.

Thanks @Ryanf55, let me re-test on Harmonic. IIRC there was an issue in Gazebo Garden that could cause crashes and I need to remind my self what it was and whether it has been fixed.

@srmainwaring srmainwaring force-pushed the prs/pr-camera-zoom-plugin branch 2 times, most recently from ca07602 to 99a5393 Compare January 14, 2024 11:36
- fix gimbal test world
- add example world for gimbal and camera
- add gimbal_small_3d
- update command topic names in gimbal test world
- update quote style in gimbal_small_3d
- rename zoom plugin and attach to sensor
- resolve parent model and subscribe to zoom command
- implement zoom for standard camera
- remove whitespace for linter
- provide alternative to gz::sim::Sensor
- handle RenderTeardown event to exit cleanly
- find package gz-common5
- use degrees for pose in gimbal world
- format plugin attributes.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
@srmainwaring srmainwaring marked this pull request as ready for review January 14, 2024 11:38
@srmainwaring
Copy link
Collaborator Author

srmainwaring commented Jan 14, 2024

If you are still interested to get this merged, let me know! I think it's a great feature addition.

Hi @Ryanf55 - tested on Harmonic and appears to now be working fine. I can not longer see a segmentation fault on exit, so I assume the issue (which was connected to the physics libraries unloading IIRC) has been resolved upstream.

@srmainwaring srmainwaring merged commit 4dcab37 into ArduPilot:main Jan 14, 2024
3 checks passed
@srmainwaring srmainwaring deleted the prs/pr-camera-zoom-plugin branch January 14, 2024 15:35
@Ryanf55 Ryanf55 mentioned this pull request Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants