-
Notifications
You must be signed in to change notification settings - Fork 38
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
YarpCameraBridge set_drivers_list python bindings breaks if the camera driver gets out of scope #871
Comments
Looking (quickly) at https://pybind11-jagerman.readthedocs.io/en/stable/advanced.html#return-value-policies we might need to change the return policy of |
Got a minimal reproducible example going: The script is as follows: import bipedal_locomotion_framework.bindings as blf
import yarp
def initialize_camera(param_handler):
camera_driver = blf.robot_interface.construct_RGBD_sensor_client(
param_handler.get_group("CAMERA_DRIVER")
)
camera_bridge = blf.robot_interface.YarpCameraBridge()
camera_bridge.initialize(param_handler.get_group("CAMERA_BRIDGE"))
if not camera_bridge.set_drivers_list([camera_driver]):
print("Error while setting the camera driver")
return
return camera_bridge
if __name__ == "__main__":
yarp.Network.init()
param_handler = blf.parameters_handler.YarpParametersHandler()
param_handler.set_from_filename("config/camera_config.ini")
print(f"Parameters: {param_handler}")
camera_bridge = initialize_camera(param_handler)
print("Camera bridge initialized")
# Get camera
ret, img_rgb = camera_bridge.get_color_image("realsense")
if not ret:
print("RGB Camera Frame not available")
ret, img_depth = camera_bridge.get_depth_image("realsense")
if not ret:
print("DEPTH Camera Frame not available")
yarp.Network.fini() The configuration files are:
And the output is:
|
@giotherobot you could try and check if that fixes the issue |
While restructuring a python script using blf python bindings with @carloscp3009 I tried to encompass the creation of the camera bridge in a function:
This seems to not work: the camera bridge is initialized correctly but looking at the logs the ports gets deleted right after the function is executed and when trying to get the images from the camera we have a SegFault.
Returning also the
camera_driver
from the funciton, even without ever using it, fixes the problem ( the ports stay open).The text was updated successfully, but these errors were encountered: