umdlife / psdk_ros2

This repository is a ROS 2 wrapper for the DJI PSDK libraries.

Home Page:https://umdlife.github.io/psdk_ros2/documentation/Introduction.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed to run as non root users

Aspirinkb opened this issue · comments

I only can run the psdk-ros2 as root user.
device ttyTHS0:

 ls -la /dev/ttyTHS0
crwxrwxrwx 1 root dialout 240, 0  5月 29 11:38 /dev/ttyTHS0

Run it as non root user, errors as following:

[INFO] [launch]: All log files can be found below /home/<my_user>/.ros/log/2024-05-29-11-37-51-693863-ubuntu-66239
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [psdk_wrapper_node-1]: process started with pid [66250]
[psdk_wrapper_node-1] [INFO] [1716953871.938300117] [wrapper.psdk_wrapper_node]: Creating Constructor PSDKWrapper
[psdk_wrapper_node-1] [INFO] [1716953872.405925383] [wrapper.psdk_wrapper_node]: Configuring PSDKWrapper
[psdk_wrapper_node-1] [INFO] [1716953872.406324552] [wrapper.psdk_wrapper_node]: Loading parameters
[psdk_wrapper_node-1] [INFO] [1716953872.406767529] [wrapper.psdk_wrapper_node]: App name: ----
[psdk_wrapper_node-1] [INFO] [1716953872.406815049] [wrapper.psdk_wrapper_node]: App id: ----
[psdk_wrapper_node-1] [INFO] [1716953872.406850249] [wrapper.psdk_wrapper_node]: App key: ----
[psdk_wrapper_node-1] [INFO] [1716953872.406901193] [wrapper.psdk_wrapper_node]: Baudrate: 460800
[psdk_wrapper_node-1] [INFO] [1716953872.406937801] [wrapper.psdk_wrapper_node]: Using connection configuration file: /home/<my_user>/psdk_ros2_ws/src/psdk_ros2/psdk_wrapper/cfg/link_config.json
[psdk_wrapper_node-1] [INFO] [1716953872.407319817] [wrapper.psdk_wrapper_node]: Setting environment
[psdk_wrapper_node-1] [INFO] [1716953872.407509514] [wrapper.psdk_wrapper_node]: Registered OSAL handler
[psdk_wrapper_node-1] [INFO] [1716953872.407556554] [wrapper.psdk_wrapper_node]: Registered HAL handler
[psdk_wrapper_node-1] [INFO] [1716953872.407581066] [wrapper.psdk_wrapper_node]: Loaded configuration file
[psdk_wrapper_node-1] [INFO] [1716953872.407597290] [wrapper.psdk_wrapper_node]: Using DJI_USE_UART_AND_NETWORK_DEVICE
[psdk_wrapper_node-1] [INFO] [1716953872.407650154] [wrapper.psdk_wrapper_node]: Environment has been set!
[psdk_wrapper_node-1] [INFO] [1716953872.408285419] [wrapper.psdk_wrapper_node]: Activating PSDKWrapper
[psdk_wrapper_node-1] [INFO] [1716953872.408383019] [wrapper.psdk_wrapper_node]: Init DJI Core...
[psdk_wrapper_node-1] chmod: changing permissions of '/dev/ttyTHS0': Operation not permitted
...
[psdk_wrapper_node-1] [ERROR] [1716953900.394957751] [wrapper.psdk_wrapper_node]: DJI core could not be initiated. Error code is: 225. Retrying for 1 time.
[psdk_wrapper_node-1] chmod: changing permissions of '/dev/ttyTHS0': Operation not permitted
[psdk_wrapper_node-1] chmod: changing permissions of '/dev/ttyTHS0': Operation not permitted

Could you help to run it as non root user?

Hi @Aspirinkb,
These requirements are not from the wrapper itself but from the Payload-SDK libraries. To run it as non root you can try to add your user to the dialout group or create an udev rule for this device which grants you the needed permissions.
Hope it helps!

@biancabnd I attempted to run the program as a regular user by adding the user to the dialout group and creating a udev rule. However, it throws the following error. When I run the program as root, it executes successfully without any errors. Can please try at your end to run the wrapper as non root user.

[psdk_wrapper_node-1] [ERROR] [1718023100.202970640] [wrapper.camera_node]: Could not initialize camera manager. Error code: 227
[psdk_wrapper_node-1] [ERROR] [1718023100.211768970] [wrapper.psdk_wrapper_node]: Failed to finish transition 3. Current state is now: inactive (Could not publish transition: publisher's context is invalid, at /tmp/binarydeb/ros-humble-rcl-5.3.6/src/rcl/publisher.c:389, at /tmp/binarydeb/ros-humble-rcl-lifecycle-5.3.6/src/rcl_lifecycle.c:368)
[ERROR] [launch_ros.actions.lifecycle_node]: Failed to make transition 'TRANSITION_ACTIVATE' for LifecycleNode '/wrapper/psdk_wrapper_node'
[psdk_wrapper_node-1] [INFO] [1718023100.212966214] [wrapper.psdk_wrapper_node]: Destroying PSDKWrapper

image

@umesh-mane did you manage to solve this permission issues?

@bonchan No I'm only able to get the permission for /dev/ttyUSB0 port and not for /dev/ttyACM0. resulting I'm able to get only telemetry and flight control module and not the camera module.

Hey @bonchan AND @umesh-mane,
try as suggested by @biancabnd, this
image

It is referenced here https://developer.dji.com/onboard-sdk/documentation/development-workflow/environment-setup.html

Even though it says its for the OSDK, the permisions needed are the same

@vicmassy that did it. thanks
I had this rules set for ttyUSB0 and ttyACM0
lines 1 to 6
image
but i had them as symlinks. maybe that was my problem

I changed the file and only left lines 9 and 10

when i start psdk_ros2 it still shows that psdk lib(dji) is trying to change the permissions but video stream works fine,. Ill try to use the symlinks and get back here.

@bonchan @vicmassy it works for me as well without symlink.
@bonchan which drone are you using ?

@umesh-mane M300 + Jetson Orin Nano
Im still having some issues with the bulk configuration but for now im ok to go forward

@bonchan Okay.
have you tried to setup bulk configration ? USB bulk setup you can check it here.
Are you using E-port development kit ?

Also @bonchan @vicmassy , I attempted to add symlinks into the udev rule, but it didn't work. When I reverted to the configuration without the symlink, it worked.

@umesh-mane yes, I'm using the E-port. and yes. I have tried to setup bulk configuration following that guide. I managed to do it on jetson nano but now I switched to jetson orin nano, I'll get back here once I make it work.

@vicmassy @biancabnd
[psdk_wrapper_node-14] chmod: changing permissions of '/dev/ttyUSB0': Operation not permitted [psdk_wrapper_node-14] chmod: changing permissions of '/dev/ttyACM0': Operation not permitted
Is this permission change happening because of the psdk_wrapper code, or is it occurring from the DJI_PSDK side?
After some tries wrapper run successfully but I want elimate this is there any way ?

Hi. This is required by the DJI PSDK not the wrapper itself.

@biancabnd Okay
Thanks for update.

commented

I am using DJI_USE_UART_AND_NETWORK_DEVICE configuration to transform serial port data (UART) and camera data (Network).
I have add my user to dialout group and relogin.
I have encountered the same issue (Operation not permitted) persisting without any changes. I would appreciate guidance on how to proceed further.
Operation not permitted tip:

[psdk_wrapper_node-1] chmod: changing permissions of '/dev/ttyTHS0': Operation not permitted

check serial port device and user group:

# check serial port device ttyTHS0, user group
 ls /dev/ttyTHS0 -la
crwxrwxrwx 1 root dialout 240, 0  7月  2 15:27 /dev/ttyTHS0

# check dialout group members
grep dialout /etc/group
dialout:x:20:<my_user>
commented

@umesh-mane yes, I'm using the E-port. and yes. I have tried to setup bulk configuration following that guide. I managed to do it on jetson nano but now I switched to jetson orin nano, I'll get back here once I make it work.

@bonchan I give up using usb bulk to transform camera data on Jetson Orin, using network is ok.

I am using DJI_USE_UART_AND_NETWORK_DEVICE configuration to transform serial port data (UART) and camera data (Network). I have add my user to dialout group and relogin. I have encountered the same issue (Operation not permitted) persisting without any changes. I would appreciate guidance on how to proceed further. Operation not permitted tip:

[psdk_wrapper_node-1] chmod: changing permissions of '/dev/ttyTHS0': Operation not permitted

check serial port device and user group:

# check serial port device ttyTHS0, user group
 ls /dev/ttyTHS0 -la
crwxrwxrwx 1 root dialout 240, 0  7月  2 15:27 /dev/ttyTHS0

# check dialout group members
grep dialout /etc/group
dialout:x:20:<my_user>

Hi @Aspirinkb,

To solve this issue you could change the permissions of the specific device sudo chmod 777 /dev/ttyTHS0. If you want this change to be persistent, you can create an udev rule which grants the needed permissions to this specific device. In case you are using a docker to launch the psdk wrapper, you could run the docker with the privileged flag set to true.

Hope it helps.

commented

I am using DJI_USE_UART_AND_NETWORK_DEVICE configuration to transform serial port data (UART) and camera data (Network). I have add my user to dialout group and relogin. I have encountered the same issue (Operation not permitted) persisting without any changes. I would appreciate guidance on how to proceed further. Operation not permitted tip:

[psdk_wrapper_node-1] chmod: changing permissions of '/dev/ttyTHS0': Operation not permitted

check serial port device and user group:

# check serial port device ttyTHS0, user group
 ls /dev/ttyTHS0 -la
crwxrwxrwx 1 root dialout 240, 0  7月  2 15:27 /dev/ttyTHS0

# check dialout group members
grep dialout /etc/group
dialout:x:20:<my_user>

Hi @Aspirinkb,

To solve this issue you could change the permissions of the specific device sudo chmod 777 /dev/ttyTHS0. If you want this change to be persistent, you can create an udev rule which grants the needed permissions to this specific device. In case you are using a docker to launch the psdk wrapper, you could run the docker with the privileged flag set to true.

Hope it helps.

Thanks @biancabnd, but I did change the permissions of the specific device with sudo chmod 777 /dev/ttyTHS0, as you can see above when check device ttyTHS0 crwxrwxrwx 1 root dialout 240, 0 7月 2 15:27 /dev/ttyTHS0

I see, this should already work. How are you running the wrapper?