a plugin for individual wheel on a 4 wheel robot in gazebo? Ros2 (foxy)
Hi everyone,
I have a question. So, is there any single plugin that works with individual wheel on robot with 4 wheels?
I'm using Gazebo11 and Foxy (ros2).
As I'm aware that libgazebo_ros_diff_drive controls 2 wheels and libgazebo_ros_ackermann_drive controls 4 wheels. I wanted to have a plugin where I'm able to control a single wheel or run with all wheels individual. Do you know the name of the plugin? Any tutorial too?
Thank you so much for your time!
Update 2
Here is my current launch file:
#!/usr/bin/env python3
from launch.substitutions import Command, LaunchConfiguration
from ament_index_python.packages import get_package_share_directory
from launch.substitutions import Command, FindExecutable, PathJoinSubstitution
from launch_ros.substitutions import FindPackageShare
from launch import LaunchDescription
from launch_ros.actions import Node
from launch import LaunchDescription, LaunchContext
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution
from launch.conditions import IfCondition, UnlessCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
import launch_ros
import os
import sys
import launch_ros.actions
import xacro
import launch
def generate_launch_description():
pkg_path = FindPackageShare("my_robot_description")
use_sim = LaunchConfiguration("use_sim")
use_fake_hardware = LaunchConfiguration("use_fake_hardware")
fake_sensor_commands = LaunchConfiguration("fake_sensor_commands")
xacro_path = PathJoinSubstitution([pkg_path, "urdf", "my_robot.urdf"])
assert os.path.exists(xacro_path.perform(LaunchContext())), (
"The xacro file doesn't exist (" + str(xacro_path.perform(LaunchContext())) + ")"
)
robot_description_content = Command(
[
PathJoinSubstitution([FindExecutable(name="xacro")]),
" ",
PathJoinSubstitution(
[
PathJoinSubstitution([FindExecutable(name="xacro")]),
" ",
xacro_path,
" ",
"use_sim:=",
use_sim,
" ",
"use_fake_hardware:=",
use_fake_hardware,
" ",
"fake_sensor_commands:=",
fake_sensor_commands,
FindPackageShare("my_robot_description"),
"src/description",
"my_robot.urdf",
]
),
]
)
robot_description = {"robot_description": robot_description_content}
controller_config_path = PathJoinSubstitution(
[
pkg_path,
"config",
"gazebo_ros_control_params.yaml",
]
)
assert os.path.exists(controller_config_path.perform(LaunchContext())), (
"The controller config doesn't exist ("
+ str(controller_config_path.perform(LaunchContext()))
+ ")"
)
robot_description = {"robot_description": robot_description_content}
rviz_config_file = PathJoinSubstitution(
[FindPackageShare("my_robot_description"), "rviz", "urdf_config.rviz"]
)
rviz_node = Node(
package="rviz2",
executable="rviz2",
name="rviz2",
output="log",
arguments=["-d", rviz_config_file],
)
robot_state_pub_node = Node(
package="robot_state_publisher",
executable="robot_state_publisher",
output="both",
parameters=[robot_description],
)
spawn_entity = launch_ros.actions.Node(
package='gazebo_ros',
executable='spawn_entity.py',
arguments=['-entity', 'my_robot', '-topic', 'robot_description'],
output='screen'
)
return launch.LaunchDescription([
#
# Launch Arguments
#
DeclareLaunchArgument(
"use_sim",
default_value="false",
description="Use simulation (Gazebo) clock if true",
),
DeclareLaunchArgument(
"use_fake_hardware",
default_value="true",
description="Start robot with fake hardware mirroring command to its states.",
),
DeclareLaunchArgument(
"fake_sensor_commands",
default_value="false",
description="Enable fake command interfaces for sensors used for simple simulations. \
Used only if 'use_fake_hardware' parameter is true.",
),
Node(
package="controller_manager",
executable="ros2_control_node",
parameters=[robot_description, controller_config_path],
output={
"stdout": "screen",
"stderr": "screen",
},
condition=UnlessCondition(use_sim),
),
Node(
package="robot_state_publisher",
executable="robot_state_publisher",
output="both",
parameters=[robot_description, {"use_sim_time": use_sim}],
),
Node(
package="controller_manager",
executable="spawner.py",
arguments=[
"joint_state_broadcaster",
"--controller-manager",
"/controller_manager",
],
),
Node(
package="controller_manager",
executable="spawner.py",
arguments=["wheel_velocity_controller", "-c", "/controller_manager"],
),
launch.actions.ExecuteProcess(cmd=['gazebo', '--verbose', '-s', 'libgazebo_ros_factory.so'], output='screen'),
launch.actions.ExecuteProcess(
name='fake_joint_calibration',
cmd=['ros2', 'topic', 'pub', '/joint_states', 'sensor_msgs/msg/JointState', '"{data True}"'],
output='screen',
shell='True'
),
robot_state_pub_node,
rviz_node,
spawn_entity,
])