Ask Your Question

Revision history [back]

Firstly: I would strongly encourage you to NOT run any ROS tool as root. For example, the created bagfiles would then be owned by root.

But if you still want to do it, you have to source /opt/ros/melodic/setup.bash in your root shell (like for any other user). Then rosbag and everything should work fine. Although I would suggest trying creating a specific user for the task. (see https://askubuntu.com/questions/676007/how-do-i-make-my-systemd-service-run-via-specific-user-and-start-on-boot)