Output or input topic remapping for joy_node or teleop_twist_joy_node not working

asked 2022-09-19 17:22:59 -0600

dvy gravatar image

Hi,

System: Ubuntu 20.04 with ROS2 foxy

I have a joystick which does not show any buttons in jstest but can read the values on the axes. I want to control a robot in gazebo using that joystick. But the problem is the enable_button: 4 configuration parameter present for teleop_twist_joy_node. Since my joystick does not have any button, I can't move the robot. My approach to overcome this issue is as below.

Method 1 (Output topic remapping for joy_node): joy_node publishes /joy topic. Somehow manage to change this output topic to /joy_renamed, make a subscriber which listens to /joy_renamed and force sets the button number 4 to 1 and publish to /joy topic again. This way, ROS2 would think that button 4 is always pushed and the robot should move by changing the axes values (by the big round buttons on joystick).

Method 2 (Input topic remapping for teleop_twist_joy_node): If method 1 is not possible, don't change anything with the joy_node does. Make a subscriber which listens to the /joy topic, force set the button number 4 to 1 and publish to /joy_renamed topic. Since, teleop_twist_joy_node listens to /joy topic by default, I want to make it listen to /joy_renamed instead. For this, I tried to use topic remapping but it is not working for me.

Method 3: Simulate a joystick based on the input from my real joystick and complement it with the button configuration somehow.

I am using the namespace joy_teleop and below is the yaml configuration file through which I am trying to do remap for method 2.

joy_teleop/teleop_twist_joy_node:
  ros__parameters:
    axis_linear:
      x: 1
    scale_linear:
      x: 0.4
    scale_linear_turbo:
      x: 1.0
    axis_angular:
      yaw: 0
    scale_angular:
      yaw: 0.6
    scale_angular_turbo:
      yaw: 1.2
    enable_button: 4
    enable_turbo_button: 5
    remap:
    -
        from: "/joy/renamed"
        to: "/joy_teleop/joy"
joy_teleop/joy_node:
  ros__parameters:
    deadzone: 0.1
    autorepeat_rate: 20.0
    dev: /dev/input/f710

Please suggest.

Thanks, Dev

edit retag flag offensive close merge delete

Comments

2

Could you instead set require_enable_button: False as a parameter to teleop_twist_joy? It seems to me from the source that this would remove the need for the enable button altogether, unless you want turbo mode.

Ronoman gravatar image Ronoman  ( 2022-09-19 17:54:51 -0600 )edit

@Ronoman: Yes, it worked. Thanks! Though it solved my problem but do you see any issue with the remapping or any suggestion for method 3?

dvy gravatar image dvy  ( 2022-09-19 18:50:20 -0600 )edit

You could definitely create a node that sits in between joy_node and teleop_twist_joy_node that artificially inserts an extra button press. You could do this conditionally based on any number of things if you do it in a node (key press, message on another topic, only on Fridays, etc).

Both method 1 and method 2 you suggest involve remapping, and I think the only difference is where you remap (at joy_node or teleop_twist_joy_node). Either should work here, you just need to pass the remapping parameters along correctly.

It sounds like your method 3 is creating a custom joy_node to do what you want, which would also be an option, but probably more work than 1 or 2.

Ronoman gravatar image Ronoman  ( 2022-09-19 19:16:01 -0600 )edit