ArduPilot / ardupilot_gazebo

Plugins and models for vehicle simulation in Gazebo Sim with ArduPilot SITL controllers
GNU Lesser General Public License v3.0
81 stars 76 forks source link

Add zoom slew rate to CameraZoomPlugin #80

Closed Ryanf55 closed 6 months ago

Ryanf55 commented 7 months ago

Feature request

Is your feature request related to a problem? Please describe.

Not all cameras can do instant zoom. I'd like to achieve the nice optical zoom rate limit that nice cameras have.

Describe the solution you'd like

Add one new parameter "slew_rate", which is the change in focal length per second possible from the camera.

The gazebo camera zoom plugin should be able to configure something like this: https://www.youtube.com/watch?v=jShVCd7m1ak&ab_channel=SuperZoom https://www.nikonusa.com/en/nikon-products/product/compact-digital-cameras/coolpix-p1000.html

Example:

Nikon has a P1000 has a 125x optical zoom (3000mm / 24mm = 125x). From the video, it takes about 7 seconds to do the zoom action.

Converting to SI, because REP-15, you have a 3 meter to 0.024 meter change.

Slew Rate [m/s] = ( 3 - 0.024) / 7 = 0.42514285714 m/s Thus, you would add to models/gimbal_small_3d/model.sdf:

        <plugin filename="CameraZoomPlugin"
            name="CameraZoomPlugin">
          <max_zoom>125.0</max_zoom>
          <slew_rate>0.42514285714</slew_rate>
        </plugin>

Describe alternatives you've considered

N/A

Platform [ x] All [ ] AntennaTracker [ ] Copter [ ] Plane [ ] Rover [ ] Submarine

Assumptions

Ignore the weird lens effects at high zoom levels. If someone wants to make a 50-9999999 lens simulator, then let them. Assume most users want instant zoom, so the default for the zoom rate will be infinity.

Additional context

I can do the implementation. Just requires a bit more math. It will be nice internally in the plugin to start doing math against focal lengths instead of the currently exposed zoom factor.

https://www.scantips.com/lights/fieldofviewmath.html https://en.wikipedia.org/wiki/Focal_length

Ryanf55 commented 6 months ago

Completed by #83 and #81