Ask Your Question
1

Log the alive time of a rosnode?

asked 2016-12-05 14:39:45 -0500

215 gravatar image

I am currently working on a rosnode which purpose is to generate CSV files about certain information. One of the information i am seeking is to know how much time a rosnode has been alive.

I know that you using ros::master::getNodes an get a vector of the active nodes, but is it possible to know how long time it has been turned on?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2016-12-05 15:20:00 -0500

ahendrix gravatar image

updated 2016-12-05 15:20:23 -0500

The ROS master does not track how long a node has been online, and the node list is reported by the nodes themselves, so there are some cases where a node may not be removed from the list because it shuts down improperly (ie segfault or runtime exception).

You'll probably need to write your own code which monitors which nodes are online (using the node ping method), and keeps track of the PID for each process; changes in the PID will indicate that the process has been restarted or replaced by a new node with the same name.

The rosprofiler package keeps track of which nodes are running, their PID and their CPU time, but doesn't track overall node uptime. It might be a good starting point for the tool you're trying to build.

edit flag offensive delete link more

Comments

Thats exactly what i need it for.. aren't there any other way.. like using a timer or something like that?. The node i monitor is a control_node.. to measure some performance, i need to know much time it has been on.

215 gravatar image215 ( 2016-12-05 17:49:35 -0500 )edit

Maybe querying the process creating time from the PID is what you're looking for: https://pythonhosted.org/psutil/#psut...

ahendrix gravatar imageahendrix ( 2016-12-06 10:59:26 -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-12-05 14:39:45 -0500

Seen: 125 times

Last updated: Dec 05 '16