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

Running two joysticks under two namespaces

asked 2012-09-22 04:22:06 -0500

Hi everyone, I'm trying to learn to use namespaces here in ROS and for a first try I figure I would have two joysticks, one on /dev/input/js1 and the other on /dev/input/js2 -- I want two instances of joy_node running, one publishing on /ns1/joy and the other one publishing on /ns2/joy

my launch file looks like this:

<launch>
  <group ns="ns1">
    <param name="dev" value="/dev/input/js1" />
    <include file="$(find falkor_quadrotor_teleop)/launch/ps3_gamepad.launch" />
  </group>
  <group ns="ns2">
    <param name="dev" value="/dev/input/js2" />
    <include file="$(find falkor_quadrotor_teleop)/launch/ps3_gamepad.launch" />
  </group>
</launch>

And ps3_gamepad.launch looks like this:

<?xml version="1.0"?>

<launch>

  <node name="joy_node" pkg="joy" type="joy_node" output="screen" />
  <!-- Note that axis IDs are those from the joystick message plus one, to be able to invert axes by specifiying either positive or negative axis numbers.-->
  <!-- Axis 2 from joy message thus has to be set as '3' or '-3'(inverted mode) below-->
  <node name="quadrotor_teleop" pkg="hector_quadrotor_teleop" type="quadrotor_teleop">
    <param name="x_axis" value="2"/>
    <param name="y_axis" value="1"/>
    <param name="z_axis" value="4"/>
    <param name="yaw_axis" value="3"/>
    <param name="x_velocity_max" value="5"/>
    <param name="y_velocity_max" value="5"/>
    <param name="z_velocity_max" value="5"/>
  </node>
</launch>

However when I run the launch file, both instances of joy_node are listening to /dev/input/js0:

process[rosout-1]: started with pid [4514]
started core service [/rosout]
process[ns1/joy_node-2]: started with pid [4526]
process[ns1/quadrotor_teleop-3]: started with pid [4544]
[ INFO] [1348322541.484222195]: Opened joystick: /dev/input/js0. deadzone_: 0.050000.
process[ns2/joy_node-4]: started with pid [4564]
[ INFO] [1348322541.559938826]: Opened joystick: /dev/input/js0. deadzone_: 0.050000.
process[ns2/quadrotor_teleop-5]: started with pid [4582]

The parameters appear to be set correctly:

$ rosparam get /ns1
dev: /dev/input/js1
quadrotor_teleop: {x_axis: 2, x_velocity_max: 5, y_axis: 1, y_velocity_max: 5, yaw_axis: 3,
  z_axis: 4, z_velocity_max: 5}

$ rosparam get /ns2
dev: /dev/input/js2
quadrotor_teleop: {x_axis: 2, x_velocity_max: 5, y_axis: 1, y_velocity_max: 5, yaw_axis: 3,
  z_axis: 4, z_velocity_max: 5}

Any ideas on what I'm doing wrong here? Thanks.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2012-09-22 05:35:23 -0500

OK, I appear to have figured this out. Here's my launch file:

<launch>
  <group ns="ns1">
    <include file="$(find falkor_quadrotor_teleop)/launch/ps3_gamepad.launch">
      <arg name="joy_dev" value="/dev/input/js1" />
    </include>
  </group>
  <group ns="ns2">
    <include file="$(find falkor_quadrotor_teleop)/launch/ps3_gamepad.launch">
      <arg name="joy_dev" value="/dev/input/js2" />
    </include>
  </group>
</launch>

And here's my ps3_gamepad.launch file

<?xml version="1.0"?>

<launch>
  <arg name="joy_dev" />

  <node name="joy_node" pkg="joy" type="joy_node" output="screen">
    <param name="dev" value="$(arg joy_dev)" />
  </node>
  <!-- Note that axis IDs are those from the joystick message plus one, to be able to invert axes by specifiying either positive or negative axis numbers.-->
  <!-- Axis 2 from joy message thus has to be set as '3' or '-3'(inverted mode) below-->
  <node name="quadrotor_teleop" pkg="hector_quadrotor_teleop" type="quadrotor_teleop">
    <param name="x_axis" value="2"/>
    <param name="y_axis" value="1"/>
    <param name="z_axis" value="4"/>
    <param name="yaw_axis" value="3"/>
    <param name="x_velocity_max" value="5"/>
    <param name="y_velocity_max" value="5"/>
    <param name="z_velocity_max" value="5"/>
  </node>
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2012-09-22 04:22:06 -0500

Seen: 670 times

Last updated: Sep 22 '12