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

How to distinguish inputs from multiple joysticks on joy topic?

asked 2019-03-07 09:29:19 -0500

Tashk gravatar image

Hi, I'm currently working on a project that requires the use of multiple xbox 360 controllers to control a single robot (multi-master single-slave system). I can currently create two joy_nodes that receive inputs from the separate controllers distinguishing themselves from each other by changing their names to js0 and js1.

The issue is that both nodes publish to the joy topic so when subscribing to the topic (or using rostopic echo) it receives the inputs from both joysticks simultaneously. The question being how do I distinguish/separate the two joysticks from each other in the joy topic (I thought one solution would be to make each joy_node publish to a different topic namespace but couldn't find any solutions or tutorials for this).

Any help would be appreciated, thank you.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2019-03-07 10:15:10 -0500

gvdhoorn gravatar image

updated 2019-03-07 10:22:02 -0500

The question being how do I distinguish/separate the two joysticks from each other in the joy topic

You can't. The Joy message has no field for that (theoretically header.frame_id could be used, but no consumer checks that).

I thought one solution would be to make each joy_node publish to a different topic namespace

Yes, that would be one way to make sure they don't publish to the same topic.

but couldn't find any solutions or tutorials for this

Well, "topic namespace[s]" don't exist. Perhaps that is why you couldn't find something.

You have two options:

  1. use remapping (with roslaunch or with rosrun) to make each joy_node instance publish to a different topic
  2. put both joy_nodes in a different namespace (either directly on the node or via a group)

Which one would be more convenient depends on whether you already are using .launch files or not.

edit flag offensive delete link more

Comments

Thank you, I found that creating a roslaunch file then remapping within it was exactly what i was looking for. Although took me a while to figure out the correct <param> definitions to separate the controllers in a launch file.

Here is my Roslaunch file code for anybody who struggles with the same issue

<launch>

<group>
    <remap from='joy' to='j0'/>
    <node pkg='joy' name='joy0' type='joy_node'>
        <param name='dev' type='string' value='/dev/input/js0'/>
    </node>
</group>

<group>
    <remap from='joy' to='j1'/>
    <node pkg='joy' name='joy1' type='joy_node'>
        <param name='dev' type='string' value='/dev/input/js1'/>
    </node>
</group>

</launch>

Tashk gravatar image Tashk  ( 2019-03-09 11:04:59 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2019-03-07 09:28:11 -0500

Seen: 829 times

Last updated: Mar 07 '19