Hi @girishkumar.kannan
Thanks for your response.
I tried to do export GZ_VERSION=garden, but it still gives the same error. I also tried with another plugin name:
plugin name=‘diff_drive’ filename=‘libgazebo_ros_diff_drive.so’
but this did also not work.
Here the launch files:
empty_world
import os
from ament_index_python.packages import (get_package_prefix, get_package_share_directory)
from launch import LaunchDescription
from launch.actions import (DeclareLaunchArgument, IncludeLaunchDescription)
from launch.substitutions import (PathJoinSubstitution, LaunchConfiguration)
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch_ros.actions import SetParameter
# ROS2 Launch System will look for this function definition #
def generate_launch_description():
# Get Package Description and Directory #
package_description = "robot_description"
package_directory = get_package_share_directory(package_description)
# Set the Path to Robot Mesh Models for Loading in Gazebo Sim #
# NOTE: Do this BEFORE launching Gazebo Sim #
install_dir_path = (get_package_prefix(package_description) + "/share")
robot_meshes_path = os.path.join(package_directory, "meshes")
gazebo_resource_paths = [install_dir_path, robot_meshes_path]
if "IGN_GAZEBO_RESOURCE_PATH" in os.environ:
for resource_path in gazebo_resource_paths:
if resource_path not in os.environ["IGN_GAZEBO_RESOURCE_PATH"]:
os.environ["IGN_GAZEBO_RESOURCE_PATH"] += (':' + resource_path)
else:
os.environ["IGN_GAZEBO_RESOURCE_PATH"] = (':'.join(gazebo_resource_paths))
# Load Empty World SDF from Gazebo Sim Package #
world_file = "empty.sdf"
world_config = LaunchConfiguration("world")
declare_world_arg = DeclareLaunchArgument("world",
default_value=["-r ", world_file],
description="SDF World File")
# Declare GazeboSim Launch #
gzsim_pkg = get_package_share_directory("ros_gz_sim")
gz_sim = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
PathJoinSubstitution([gzsim_pkg, "launch", "gz_sim.launch.py"])),
launch_arguments={"gz_args": world_config}.items(),
)
# Create and Return the Launch Description Object #
return LaunchDescription(
[
declare_world_arg,
# Sets use_sim_time for all nodes started below (doesn't work for nodes started from ignition gazebo) #
SetParameter(name="use_sim_time", value=True),
gz_sim,
]
)
and spawn_robot
import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import (Command, LaunchConfiguration)
from launch_ros.actions import (Node, SetParameter)
# ROS2 Launch System will look for this function definition #
def generate_launch_description():
# Get Package Description and Directory #
package_description = "robot_description"
package_directory = get_package_share_directory(package_description)
# Load URDF File #
urdf_file = 'robot.urdf'
robot_desc_path = os.path.join(package_directory, "urdf", urdf_file)
print("URDF Loaded !")
# Robot State Publisher (RSP) #
robot_state_publisher_node = Node(
package='robot_state_publisher',
executable='robot_state_publisher',
name='robot_state_publisher_node',
output="screen",
emulate_tty=True,
parameters=[{'use_sim_time': True,
'robot_description': Command(['xacro ', robot_desc_path])}]
)
# Spawn the Robot #
declare_spawn_model_name = DeclareLaunchArgument("model_name", default_value="my_robot",
description="Model Spawn Name")
declare_spawn_x = DeclareLaunchArgument("x", default_value="0.0",
description="Model Spawn X Axis Value")
declare_spawn_y = DeclareLaunchArgument("y", default_value="0.0",
description="Model Spawn Y Axis Value")
declare_spawn_z = DeclareLaunchArgument("z", default_value="0.5",
description="Model Spawn Z Axis Value")
gz_spawn_entity = Node(
package="ros_gz_sim",
executable="create",
name="my_robot_spawn",
arguments=[
"-name", LaunchConfiguration("model_name"),
"-allow_renaming", "true",
"-topic", "robot_description",
"-x", LaunchConfiguration("x"),
"-y", LaunchConfiguration("y"),
"-z", LaunchConfiguration("z"),
],
output="screen",
)
# Create and Return the Launch Description Object #
return LaunchDescription(
[
# Sets use_sim_time for all nodes started below (doesn't work for nodes started from ignition gazebo) #
SetParameter(name="use_sim_time", value=True),
robot_state_publisher_node,
declare_spawn_model_name,
declare_spawn_x,
declare_spawn_y,
declare_spawn_z,
gz_spawn_entity,
]
)