TurtleBot2 not moving with teleop_twist_joy

asked 2023-07-27 10:52:27 -0500

Djinn gravatar image

updated 2023-07-27 11:13:35 -0500

Hello, I am currently working on my TurtleBot2 on Ubuntu 22.04 and ROS2. I have set up everything and am now trying to move TurtleBot 2 with my Stadia Controller. I am using this ros2 launch teleop_twist_joy teleop-launch.py joy_config:='stadia' command, and it proceeds to show me all needed information I have in my Stadia config but the TurtleBot wont move. I have checked the topic monitor and whenever I use the Controller it seems like it does write something into the /cmd_vel topic and the /joy topic but the TurtleBot wont move. I've also checked the /event/bumper topic in order to exclude that the TurtleBot2 is not connected properly. Can anyone help me out?

teleop_launch.py:

import os

from ament_index_python.packages import get_package_share_directory

import launch
import launch_ros.actions


def generate_launch_description():
    joy_config = launch.substitutions.LaunchConfiguration('joy_config')
    joy_dev = launch.substitutions.LaunchConfiguration('joy_dev')
    config_filepath = launch.substitutions.LaunchConfiguration('config_filepath')

    return launch.LaunchDescription([
        launch.actions.DeclareLaunchArgument('joy_config', default_value='stadia'),
        launch.actions.DeclareLaunchArgument('joy_dev', default_value='/dev/input/js0'),
        launch.actions.DeclareLaunchArgument('config_filepath', default_value=[
            launch.substitutions.TextSubstitution(text=os.path.join(
                get_package_share_directory('teleop_twist_joy'), 'config', '')),
            joy_config, launch.substitutions.TextSubstitution(text='.config.yaml')]),

        launch_ros.actions.Node(
            package='joy', executable='joy_node', name='joy_node',
            parameters=[{
                'dev': joy_dev,
                'deadzone': 0.3,
                'autorepeat_rate': 20.0,
            }]),
        launch_ros.actions.Node(
            package='teleop_twist_joy', executable='teleop_node',
            name='teleop_twist_joy_node', parameters=[config_filepath]),
    ])

stadia.config.yaml:

    teleop_twist_joy_node:
  ros__parameters:
    axis_linear:  # Left thumb stick vertical
      x: 1
    scale_linear:
      x: 0.7
    scale_linear_turbo:
      x: 1.5

    axis_angular:  # Left thumb stick horizontal
      yaw: 2
    scale_angular:
      yaw: 0.4

    enable_button: 2  # Left trigger button
    enable_turbo_button: 5  # Right trigger button
edit retag flag offensive close merge delete

Comments

@gvdhoorn I saw that you have answered alot of questions about similar topics, could you help me out? Thank you in advance !

Djinn gravatar image Djinn  ( 2023-07-27 11:13:09 -0500 )edit

@ljaniec did you have this problem while working with the TurtleBot2 or do you know how to solve it?

Djinn gravatar image Djinn  ( 2023-08-03 10:57:01 -0500 )edit

@Djinn Doesn't TB2 use other topic than /cmd_vel? It was something with mux in the name

ljaniec gravatar image ljaniec  ( 2023-08-09 07:01:21 -0500 )edit

@ljaniec how do I change the topic from /cmd_vel to /cmd_vel_mux? Do I have to change it in the kobuki_node file?

Djinn gravatar image Djinn  ( 2023-08-09 07:36:01 -0500 )edit

Modify your launchfile with remappings, like here:

talker_node = Node( package="demo_nodes_cpp", executable="talker", name="my_talker", remappings=[ ("chatter", "my_chatter") ] ) and listener_node = Node( package="demo_nodes_py", executable="listener", remappings=[ ("chatter", "my_chatter") ] )

ljaniec gravatar image ljaniec  ( 2023-08-09 08:33:16 -0500 )edit

@ljaniec so Ive modified my launch file to this :

launch_ros.actions.Node(
        package='teleop_twist_joy', executable='teleop_node',
        name='teleop_twist_joy_node', remappings=[("cmd_vel","cmd_vel_mux/input/teleop")], parameters=[config_filepath]),
])

but the turtlebot still wont move. Ive also tried "cmd_vel_mux", but nothing was written into this topic when I was using the controller and looking at rqt.

Djinn gravatar image Djinn  ( 2023-08-09 10:20:26 -0500 )edit