astuff / avt_vimba_camera

ROS1/2 Driver for AVT cameras using VIMBA SDK.
Other
22 stars 43 forks source link

ROS1: Can't run driver as root #96

Closed subeiammar closed 2 years ago

subeiammar commented 2 years ago

I'm trying to run the driver for two Alvium 1800 U-1236c USB cameras in ROS Melodic for stereo imaging. I'm using this ROS1 driver as part of a bigger system of sensors and ROS drivers, and I need to run a lot of drivers as root to avoid permission issues.

With that said, I am able to run the driver for two cameras as a non-root user just fine with roslaunch avt_vimba_camera test.launch. Here's the relevant output:

[ INFO] [1653692850.006456854]: [Vimba System]: AVT Vimba System initialized successfully
[ INFO] [1653692850.006586017]: [Vimba System]: AVT Vimba System initialized successfully
[ INFO] [1653692850.007329862]: Searching for cameras ...
[ INFO] [1653692850.007448399]: Searching for cameras ...
[ INFO] [1653692850.007669084]: Found camera named Allied Vision 1800 U-1236c:
[ INFO] [1653692850.007683197]:  - Model Name     : 1800 U-1236c
[ INFO] [1653692850.007691685]:  - Camera ID      : DEV_1AB22C0143CE
[ INFO] [1653692850.007698626]:  - Serial Number  : 01RYM
[ INFO] [1653692850.007705446]:  - Interface ID   : VimbaUSBInterface_0x0
[ INFO] [1653692850.007712965]:  - Interface type : USB
[ INFO] [1653692850.007720021]:  - Access type    : Read and write access
[ INFO] [1653692850.007784285]: Found camera named Allied Vision 1800 U-1236c:
[ INFO] [1653692850.007785832]:  - Interface type : USB
[ INFO] [1653692850.007796299]:  - Model Name     : 1800 U-1236c
[ INFO] [1653692850.007797021]:  - Access type    : Read and write access
[ INFO] [1653692850.007807339]:  - Camera ID      : DEV_1AB22C0143DC
[ INFO] [1653692850.007815444]:  - Serial Number  : 01RZ0
[ INFO] [1653692850.007825577]:  - Interface ID   : VimbaUSBInterface_0x0
[ INFO] [1653692850.007835095]:  - Interface type : USB
[ INFO] [1653692850.007844266]:  - Access type    : Read and write access
[ INFO] [1653692850.062520539]: Trying to open camera by ID: 01RZ0
[ INFO] [1653692850.063513144]: Trying to open camera by ID: 01RYM
[ INFO] [1653692850.158668240]: Opened connection to camera named Allied Vision 1800 U-1236c with ID DEV_1AB22C0143CE
[ INFO] [1653692850.160581913]: Opened connection to camera named Allied Vision 1800 U-1236c with ID DEV_1AB22C0143DC

However, running the driver with sudo bash -ic 'roslaunch avt_vimba_camera test.launch' instead outputs:

[ERROR] [1653694251.671199815]: [Vimba System]: Could not start Vimba system: TL not loaded.
[ERROR] [1653694251.674609727]: [Vimba System]: Could not start Vimba system: TL not loaded.
[ INFO] [1653694251.728078109]: Trying to open camera by ID: 01RZ0
[ WARN] [1653694251.728141620]: Could not find camera using 01RZ0. Retrying every two seconds ...
[ INFO] [1653694251.728293049]: Trying to open camera by ID: 01RYM
[ WARN] [1653694251.728327857]: Could not find camera using 01RYM. Retrying every two seconds ...

I realize that the transport layer is not loading properly, and that I can resolve this issue by not running the driver as root. I was just wondering why this issue would occur in the first place. Has anyone else seen something similar?

icolwell-as commented 2 years ago

Hi @subeiammar, I've never come across this, but I suspect it's related to environment variables, that's usually the case when running something as root doesn't work as expected.

I looked in the VimbaGigETL install script, and it appears that there is a file located at /etc/profile.d/VimbaGigETL_64bit.sh that contains the following:

#!/bin/sh

#Do not edit this file manually because it may be overwritten automatically.
export GENICAM_GENTL64_PATH=$GENICAM_GENTL64_PATH:"/home/ian/opt/Vimba_5_0/VimbaGigETL/CTI/x86_64bit"

I'm guessing this file doesn't get sourced when running as root, and the GENICAM_GENTL64_PATH environment variable is missing.

You can try sourcing that file, or you could maybe try the -E flag when running sudo as described here.

subeiammar commented 2 years ago

Yeah I suspected it didn't have much to do with the driver itself, sorry about that. It had been a long day... :upside_down_face:

In any case, you've definitely pointed me in the right direction and I believe it's resolved. Thanks again!