0
$\begingroup$

Rosanswers logo

Hello, I am trying to set up a ROS2 (foxy) node to run as root (with sudo). The node is running high frequency, low level operations on the RT-Linux kernel - thus the need for root access.

I've been trying to run the node as root but the other nodes (and also tools like ros2 topic echo) don't seem to communicate with each other. Echo doesn't print anything, and callbacks on my node's are not triggered. I've tried to set up ROS_DOMAIN_ID, also sourced .bashrc and /opt/ros/foxy/setup.bash nut neither of these things seem to solve the problem.

The last thing that I've tried was creating a script that executed:

sudo bash -c "export ROS_DOMAIN_ID=69 &&  source install/setup.bash && source /home/robot/.bashrc && ros2 launch ros2_bringup robot.launch.py"

Has anyone done something like that? Is there any step that I'm missing? Googling doesn't really show up anything helpfull.


Originally posted by MAB Jakub on ROS Answers with karma: 33 on 2021-11-22

Post score: 0

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

Hi, If you run a node with sudo it can only communicate with other nodes if these are also run with sudo on the same PC.


Originally posted by mcbed with karma: 36 on 2022-03-22

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$
0
$\begingroup$

Rosanswers logo

For anyone interested: I wasn't able to solve the problem, but I've found the workaround of sorts. The solution is to run my node as normal user in parallel with a sudo script that monitors the node and set all the execution parameters. The downside is that I've needed to use some sleep/delay functions to wait for the node to initialise, so this may cause problems in the future, but it is good enough form now.


Originally posted by MAB Jakub with karma: 33 on 2022-03-16

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.