neufieldrobotics / spinnaker_sdk_camera_driver

Point Grey (FLIR) Spinnaker based camera driver (Blackfly S etc.)
MIT License
125 stars 91 forks source link

Cannot launch node as normal user, but can launch as root #129

Closed civerachb-cpr closed 3 years ago

civerachb-cpr commented 3 years ago

System Description Camera Name and Model: 2x Blackfly S (USB3, connected via Sync cable) Operating System: Ubuntu 18.04.5 w/ JetPack 4.5.1 Spinnaker Version: 2.2.0.48 ROS Version: Melodic

Computer details Processor: Nvidia AGX Xavier RAM: 32GB

Multiple Cameras Only How is the triggering setup? Master/Slave (though not specifically applicable to my current problem -- see below)

For USB 3.0 cameras: On same USB 3.0 bus or different buses? Same bus Is the USB 3.0 hub externally powered? Yes

Do the cameras work with SpinView? Yes

Describe the bug Summary: I cannot launch the node/nodelet as a normal user, but I can launch it correctly if I am logged into a root shell.

Following the instructions in https://github.com/neufieldrobotics/spinnaker_sdk_camera_driver/issues/89 I am able to build the node. However, when I try to launch the node I get the commonly-cited [FATAL] [1622735926.930668531]: No cameras found! failed assertion. But, if I run the following:

$ sudo -s
# source /opt/ros/melodic/setup.bash
# source /home/administrator/catkin_ws/devel/setup.bash
# roslaunch roslaunch spinnaker_sdk_camera_driver node_acquisition.launch binning:=2

the note starts up properly and I am able to see data; rostopic hz reports the data is coming in at about 20Hz and I can see the video stream in rviz.

For simplicity I'm only trying to launch a single camera for the moment. Once I get these issues sorted out I'll re-enable the synchronization and launch the second camera.

I suspect that it's something as simple as a udev rule that I'm missing, but I'm not sure what the necessary rule is. I have the following rule defined in /etc/udev/rules.d/50-spinnaker.rules:

SUBSYSTEM=="usb", ATTR{idVendor}=="1e10", MODE:="0666", GROUP="flirimaging", SYMLINK+="spinnaker%n

Checking the normal user's groups:

$ groups
administrator adm cdrom sudo audio dip video plugdev netdev i2c lpadmin gdm lightdm sambashare weston-launch gpio flirimaging

I can see both camera devices:

$ ls -l /dev/spinnaker*
lrwxrwxrwx 1 root root 15 Jun  2 17:35 /dev/spinnaker1 -> bus/usb/002/033
lrwxrwxrwx 1 root root 15 Jun  2 17:35 /dev/spinnaker4 -> bus/usb/002/034

$ ls -l /dev/bus/usb/002/033
crw-rw-rw- 1 root flirimaging 189, 160 Jun  3 12:07 /dev/bus/usb/002/033

$ ls -l /dev/bus/usb/002/034
crw-rw-rw- 1 root flirimaging 189, 161 Jun  3 12:08 /dev/bus/usb/002/034

Is this a known limitation of the driver and/or libspinnaker that it must be launched as root? Or is this something specific to the AGX Xavier and/or the version of JetPack that I'm using? Or is there an additional group that I need to add the user to that I've omitted?

Error Messages Running from a root shell:

$ sudo -s
# source /opt/ros/melodic/setup.bash
# source /home/administrator/catkin_ws/devel/setup.bash
# roslaunch spinnaker_sdk_camera_driver node_acquisition.launch binning:=2
... logging to /home/administrator/.ros/log/9282d74a-c485-11eb-90b4-00044bcbdf38/roslaunch-cpr-mitre-5294.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://cpr-mitre:37961/

SUMMARY
========

PARAMETERS
 * /acquisition_node/binning: 2
 * /acquisition_node/cam_aliases: ['left_cam']
 * /acquisition_node/cam_ids: [20480529]
 * /acquisition_node/color: False
 * /acquisition_node/delay: 1.0
 * /acquisition_node/distortion_coeffs: [[-0.021141875266...
 * /acquisition_node/distortion_model: plumb_bob
 * /acquisition_node/exposure_time: 0
 * /acquisition_node/external_trigger: False
 * /acquisition_node/flip_horizontal: [False]
 * /acquisition_node/flip_vertical: [False]
 * /acquisition_node/frames: 3400
 * /acquisition_node/image_height: 1080
 * /acquisition_node/image_width: 1440
 * /acquisition_node/intrinsic_coeffs: [[1886.9232141485...
 * /acquisition_node/live: False
 * /acquisition_node/live_grid: False
 * /acquisition_node/master_cam: 20480529
 * /acquisition_node/max_rate_save: False
 * /acquisition_node/projection_coeffs: [[913.700317, 0.0...
 * /acquisition_node/rectification_coeffs: [[1.0, 0.0, 0.0, ...
 * /acquisition_node/region_of_interest/height: 0
 * /acquisition_node/region_of_interest/width: 0
 * /acquisition_node/region_of_interest/x_offset: 0
 * /acquisition_node/region_of_interest/y_offset: 0
 * /acquisition_node/save: False
 * /acquisition_node/save_path: ~
 * /acquisition_node/save_type: bmp
 * /acquisition_node/skip: 20
 * /acquisition_node/soft_framerate: 20
 * /acquisition_node/target_grey_value: 0
 * /acquisition_node/tf_prefix: 
 * /acquisition_node/time: False
 * /acquisition_node/to_ros: True
 * /acquisition_node/utstamps: False
 * /rosdistro: melodic
 * /rosversion: 1.14.11

NODES
  /
    acquisition_node (spinnaker_sdk_camera_driver/acquisition_node)

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

setting /run_id to 9282d74a-c485-11eb-90b4-00044bcbdf38
process[rosout-1]: started with pid [5318]
started core service [/rosout]
process[acquisition_node-2]: started with pid [5336]
[ INFO] [1622736354.955556854]: Initializing nodelet with 8 worker threads.
[ INFO] [1622736355.017821482]: Initializing nodelet
[ INFO] [1622736355.020252446]: [ OK ] USB memory: 1024 MB
[ INFO] [1622736355.020363876]: *** PARAMETER SETTINGS ***
[ INFO] [1622736355.020419206]: ** Date = 20210603
[ INFO] [1622736355.022402822]:   Save path set via parameter to: /home/administrator
[ INFO] [1622736355.022511179]:   Camera IDs:
[ INFO] [1622736355.024291041]:     20480529
[ INFO] [1622736355.025777640]:   Camera Aliases:
[ INFO] [1622736355.025962673]:     20480529 >> left_cam
[ INFO] [1622736355.027707397]:   External trigger: false
[ INFO] [1622736355.030596048]:   Unique time stamps for each camera: false
[ INFO] [1622736355.032030165]:   color set to: false
[ INFO] [1622736355.033428280]:   20480529 flip_horizontal 0
[ INFO] [1622736355.034953730]:   20480529 flip_vertical 0
[ INFO] [1622736355.036457994]:   Exporting images to ROS: true
[ INFO] [1622736355.037827948]:   Showing live images setting: false
[ INFO] [1622736355.039297427]:   Showing grid-style live images setting: false
[ INFO] [1622736355.040602385]:   Max Rate Save Mode: false
[ INFO] [1622736355.041971219]:   Displaying timing details: false
[ INFO] [1622736355.043323764]:   No. of images to skip set to: 20
[ INFO] [1622736355.044753209]:   Init sleep delays set to : 1.00 sec
[ WARN] [1622736355.046335013]:   'fps' Parameter not set, using default behavior: fps=20.00
[ INFO] [1622736355.047865551]:   'exposure_time'=0, Setting autoexposure
[ WARN] [1622736355.049511134]:   'gain' Parameter not set, using default behavior: Auto gain based on target grey value
[ INFO] [1622736355.051430202]:   'target_grey_value'=0, Setting AutoExposureTargetGreyValueAuto to Continuous/ auto
[ INFO] [1622736355.054500174]:   Binning set to: 2
[ INFO] [1622736355.057075658]:   Using Software rate control, rate set to: 20
[ INFO] [1622736355.058401034]:   Saving images set to: 0
[ INFO] [1622736355.062368649]:   tf_prefix set to: 
[ INFO] [1622736355.070580180]:   Region of Interest set to width: 0    height: 0   offset_x: 0 offset_y: 0
[ INFO] [1622736355.073446462]:   Camera Intrinsic Paramters:
[ INFO] [1622736355.074426285]:    1886.923214 0.000000 604.721488 0.000000 1886.666877 493.477267 0.000000 0.000000 1.000000 
[ INFO] [1622736355.076179489]:   Camera Distortion Paramters:
[ INFO] [1622736355.076293830]:    -0.021142 -0.373387 2.385983 3.282457 
[ INFO] [1622736355.077712011]:   Camera Rectification Paramters:
[ INFO] [1622736355.077849937]:    1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000 
[ INFO] [1622736355.079416509]:   Camera Projection Paramters:
[ INFO] [1622736355.079545635]:    913.700317 0.000000 953.448302 0.000000 0.000000 1063.296631 777.871993 0.000000 0.000000 0.000000 1.000000 0.000000 
[ INFO] [1622736355.079603750]:   Camera coeffs provided, camera info messges will be published.
[ INFO] [1622736355.079715787]: *** SYSTEM INFORMATION ***
[ INFO] [1622736355.079800303]: Creating system instance...
[ INFO] [1622736355.079876179]: spinnaker_sdk_camera_driver package version: 1.1.0
[ INFO] [1622736358.561142601]: Spinnaker library version: 2.2.0.48
[ INFO] [1622736358.561482138]: Retreiving list of cameras...
[ INFO] [1622736358.682412436]: Numer of cameras found: 2
[ INFO] [1622736358.683603245]:  Cameras connected: 2
[ INFO] [1622736358.687538154]:   -21016017 Blackfly S BFS-U3-63S4C 1801.0.9.0
[ INFO] [1622736358.689282558]:   -20480529 Blackfly S BFS-U3-63S4C 1801.0.9.0
[ INFO] [1622736358.756872786]: Dynamic Reconfigure: Level : 4294967295
[ INFO] [1622736358.766220051]: *** FLUSH SEQUENCE ***
[ INFO] [1622736358.766800271]: Initializing cameras...
[ INFO] [1622736359.167285715]: Deinitializing cameras...
[ INFO] [1622736359.193855313]: All cameras deinitialized.
[ INFO] [1622736361.194425033]: Initializing cameras...
[ INFO] [1622736361.614702725]: onInit Initialized
[ INFO] [1622736361.615389350]: *** ACQUISITION ***
[ WARN] [1622736361.677023515]:  Looks like your calibration is not done at full Sensor Resolution for cam_id = 20480529 , Sensor_Width = 3096 given cameraInfo params:width = 1440
[ WARN] [1622736361.677418510]:  Looks like your calibration is not done at full Sensor Resolution for cam_id = 20480529 , Sensor_Height= 2094 given cameraInfo params:height = 1080

Running as a normal user:

$ roslaunch spinnaker_sdk_camera_driver node_acquisition.launch binning:=2
... logging to /home/administrator/.ros/log/f70e1e5e-c485-11eb-bce2-00044bcbdf38/roslaunch-cpr-mitre-6442.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://cpr-mitre:35979/

SUMMARY
========

PARAMETERS
 * /acquisition_node/binning: 2
 * /acquisition_node/cam_aliases: ['left_cam']
 * /acquisition_node/cam_ids: [20480529]
 * /acquisition_node/color: False
 * /acquisition_node/delay: 1.0
 * /acquisition_node/distortion_coeffs: [[-0.021141875266...
 * /acquisition_node/distortion_model: plumb_bob
 * /acquisition_node/exposure_time: 0
 * /acquisition_node/external_trigger: False
 * /acquisition_node/flip_horizontal: [False]
 * /acquisition_node/flip_vertical: [False]
 * /acquisition_node/frames: 3400
 * /acquisition_node/image_height: 1080
 * /acquisition_node/image_width: 1440
 * /acquisition_node/intrinsic_coeffs: [[1886.9232141485...
 * /acquisition_node/live: False
 * /acquisition_node/live_grid: False
 * /acquisition_node/master_cam: 20480529
 * /acquisition_node/max_rate_save: False
 * /acquisition_node/projection_coeffs: [[913.700317, 0.0...
 * /acquisition_node/rectification_coeffs: [[1.0, 0.0, 0.0, ...
 * /acquisition_node/region_of_interest/height: 0
 * /acquisition_node/region_of_interest/width: 0
 * /acquisition_node/region_of_interest/x_offset: 0
 * /acquisition_node/region_of_interest/y_offset: 0
 * /acquisition_node/save: False
 * /acquisition_node/save_path: ~
 * /acquisition_node/save_type: bmp
 * /acquisition_node/skip: 20
 * /acquisition_node/soft_framerate: 20
 * /acquisition_node/target_grey_value: 0
 * /acquisition_node/tf_prefix: 
 * /acquisition_node/time: False
 * /acquisition_node/to_ros: True
 * /acquisition_node/utstamps: False
 * /rosdistro: melodic
 * /rosversion: 1.14.11

NODES
  /
    acquisition_node (spinnaker_sdk_camera_driver/acquisition_node)

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

setting /run_id to f70e1e5e-c485-11eb-bce2-00044bcbdf38
process[rosout-1]: started with pid [6465]
started core service [/rosout]
process[acquisition_node-2]: started with pid [6482]
[ INFO] [1622736523.620144479]: Initializing nodelet with 8 worker threads.
[ INFO] [1622736523.679393702]: Initializing nodelet
[ INFO] [1622736523.681082008]: [ OK ] USB memory: 1024 MB
[ INFO] [1622736523.681202878]: *** PARAMETER SETTINGS ***
[ INFO] [1622736523.681283426]: ** Date = 20210603
[ INFO] [1622736523.683885375]:   Save path set via parameter to: /home/administrator
[ INFO] [1622736523.684017189]:   Camera IDs:
[ INFO] [1622736523.687979556]:     20480529
[ INFO] [1622736523.690393369]:   Camera Aliases:
[ INFO] [1622736523.690471676]:     20480529 >> left_cam
[ INFO] [1622736523.692148973]:   External trigger: false
[ INFO] [1622736523.694927987]:   Unique time stamps for each camera: false
[ INFO] [1622736523.696385241]:   color set to: false
[ INFO] [1622736523.697988455]:   20480529 flip_horizontal 0
[ INFO] [1622736523.699458541]:   20480529 flip_vertical 0
[ INFO] [1622736523.700847056]:   Exporting images to ROS: true
[ INFO] [1622736523.702340536]:   Showing live images setting: false
[ INFO] [1622736523.703823808]:   Showing grid-style live images setting: false
[ INFO] [1622736523.705613974]:   Max Rate Save Mode: false
[ INFO] [1622736523.707907204]:   Displaying timing details: false
[ INFO] [1622736523.709898212]:   No. of images to skip set to: 20
[ INFO] [1622736523.712011338]:   Init sleep delays set to : 1.00 sec
[ WARN] [1622736523.713338986]:   'fps' Parameter not set, using default behavior: fps=20.00
[ INFO] [1622736523.714947960]:   'exposure_time'=0, Setting autoexposure
[ WARN] [1622736523.716422335]:   'gain' Parameter not set, using default behavior: Auto gain based on target grey value
[ INFO] [1622736523.718695980]:   'target_grey_value'=0, Setting AutoExposureTargetGreyValueAuto to Continuous/ auto
[ INFO] [1622736523.721942793]:   Binning set to: 2
[ INFO] [1622736523.724804851]:   Using Software rate control, rate set to: 20
[ INFO] [1622736523.727407664]:   Saving images set to: 0
[ INFO] [1622736523.733502806]:   tf_prefix set to: 
[ INFO] [1622736523.747527578]:   Region of Interest set to width: 0    height: 0   offset_x: 0 offset_y: 0
[ INFO] [1622736523.751150312]:   Camera Intrinsic Paramters:
[ INFO] [1622736523.752628240]:    1886.923214 0.000000 604.721488 0.000000 1886.666877 493.477267 0.000000 0.000000 1.000000 
[ INFO] [1622736523.755968241]:   Camera Distortion Paramters:
[ INFO] [1622736523.756362628]:    -0.021142 -0.373387 2.385983 3.282457 
[ INFO] [1622736523.760070166]:   Camera Rectification Paramters:
[ INFO] [1622736523.760438536]:    1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 1.000000 
[ INFO] [1622736523.764589840]:   Camera Projection Paramters:
[ INFO] [1622736523.764937281]:    913.700317 0.000000 953.448302 0.000000 0.000000 1063.296631 777.871993 0.000000 0.000000 0.000000 1.000000 0.000000 
[ INFO] [1622736523.765054758]:   Camera coeffs provided, camera info messges will be published.
[ INFO] [1622736523.765434937]: *** SYSTEM INFORMATION ***
[ INFO] [1622736523.765602881]: Creating system instance...
[ INFO] [1622736523.765780041]: spinnaker_sdk_camera_driver package version: 1.1.0
[ INFO] [1622736525.122585618]: Spinnaker library version: 2.2.0.48
[ INFO] [1622736525.123166638]: Retreiving list of cameras...
[FATAL] [1622736525.128492366]: ASSERTION FAILED
    file = /home/administrator/catkin_ws/src/spinnaker_sdk_camera_driver/src/capture.cpp
    line = 185
    cond = numCameras_
    message = 
[FATAL] [1622736525.128690040]: No cameras found!
[FATAL] [1622736525.128794973]: 

[acquisition_node-2] process has died [pid 6482, exit code -6, cmd /home/administrator/catkin_ws/devel/lib/spinnaker_sdk_camera_driver/acquisition_node __name:=acquisition_node __log:=/home/administrator/.ros/log/f70e1e5e-c485-11eb-bce2-00044bcbdf38/acquisition_node-2.log].
log file: /home/administrator/.ros/log/f70e1e5e-c485-11eb-bce2-00044bcbdf38/acquisition_node-2*.log

The referenced log file does not exist, but here's the roslaunch log from the same directory: roslaunch-cpr-mitre-6442.log

vik748 commented 3 years ago

Usually the last step in installing the Spinnaker library adds the current user to the right groups with permissions to the usb etc. Are you sure you have installed the library correctly? Are you able to run the camera using SpinView as a standard user?

civerachb-cpr commented 3 years ago

Yes, I'm able to use SpinView as a normal user.

After rebooting the Jetson a few times it looks like the issue may have resolved itself for reasons I haven't yet identified. Re-running groups shows the same output as previously, so nothing's changed on that front. To install the Spinnaker library + tools I just downloaded the archive, unzipped it, and installed with sudo dpkg -i and sudo apt-get -f install to grab a few missing dependencies.

I don't have a good explanation for why it seems to be working now, but I'll keep an eye on it and leave another comment if it suddenly stops for some reason.

vik748 commented 3 years ago

Ideally you want to use the install_spinnaker_arm.sh script included with Spinnaker.

vik748 commented 3 years ago

@civerachb-cpr I am closing the issue since we haven't heard from you. Pls re-open if necessary.

civerachb-cpr commented 3 years ago

Sorry about the radio silence. I was unable to replicate the original problem. Not sure what exactly happened, but it appears to have resolved itself, so it's all good now. Thanks!