YDLIDAR / ydlidar_ros2_driver

ydlidar driver package under ros2
Other
54 stars 99 forks source link

How to initialize the driver without sudo? #41

Closed ywiyogo closed 8 months ago

ywiyogo commented 8 months ago

I've successfully install the SDK and the ros2_driver in my docker container. However, I still cannot start my lidar probably due to a permission error. Running sudo tri_test works, but not without sudo, which returns:

[YDLIDAR] Error, cannot bind to the specified [serial port:/dev/ttyUSB0] and [baudrate:230400]

Screenshot from 2023-12-29 13-01-59

The command ros2 launch ydlidar_ros2_driver ydlidar_launch_view.py returns this error:

[ydlidar_ros2_driver_node-1] [ERROR] [1703828580.750248162] [ydlidar_ros2_driver_node]: Unknown error

Unfortunantely, using sudo and ros2 doesn'T work:

$ sudo ros2 launch ydlidar_ros2_driver ydlidar_launch_view.py 
sudo: ros2: command not found

and running the ./initenv.sh doesn't work in the docker container:

ydlidar_ros2_driver/startup$ ./initenv.sh 
./initenv.sh: line 2: /etc/udev/rules.d/ydlidar.rules: Permission denied
./initenv.sh: line 4: /etc/udev/rules.d/ydlidar-V2.rules: Permission denied
./initenv.sh: line 6: /etc/udev/rules.d/ydlidar-2303.rules: Permission denied
udev: unrecognized service
udev: unrecognized service

ydlidar_ros2_driver/startup$ sudo ./initenv.sh 
udev: unrecognized service
udev: unrecognized service
ywiyogo commented 8 months ago

I've just found the solution. I need to change the permission access using sudo chmod 666 /dev/ttyUSB0.