Ask Your Question
1

How to launch nodes with realtime priority

asked 2016-10-20 09:23:48 -0500

Cerin gravatar image

Is there any built-in mechanism to control the nice value for a ROS node?

I have a node that exposes a simple service for generating speech via espeak. Usually, the generated speech sounds fine, but sometimes when the CPU is under load, the speech will sound slow and stuttering.

I can improve this by manually setting my speech node to run in near-realtime via nice, but that feels hacky. Is there a formal way to do this in ROS?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2016-10-20 10:48:30 -0500

gvdhoorn gravatar image

updated 2016-10-20 10:49:35 -0500

(I wouldn't call it realtime priority, but ..)

I haven't done it myself, but you can probably use roslaunch's launch-prefix together with the Linux nice utility to start a node at a higher nice value.

Something like launch-prefix="nice -n N" (where N is the nice value).

See How to bind a node to a specific cpu core? for a related Q&A.

See roslaunch/XML/node - Attributes for more info on launch-prefix.

edit flag offensive delete link more

Comments

This works well for me. However, you have to be root to set negative nice values. So if you want to give your node a higher priority this way, you have to run roslaunch as root.

Felix Widmaier gravatar imageFelix Widmaier ( 2017-02-24 06:15:07 -0500 )edit

Couldn't you add sudo -E to the launch-prefix? Still a security risk, but avoids running all of roslaunch as root.

gvdhoorn gravatar imagegvdhoorn ( 2017-02-24 06:39:35 -0500 )edit

Hm, maybe with some more configuration. Only doing sudo -E nice -n N resulted in the following error:

sudo: no tty present and no askpass program specified
Felix Widmaier gravatar imageFelix Widmaier ( 2017-02-24 07:17:16 -0500 )edit

Yes. As soon as a posted the comment I wondered myself how that would work with the password. "passwordless sudo" for a single binary could be an option, but that still has an impact on security.

gvdhoorn gravatar imagegvdhoorn ( 2017-02-24 07:35:08 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-10-20 09:23:48 -0500

Seen: 1,854 times

Last updated: Oct 20 '16