ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

polling an event stream

asked 2015-10-02 11:30:27 -0600

aaser gravatar image

Hi, I'm very new to ROS, and I'm having some issues understanding what the correct way to poll an event stream is. Currently I am reading events from an xbox controller, and I want to present a snapshot of the current controller state say 60 times per second. The code I've come up with is , (and less important, ).

This seems to be the wrong way to go about things, as I can't seem to find a way to actually make it run as an ROS node. What is the correct way to design this? Am I thinking about it wrong, or is there a simple yet obvious flaw? Running ROS indigo on linux mint.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-10-03 09:44:26 -0600

updated 2015-10-03 09:45:45 -0600

You should initalise ros node with:


for explanation check here.

So you should write something like this:

if __name__ == '__main__':


        loop = asyncio.get_event_loop()
        loop.add_reader(xboxc, partial(read_events, xboxc))

    except rospy.ROSInterruptException:


But if you use xbox controller with ROS probably you want to use joy package.

edit flag offensive delete link more


Thanks, appreciate it, and it seems like it's just what I was looking for too. I am aware of the joy package, but I wanted to use a controller as a learning tool since I get so much feedback from the system, rather than trying to divine why my arduino isnt blinking like it should. Thanks a lot!

aaser gravatar image aaser  ( 2015-10-03 14:23:54 -0600 )edit

Please mark question as answered if you are happy with the answer

destogl gravatar image destogl  ( 2015-10-06 03:38:48 -0600 )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


Asked: 2015-10-02 11:29:55 -0600

Seen: 400 times

Last updated: Oct 03 '15