stereolabs / zed-ros-wrapper

ROS wrapper for the ZED SDK
https://www.stereolabs.com/docs/ros/
MIT License
447 stars 391 forks source link

ZED connection -> CAMERA FAILED TO SETUP #548

Closed ruksen25 closed 4 years ago

ruksen25 commented 4 years ago

Hi!

I am working on a project that I have build up inside a docker-container. The cotainer is set up as follows:

My container has GL and so I am able to open ZED_Explorer tool which shows the image feed from the camera just fine, but when running it gives the following error: [ZED Depth Viewer] Failed to create directory to save images: /root/Documents/ZED [ZED]ERROR: sl::Camera::Open has not been called, no Camera instance running.

When I run the ros wrapper with roslaunch zed_wrapper zed2.launch I get similar errors regarding camera setup and sl::Camera::Open not being run. Do you know what might cause this issue?

This is the full output of running the ROS wrapper:

`$ roslaunch zed_wrapper zed2.launch
... logging to /root/.ros/log/942b1d46-6e78-11ea-9010-0242ac110002/roslaunch-1d22dc2e1326-10293.log Checking log directory for disk usage. This may take awhile. Press Ctrl-C to interrupt Done checking log file disk usage. Usage is <1GB.

xacro: Traditional processing is deprecated. Switch to --inorder processing! To check for compatibility of your document, use option --check-order. For more infos, see http://wiki.ros.org/xacro#Processing_Order started roslaunch server http://1d22dc2e1326:34895/

SUMMARY

PARAMETERS

NODES /zed2/ zed2_state_publisher (robot_state_publisher/robot_state_publisher) zed_node (zed_wrapper/zed_wrapper_node)

auto-starting new master process[master]: started with pid [10306] ROS_MASTER_URI=http://localhost:11311

setting /run_id to 942b1d46-6e78-11ea-9010-0242ac110002 process[rosout-1]: started with pid [10319] started core service [/rosout] process[zed2/zed2_state_publisher-2]: started with pid [10336] process[zed2/zed_node-3]: started with pid [10337] [ INFO] [1585127477.681715197]: Initializing nodelet with 8 worker threads. [ INFO] [1585127477.701512661]: ** Starting nodelet '/zed2/zed_node' ** [ INFO] [1585127477.701606724]: SDK version : 3.1.1 [ INFO] [1585127477.701646229]: PARAMETERS [ INFO] [1585127477.702510265]: Camera Name -> zed2 [ INFO] [1585127477.703525801]: Camera Resolution -> HD720 [ INFO] [1585127477.704434505]: Camera Grab Framerate -> 30 [ INFO] [1585127477.705112824]: Gpu ID -> -1 [ INFO] [1585127477.706020394]: Camera ID -> -1 [ INFO] [1585127477.706805418]: Verbose -> DISABLED [ INFO] [1585127477.708561894]: Camera Flip -> DISABLED [ INFO] [1585127477.710559645]: Self calibration -> ENABLED [ INFO] [1585127477.712631828]: Camera Model by param -> zed2 [ INFO] [1585127477.713588283]: Image resample factor -> 1 [ INFO] [1585127477.714395529]: Extrinsic param. frame -> X RIGHT - Y DOWN - Z FWD [ INFO] [1585127477.715369158]: Depth quality -> ULTRA [ INFO] [1585127477.716474115]: Depth Sensing mode -> STANDARD [ INFO] [1585127477.717342607]: OpenNI mode -> DISABLED [ INFO] [1585127477.718257510]: Depth Stabilization -> ENABLED [ INFO] [1585127477.719437289]: Minimum depth -> 0.7 m [ INFO] [1585127477.720625430]: Maximum depth -> 20 m [ INFO] [1585127477.721831125]: Depth resample factor -> 1 [ INFO] [1585127477.722858207]: Path rate -> 2 Hz [ INFO] [1585127477.723889375]: Path history size -> 1 [ INFO] [1585127477.726287437]: Odometry DB path -> [ INFO] [1585127477.728561964]: Spatial Memory -> ENABLED [ INFO] [1585127477.730481164]: IMU Fusion -> ENABLED [ INFO] [1585127477.732613661]: Floor alignment -> DISABLED [ INFO] [1585127477.734587887]: Init Odometry with first valid pose data -> ENABLED [ INFO] [1585127477.737228255]: Two D mode -> DISABLED [ INFO] [1585127477.741875866]: Mapping -> DISABLED [ INFO] [1585127477.744209137]: Object Detection -> DISABLED [ INFO] [1585127477.745493231]: Sensors timestamp sync -> DISABLED [ INFO] [1585127477.746867273]: Sensors data freq -> 400 Hz [ INFO] [1585127477.749256720]: SVO input file: -> [ INFO] [1585127477.750651630]: SVO REC compression -> H265 (HEVC) [ INFO] [1585127477.761153644]: map_frame -> map [ INFO] [1585127477.761209924]: odometry_frame -> odom [ INFO] [1585127477.761272991]: base_frame -> base_link [ INFO] [1585127477.761319411]: camera_frame -> zed2_camera_center [ INFO] [1585127477.761366151]: imu_link -> zed2_imu_link [ INFO] [1585127477.761438587]: left_camera_frame -> zed2_left_camera_frame [ INFO] [1585127477.761496157]: left_camera_optical_frame -> zed2_left_camera_optical_frame [ INFO] [1585127477.761556865]: right_camera_frame -> zed2_right_camera_frame [ INFO] [1585127477.761618470]: right_camera_optical_frame -> zed2_right_camera_optical_frame [ INFO] [1585127477.761674094]: depth_frame -> zed2_left_camera_frame [ INFO] [1585127477.761732628]: depth_optical_frame -> zed2_left_camera_optical_frame [ INFO] [1585127477.761795607]: disparity_frame -> zed2_left_camera_frame [ INFO] [1585127477.761849050]: disparity_optical_frame -> zed2_left_camera_optical_frame [ INFO] [1585127477.761893657]: confidence_frame -> zed2_left_camera_frame [ INFO] [1585127477.761991779]: confidence_optical_frame -> zed2_left_camera_optical_frame [ INFO] [1585127477.764576918]: Broadcast odometry TF -> ENABLED [ INFO] [1585127477.766959156]: Broadcast map pose TF -> ENABLED [ INFO] [1585127477.768142751]: [DYN] Depth confidence -> 50 [ INFO] [1585127477.769491331]: [DYN] Depth texture conf. -> 100 [ INFO] [1585127477.770741613]: [DYN] pub_frame_rate -> 15 Hz [ INFO] [1585127477.772087303]: [DYN] point_cloud_freq -> 15 Hz [ INFO] [1585127477.773334782]: [DYN] brightness -> 4 [ INFO] [1585127477.774660803]: [DYN] contrast -> 4 [ INFO] [1585127477.776064827]: [DYN] hue -> 0 [ INFO] [1585127477.777620750]: [DYN] saturation -> 4 [ INFO] [1585127477.778926578]: [DYN] sharpness -> 4 [ INFO] [1585127477.780301103]: [DYN] gamma -> 8 [ INFO] [1585127477.781399724]: [DYN] auto_exposure_gain -> ENABLED [ INFO] [1585127477.785017651]: [DYN] auto_whitebalance -> ENABLED [ INFO] [1585127477.802464788]: Camera coordinate system -> Right HANDED Z UP and X FORWARD [ INFO] [1585127477.802624385]: *** Opening ZED 2... [ INFO] [1585127479.239753542]: ZED connection -> CAMERA FAILED TO SETUP [ZED]ERROR: sl::Camera::Open has not been called, no Camera instance running. [ INFO] [1585127482.767643286]: ZED connection -> CAMERA FAILED TO SETUP [ZED]ERROR: sl::Camera::Open has not been called, no Camera instance running. [ INFO] [1585127486.175643044]: ZED connection -> CAMERA FAILED TO SETUP [ZED]ERROR: sl::Camera::Open has not been called, no Camera instance running. `

adujardin commented 4 years ago

Hi

What command did you use to start the container? Did you use --privileged option?
Did you plug the ZED2 after launching the container (see https://github.com/stereolabs/zed-docker#usb-replughot-plug if so)?

Could you launch lsusb -d 2b03: from within the container (you may need to install usbutils)?

If possible could you share the docker image or DockerFile used and the exact launch command to try to replicate this?

ruksen25 commented 4 years ago

Thank you for the reply. I really appreciate you taking the time to offer support.

I run using this command: sudo docker run --runtime=nvidia -v /home/usr/Documents/ergo_adapt_docker_share/ergo_adapt_docker_ros:/home/catkin_ws/src/ergoadapt -it --rm --name zed --device=/dev/video0:/dev/video0 --device=/dev/video1:/dev/video1 --privileged --add-host=021802CP00066.local:192.168.1.19 -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix:ro mkvdb/ros_intera_zed_openpose:latest bash

Using the last part (image name) you should be able to download my image from docker hub.

Camera is plugged in before running the container. When running lsusb -d 2b03: in my container I get: Bus 001 Device 006: ID 2b03:f781 Bus 001 Device 005: ID 2b03:f780

adujardin commented 4 years ago

Your lsusb command shows the ZED2 is correctly detected (Camera and IMU).

I tried different things with zed images and your image and it's working fine for both ZED and ZED2.

I did not use this exact launch command this my nvidia docker version is newer and I don't have some of the local folders.

docker run --gpus all -e NVIDIA_DRIVER_CAPABILITIES=all -it --rm --name zed --privileged -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix:ro mkvdb/ros_intera_zed_openpose:latest bash

Output logs

I also tried the tools (you can ignore the Depth viewer error about the folder creation, it's working fine without it) and some samples without any issues.

Could you try running a sample without ROS on a ZED image (DockerHub, zed-docker) ?

ruksen25 commented 4 years ago

Your output log file indeed seems to indicate that you do not experience the same issues. When I run my container with your docker run command nothing changes and I still have the same issues.

I tried running the stereolabs/zed:3.1-gl-devel-cuda10.0-ubuntu16.04 container (which resembles my setup the most i think) and then launch the ZED_Depth_viewer inside. When I do that, I still get the [ZED]ERROR: sl::Camera::Open has not been called, no Camera instance running. error. I have previously tested in several of your different docker containers but my error occurs in each of them.

I find it all very peculiar.

I am using a brand new camera for the very first time. Is there any initialization of the camera I habe to do which I have overlooked? Also What versions of Docker, its API and the Nvidia-container-toolkit do you have? (Grasping at straws here...)

Inside the mentioned container of yours I tested, I should be able to cmake inside eg. /usr/local/zed/samples/depth sensing/cpp/ , right?

adujardin commented 4 years ago

I'm using Ubuntu 18, Cuda 10.0 with nvidia-container-toolkit (not nvidia-docker2). But I think this would only result in an issue with CUDA execution or GPU related issue (video decoding, OpenGL...), which seems to be working fine here.

No, there's nothing to initialize or any special first step for new cameras. Depending on the docker image used, but on most on them, you can directly compile (cmake/make) the sample in interactive yes.

Would it be possible for you to test the tools or samples directly on the host? Can you run guvcview in docker to try to open the camera without the ZED SDK? Maybe also the Diagnostic Tool, and upload the json results.

adujardin commented 4 years ago

One other thing, are you sure the ZED2 is connected to a USB3 port? The error code you have usually means the resolution can't be set because there's not enough bandwidth.

ruksen25 commented 4 years ago

This is a bit embarrassing, but it seems like your last comment was helpful.

Though I had been aware of the requirement of a USB3, It seems like I had failed to ensure this is what I am using. Since my visualisation in the SDK tools was working just fine, I assumed it was correctly connected. However, I had connected my camera to a usb port in the front of my desktop which has a blue insert blindly trusting it had the sufficient USB3 capeabilities. Seemingly this was not the case. I then connected the camera on the back of the tower and now it works. Apparently this is a know issue. For anyone else reading this wanting to ensure they are using the right USB, I can share that I found it helpful to run lsusb -d 2b03: -v and then inspect the bcdUSB value for the camera to check that it is indeed 3.00

My ROS zed_wrapper is now running flawlessly, and I am able to visualise in rviz.

BTW. I found out that it also works if I take out the --privileged flag and and add the two buses obtained by lsusb -d 2b03: and video0 and video1, thus in my case using the flags --device=/dev/video1:/dev/video1 --device=/dev/video0:/dev/video0 --device=/dev/bus/usb/004:/dev/bus/usb/004 --device=/dev/bus/usb/003:/dev/bus/usb/003. When I have alternate options I prefer that to the --privileged flag that you seem to recommend most frequently.

@adujardin Thank you very much for your support it has been a huge help.

adujardin commented 4 years ago

The documentation is mainly focused on getting started. We recommend the privileged option to avoid having to check which dev folder to mount for each camera, and ease of development in general, but that's correct it is not mandatory.