Hi, I’m currently using a Reachy 2021 and I have trouble accessing both cameras.
I tried using the Reachy SDK python API but all I get is this error :
Exception in thread Thread-165: Traceback (most recent call last): File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner self.run() File "/usr/lib/python3.8/threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "/home/reachy/reachy-sdk/reachy_sdk/camera.py", line 191, in poll_img for resp in self._stub.StreamImage(stream_request): File "/home/reachy/.local/lib/python3.8/site-packages/grpc/_channel.py", line 426, in __next__ return self._next() File "/home/reachy/.local/lib/python3.8/site-packages/grpc/_channel.py", line 826, in _next raise self grpc._channel._MultiThreadedRendezvous: <_MultiThreadedRendezvous of RPC that terminated with: status = StatusCode.UNAVAILABLE details = "failed to connect to all addresses" debug_error_string = "{"created":"@1717683654.457389558","description":"Failed to pick subchannel","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":3008,"referenced_errors":[{"created":"@1717683654.457388289","description":"failed to connect to all addresses","file":"src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc","file_line":397,"grpc_status":14}]}"
Reachy-sdk is running and everything else works correctly. I’ve checked the script camera.py to see what was the cause of the problem but I could not find anything.
I also tried using the example code view_cam.py with both ROS and OpenCV.
With ROS, I launched camera_publisher.launch.py beforehand and got the following error and so nothing is published on the topic and view_cam.py does nothing.
[INFO] [launch]: All log files can be found below /home/reachy/.ros/log/2024-06-06-15-31-43-158018-reachy-17567 [INFO] [launch]: Default logging verbosity is set to INFO [INFO] [camera_publisher-1]: process started with pid [17569] [camera_publisher-1] Traceback (most recent call last): [camera_publisher-1] File "/home/reachy/reachy_ws/install/reachy_controllers/lib/reachy_controllers/camera_publisher", line 33, in <module> [camera_publisher-1] sys.exit(load_entry_point('reachy-controllers==1.0.0', 'console_scripts', 'camera_publisher')()) [camera_publisher-1] File "/home/reachy/reachy_ws/install/reachy_controllers/lib/python3.8/site-packages/reachy_controllers/camera_publisher.py", line 105, in main [camera_publisher-1] camera_publisher = CameraPublisher() [camera_publisher-1] File "/home/reachy/reachy_ws/install/reachy_controllers/lib/python3.8/site-packages/reachy_controllers/camera_publisher.py", line 37, in __init__ [camera_publisher-1] self.left_device.video_capture.set_format(width=resolution[0], height=resolution[1], pixel_format='MJPG') [camera_publisher-1] AttributeError: 'Device' object has no attribute 'video_capture' [ERROR] [camera_publisher-1]: process has died [pid 17569, exit code 1, cmd '/home/reachy/reachy_ws/install/reachy_controllers/lib/reachy_controllers/camera_publisher --ros-args'].
With OpenCV, I managed to access the cameras but the focus is not done.
I tried modifying the code to add focus or autofocus properties but it doesn’t seem to have any effect with these cameras.
def __init__(self, side: str) -> None:
"""Initialize cap by connecting to the required video port and configuring it."""
self.cap = cv.VideoCapture(self.side_to_port[side], apiPreference=cv.CAP_V4L2)
self.cap.set(cv.CAP_PROP_FOURCC, cv.VideoWriter.fourcc('m', 'j', 'p', 'g'))
self.cap.set(cv.CAP_PROP_FOURCC, cv.VideoWriter.fourcc('M', 'J', 'P', 'G'))
self.cap.set(cv.CAP_PROP_FPS, 30)
self.cap.set(cv.CAP_PROP_FRAME_WIDTH, 640)
self.cap.set(cv.CAP_PROP_FRAME_HEIGHT, 480)
#self.cap.set(cv.CAP_PROP_FOCUS,30)
# Set focus to auto
# self.cap.set(cv.CAP_PROP_AUTOFOCUS, 1) # Turn on autofocus
self.cam_img = None
self.rot_value = self.rot[side]
Does anyone know how I can fix this ? (The best way is to use the SDK API, but I can work only with OpenCv if the camera focus is done)
Thanks !