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

acorn's profile - activity

2016-03-25 05:58:41 -0500 received badge  Taxonomist
2013-06-02 23:50:19 -0500 received badge  Notable Question (source)
2013-06-02 23:50:19 -0500 received badge  Famous Question (source)
2013-01-10 15:20:55 -0500 received badge  Popular Question (source)
2013-01-10 13:47:42 -0500 commented question How to use select() or poll() in a ROS c++ node

Lorenz, thanks for the answer and suggestions. It sounds like the basic answer to my question is "you cannot do that" which is fine -- I'll use one of the other methods suggested. Thanks.

2013-01-10 13:45:05 -0500 received badge  Scholar (source)
2013-01-10 07:07:23 -0500 commented question How to use select() or poll() in a ROS c++ node

Polling does work, but I prefer not to tie up the processor until something actually arrives on the serial port. Sleeping in select() allows other processes to use 100% of the cpu (or allows the cpu to go idle to save pwr), and also allows the process to wake up quickly when serial traffic arrives.

2013-01-09 21:07:28 -0500 asked a question How to use select() or poll() in a ROS c++ node

How do I use select() or poll() to sleep a (c++) ros node's main thread until either a subscribed message arrives or until some other file descriptor is readable?

For example I have a node that is subscribed to a topic and also listening to a serial port. I want the process to sleep (in select() or poll()) until either the serial port is readable or the socket(s) that ROS is using to receive subscribed messages is readable. I think I can accomplish this in either of 2 ways:

A) If I can get a list of file descriptors that ROS is using I can call select myself. (When any of the ROS file descriptors are readable I would call ros::spinOnce() so ros can read messages and call callbacks.)

or

B) If I can pass a file descriptor (the serial port) to ROS with a callback to call when the fd is readable then ROS can add the fd to its own select/poll list (and I can call ros::spin() and wait for callbacks).

It looks like ros::PollSet::addSocket() is supposed to allow (B), but I am not sure how to use it. (E.g. how do I get a pointer to the ros::PollSet?)

I am currently using fuerte on Ubuntu 10.04.

Thanks! -Acorn