Ask Your Question
0

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 http://pastebin.com/N8GvK2eM , (and less important, http://pastebin.com/u0J179e2 ).

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
1

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

destogl gravatar image

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

You should initalise ros node with:

rospy.init_node()

for explanation check here.

So you should write something like this:

if __name__ == '__main__':

    rospy.init_node('xbox_controller')

    try:
        loop = asyncio.get_event_loop()
        loop.add_reader(xboxc, partial(read_events, xboxc))
        loop.run_until_complete(summarize())

    except rospy.ROSInterruptException:

            pass

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

edit flag offensive delete link more

Comments

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 imageaaser ( 2015-10-03 14:23:54 -0600 )edit
1

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

destogl gravatar imagedestogl ( 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

Stats

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

Seen: 216 times

Last updated: Oct 03 '15