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

implement ros2 control for a 4 wheel differential drive robot

asked 2023-07-22 02:04:29 -0500

KalaDaku gravatar image

Hello. I am trying to implement ros2 control (controller manager(YAML) and resource manager(URDF)) for controlling a 4 wheel robot. I have been following this video https://youtu.be/4QKsDf1c4hc but the problem is this video is for a 2 wheel robot and i want the same for a 4 wheel robot. I made the changes that if felt like but it dose'nt seems to work. The robot isnt moving at all. To keep things simple i am only using the frromnt 2 wheels and have set the friction of others 2 wheels near to zero.

Version: ROS2 Foxy

NOET: The formatting of this question is not good as i don't use answers.ros.org much.

Here is the Terminal window. It says "No Parameter file provided. Configuration might be wrong.".

The ".yaml" file:

controller_manager: ros_parameters: update_rate: 30 use_sim_time: true

  diff_cont:
    type: diff_drive_controller/DiffDriveController

  joint_broad:
    type: joint_state_broadcaster/JointStateBroadcaster

diff_cont: ros__parameters:

publish_rate: 50.0

base_frame_id: base_link

left_wheel_names: ['left_front_wheel_joint']
right_wheel_names: ['right_front_wheel_joint']
wheel_separation: 0.36
wheel_radius: 0.1

use_stamped_vel: false

# open_loop: false    

# wheels_per_side: x
# wheel_separation_multiplier: x
# left_wheel_radius_multiplier: x
# right_wheel_radius_multiplier: x

# odom_frame_id: x
# pose_covariance_diagonal: x
# twist_covariance_diagonal: x
# open_loop: x
# enable_odom_tf: x

# cmd_vel_timeout: x
# publish_limited_velocity: x
# velocity_rolling_window_size: x


# linear.x.has_velocity_limits: false
# linear.x.has_acceleration_limits:

false # linear.x.has_jerk_limits: false # linear.x.max_velocity: NAN # linear.x.min_velocity: NAN # linear.x.max_acceleration: NAN # linear.x.min_acceleration: NAN # linear.x.max_jerk: NAN # linear.x.min_jerk: NAN

# angular.z.has_velocity_limits: false
# angular.z.has_acceleration_limits:

false # angular.z.has_jerk_limits: false # angular.z.max_velocity: NAN # angular.z.min_velocity: NAN # angular.z.max_acceleration: NAN # angular.z.min_acceleration: NAN # angular.z.max_jerk: NAN # angular.z.min_jerk: NAN

joint_broad:

ros__parameters:

The Launch File:

import os

from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription from launch.actions import IncludeLaunchDescription from launch.launch_description_sources import PythonLaunchDescriptionSource

from launch_ros.actions import Node

def generate_launch_description():

# Include the robot_state_publisher launch file, provided by our own package. Force sim time to be enabled
# !!! MAKE SURE YOU SET THE PACKAGE NAME CORRECTLY !!!

package_name='my_bot' #<--- CHANGE ME

rsp = IncludeLaunchDescription(
            PythonLaunchDescriptionSource([os.path.join(
                get_package_share_directory(package_name),'launch','rsp.launch.py'
            )]), launch_arguments={'use_sim_time': 'true'}.items()
)

# Include the Gazebo launch file, provided by the gazebo_ros package
gazebo = IncludeLaunchDescription(
            PythonLaunchDescriptionSource([os.path.join(
                get_package_share_directory('gazebo_ros'), 'launch', 'gazebo.launch.py')]),
         )

# Run the spawner node from the gazebo_ros package. The entity name doesn't really matter if you only have a single robot.
spawn_entity = Node(package='gazebo_ros', executable='spawn_entity.py',
                    arguments=['-topic', 'robot_description',
                               '-entity', 'my_bot'],
                    output='screen')



# Launch them all!
return LaunchDescription([
    rsp,
    gazebo,
    spawn_entity,
])

The urdf file:

<robot <a="" href="http://xmlns:xacro="http://www.ros.org/wiki/xacro">xmlns:xacro="http://www.ros.org/wiki/..." ><="" p=""> </robot>

<xacro:include filename="inertial_macros.xacro"/>

<material name="white">
    <color rgba="1 1 1 1" />
</material>

<material name="orange">
    <color rgba="1 0.3 0.1 1" />
</material>

<material name="blue">
    <color rgba="0.2 0.2 1 1" />
</material>

<material name="black">
    <color rgba="0 0 0 1" />
< ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-07-24 03:52:58 -0500

MSanMon gravatar image

The gazebo_ros_diff_drive plugin in the gazebo_ros_pkgs for ros2 allows you to control a robot with as many wheels as you want per side. Here is an example for a 8 wheeled vehicle:

 <gazebo>
    <plugin name='diff_drive' filename='libgazebo_ros_diff_drive_mod.so'>

    <ros>
      <namespace>/ARGJ801</namespace>
      <!--<remapping>cmd_vel:=cmd_demo</remapping>-->
      <remapping>odom:=odom_demo</remapping>
    </ros>

    <!-- wheels -->
    <num_wheel_pairs>4</num_wheel_pairs>
    <left_joint>jo_w1</left_joint>
    <left_joint>jo_w2</left_joint>
    <left_joint>jo_w3</left_joint>
    <left_joint>jo_w4</left_joint>

    <right_joint>jo_w5</right_joint>
    <right_joint>jo_w6</right_joint>
    <right_joint>jo_w7</right_joint>
    <right_joint>jo_w8</right_joint>
    <!-- kinematics -->
    <wheel_separation>1.35</wheel_separation>
    <wheel_diameter>0.64</wheel_diameter>

    <!-- limits -->
    <max_wheel_torque>500</max_wheel_torque>
    <max_wheel_acceleration>2.0</max_wheel_acceleration>

    <!-- output -->
    <publish_odom>true</publish_odom>
    <publish_odom_tf>false</publish_odom_tf>
    <publish_wheel_tf>false</publish_wheel_tf>

    <odometry_frame>odom</odometry_frame>
    <robot_base_frame>base_link</robot_base_frame>

  </plugin>
    </gazebo>
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2023-07-22 02:04:29 -0500

Seen: 1,503 times

Last updated: Jul 24 '23