ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to run a single node as root [ROS2]

asked 2021-11-22 06:33:50 -0600

MAB Jakub gravatar image

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.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2022-03-22 05:32:29 -0600

mcbed gravatar image

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.

edit flag offensive delete link more
1

answered 2022-03-16 02:30:36 -0600

MAB Jakub gravatar image

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.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2021-11-22 06:33:50 -0600

Seen: 1,434 times

Last updated: Mar 22 '22