Ask Your Question
0

Remapping diff drive controller to cmd_vel

asked 2021-10-18 14:00:41 -0500

ericnasanta gravatar image

updated 2021-10-21 14:44:31 -0500

Hi!

I'm looking to use nav2 with my current diff drive controller setup. My controller is currently subscribed to the /diff_drive_controller/cmd_vel_unstamped topic, while it appears nav is publishing to the /cmd_vel topic. Is there a way I can remap my current controller to subscribe to the /cmd_vel topic.

I'm currently working with ros2 foxy on Ubuntu 20.04 in Gazebo.

Here's how i'm loading my controllers in my launch file:

robot_state_publisher_node = launch_ros.actions.Node(
    package='robot_state_publisher',
    executable='robot_state_publisher',

    parameters=[{'use_sim_time': LaunchConfiguration('use_sim_time')},{'robot_description': Command(['xacro ', LaunchConfiguration('model')])}]
)

rviz_node = launch_ros.actions.Node(
    package='rviz2',
    executable='rviz2',
    name='rviz2',
    output='screen',
    parameters=[{'use_sim_time': LaunchConfiguration('use_sim_time')}],
    arguments=['-d', LaunchConfiguration('rvizconfig'),{ 'robot_description': Command(['xacro ', LaunchConfiguration('model')])}],
)
spawn_entity = launch_ros.actions.Node(
    package='gazebo_ros',
    executable='spawn_entity.py',
    arguments=['-entity', 'robotech', '-topic', { 'robot_description': Command(['xacro ', LaunchConfiguration('model')])}],
    output='screen',

)

robot_localization_node = launch_ros.actions.Node(
  package='robot_localization',
   executable='ekf_node',
   name='ekf_filter_node',
   output='screen',
   parameters=[os.path.join(pkg_share, 'config/ekf.yaml'), {'use_sim_time': LaunchConfiguration('use_sim_time')},{ 'robot_description': Command(['xacro ', LaunchConfiguration('model')])}]
)

load_joint_state_controller = ExecuteProcess(
    cmd=['ros2', 'control', 'load_controller', '--set-state','start',
         'joint_state_broadcaster'],
    output='screen'
)

load_joint_trajectory_controller = ExecuteProcess(
    cmd=['ros2', 'control', 'load_controller', '--set-state','start', 'joint_trajectory_controller'],
    output='screen'
)

load_diff_drive_controller = ExecuteProcess(
    cmd=['ros2', 'control', 'load_controller', '--set-state','start', 'diff_drive_controller'],
    output='screen'
)

return launch.LaunchDescription([

    launch.actions.DeclareLaunchArgument(name='gui', default_value='False',
                                        description='Flag to enable joint_state_publisher_gui'),
    launch.actions.DeclareLaunchArgument(name='model', default_value=default_model_path,
                                        description='Absolute path to robot urdf file'),

    launch.actions.DeclareLaunchArgument(name='rvizconfig', default_value=default_rviz_config_path,
                                        description='Absolute path to rviz config file'),
    launch.actions.ExecuteProcess(cmd=['gazebo','--verbose', '-s', 'libgazebo_ros_init.so', '-s', 'libgazebo_ros_factory.so', world_path], output='screen'),

    launch.actions.DeclareLaunchArgument(name='use_sim_time', default_value='True',
                                        description='Flag to enable use_sim_time'),

    RegisterEventHandler(
        event_handler=OnProcessExit(
            target_action=spawn_entity,
            on_exit=[load_joint_state_controller],
        )
    ),
    RegisterEventHandler(
        event_handler=OnProcessExit(
            target_action=load_joint_state_controller,
            on_exit=[load_joint_trajectory_controller],
        )
    ),
    RegisterEventHandler(
        event_handler=OnProcessExit(
            target_action=load_joint_state_controller,
            on_exit=[load_diff_drive_controller],
        )
    ),
    robot_state_publisher_node,
    spawn_entity,
    robot_localization_node,
    rviz_node
])

Edit: and this is my config file.

controller_manager:
  ros__parameters:
    update_rate: 100  # Hz
    use_sim_time: True
    joint_state_broadcaster:
      type: joint_state_broadcaster/JointStateBroadcaster



    joint_trajectory_controller:
      type: joint_trajectory_controller/JointTrajectoryController

    diff_drive_controller:
      type: diff_drive_controller/DiffDriveController

diff_drive_controller:
  ros__parameters:

    use_sim_time: True
    left_wheel_names: ["drivewhl_l_joint"]
    right_wheel_names: ["drivewhl_r_joint"]


    wheel_separation: 0.406
    #wheels_per_side: 1  # actually 2, but both are controlled by 1 signal
    wheel_radius: 0.0865

    wheel_separation_multiplier: 1.0
    left_wheel_radius_multiplier: 1.0
    right_wheel_radius_multiplier: 1.0

    publish_rate: 50.0
    odom_frame_id: odom
    base_frame_id: base_link
    pose_covariance_diagonal : [0.001, 0.001, 0.001, 0.001, 0.001, 0.01]
    twist_covariance_diagonal: [0.001, 0.001, 0.001, 0.001, 0.001, 0.01]

    open_loop: true
    enable_odom_tf: false



    cmd_vel_timeout: 0.5
    #publish_limited_velocity: true
    use_stamped_vel: false
    #velocity_rolling_window_size: 10

    # Preserve turning radius when limiting speed/acceleration/jerk
    preserve_turning_radius: false

    # Publish limited velocity
    publish_cmd: false

    # Publish wheel data
    publish_wheel_data: false

    # Velocity and acceleration limits
    # Whenever a min_* is unspecified, default to -max_*

    linear.x.max_velocity: 100.0
    linear.x.min_velocity: -100.0
    linear.x.max_acceleration: 5.0


    angular.z.max_velocity: 100.0
    angular.z.min_velocity: -100.0
    angular.z.max_acceleration: 5.0



joint_trajectory_controller:
  ros__parameters:
    use_sim_time: True
    joints:
      - frcasterbase
      - frcasterwheel
      - rrcasterbase
      - rrcasterwheel
      - rlcasterbase
      - rlcasterwheel
      - flcasterbase
      - flcasterwheel
      - drivewhl_l_joint
      - drivewhl_r_joint


    interface_name: position

    command_interfaces:
      - position

    state_interfaces:
      - position
      - velocity
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-10-21 18:41:07 -0500

miura gravatar image

I think there are two options: remap with nav2 or remap with diff_drive_controller. From this Issue, it may not be possible to remap with diff_drive_controller.

Therefore, I think it is better to use nav2 to remap /cmd_vel to /diff_drive_controller/cmd_vel.

For more information about how to remap, please refer to the following.

https://docs.ros.org/en/foxy/Tutorial...

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2021-10-18 14:00:41 -0500

Seen: 114 times

Last updated: Oct 21 '21