Reachy 2021 error accessing the cameras

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 !

Hi @Alex !

Based on your logs, I suggest that the issue might be with the version of your v4l2py library. Please run pip show to verify that you have the correct version, as shown below:

Untitled (1)

Regarding the focus adjustment, follow this procedure:

Make the focus on the right camera :

You will need to open the view_cam.py script AND an ipython terminal side by side to do this.

Open the view_cam window on one side of the screen :

cd ~/reachy_ws/src/reachy_2023/camera_controllers/examples
python3 view_cam.py right ros

In a Python terminal, first perform the zoom homing (it resets the zero positions of the zoom motor for the camera you want to focus):

from reachy_sdk import ReachySDK

reachy = ReachySDK(host='localhost')
reachy.right_camera.zoom_homing()

Change the focus by hand until the image seems clear enough. The value of the focus should be between 100 and 600. For example, to put 300 value for the focus:

reachy.right_camera.focus = 300 

When the image reaches a satisfactory definition, all that’s left to do is close these terminals and do the same for the left camera if necessary, replacing ‘right’ with ‘left’ in the procedure.

Hi, I managed to download the correct v4l2py version and now camera_publisher.launch.py runs without errors and I can now access the cameras with ros.
However the API still produces the same error (only for the cameras, everything else works fine). I tried making the focus and got this :

I think it comes from the gRPC server but I have no knowledge about that.
Thanks !

Hi,

Thank you for the update. I’m glad to hear that you were able to download the correct v4l2py version and get camera_publisher.launch.py running without errors.

Regarding the issue with the API still producing the same error for the cameras, I have a few questions and suggestions to narrow down the problem:

  1. Launch Configuration: Can you confirm that camera_publisher.launch.py is not being launched directly? Instead, please ensure that all services are being launched using run_everything.launch.py. This will help us verify if the error is due to the launch configuration.
  2. Configuration Check: Please make sure that nothing is commented out in run_everything.launch.py, as it might have been modified for a special Reachy configuration. This could potentially affect the camera services.

To assist further, could you please provide the reachy.yaml file for review? You can do this by running the following command and sending a screenshot:

nano ~/.reachy.yaml

This will help us verify the configuration settings and identify any possible discrepancies.

Thank you for your cooperation, and I look forward to your response.

Best regards,

Annaëlle

HI, the node camera_publisher is launched with every other nodes at robot startup, and nothing is commented in run_everything.launch.py.

Here is the reachy.yaml file :

Best Regards,