Kinovarobotics / ros_kortex_vision

ROS package for KINOVA® KORTEX™ arms vision module
BSD 3-Clause "New" or "Revised" License
32 stars 34 forks source link

How to close the auto-focus function of the camera? #8

Open JingKangSun opened 2 years ago

JingKangSun commented 2 years ago

Hi,

I want to do a calibration on the camera of the kinova-gen3, however, I found that the camera open the auto-focus function.

How can I close this function?

Thanks.

felixmaisonneuve commented 2 years ago

Hi @JingKangSun,

In our kortex repo, we actually provide an example on how to disable the auto-focus : https://github.com/Kinovarobotics/kortex/blob/master/api_python/examples/500-Gen3_vision_configuration/03-vision_sensor_focus_action.py#L82-L86

To disable the auto-focus, you could modify the example to something like this

def example_routed_vision_do_autofocus_action(vision_config, vision_device_id):
    print("\n-- Using Vision Config Service to disable the auto-focus --")
    sensor_focus_action.focus_action = VisionConfig_pb2.FOCUSACTION_DISABLE_FOCUS
    vision_config.DoSensorFocusAction(sensor_focus_action, vision_device_id)
    print("-- Place or remove an object from the center of the camera, observe the focus doesn't change --")
    example_wait_for_focus_action()

...

def main():
    # Import the utilities helper module
    sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
    import utilities

    # Parse arguments
    args = utilities.parseConnectionArguments()

    # Create connection to the device and get the router
    with utilities.DeviceConnection.createTcpConnection(args) as router:

        device_manager = DeviceManagerClient(router)
        vision_config = VisionConfigClient(router)

        # example core
        vision_device_id = example_vision_get_device_id(device_manager)

        if vision_device_id != 0:
            example_routed_vision_do_autofocus_action(vision_config, vision_device_id)
            # example_routed_vision_set_focus_point(vision_config, vision_device_id)
            # example_routed_vision_set_manual_focus(vision_config, vision_device_id)

I do not know at the moment if this config is persistant after a reboot. If it is not, I suppose you could run it before you want to do a calibration

Looking at the web app, I see a "PAUSE AUTO-FOCUS" button (in Operations->Camera) that might be doing just that. I am unsure however. I have very little experience with the vision module.

Best, Felix

SnallQiu commented 2 months ago

@JingKangSun Is there any good way to solve this? Thank you!