Skip to content

Commit

Permalink
color_objects.launch.pyからemptyworld.launch.pyを実行するように変更
Browse files Browse the repository at this point in the history
  • Loading branch information
YusukeKato committed Oct 24, 2023
1 parent 77dee4d commit 0942e30
Showing 1 changed file with 13 additions and 111 deletions.
124 changes: 13 additions & 111 deletions raspimouse_gazebo/launch/raspimouse_with_color_objects.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,125 +22,27 @@
import os

from ament_index_python.packages import get_package_share_directory
from raspimouse_description.robot_description_loader import RobotDescriptionLoader
from launch import LaunchDescription
from launch.actions import ExecuteProcess
from launch.actions import DeclareLaunchArgument
from launch.actions import IncludeLaunchDescription
from launch_ros.actions import SetParameter
from launch_ros.actions import Node
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import ComposableNodeContainer
from launch_ros.descriptions import ComposableNode
from launch.launch_description_sources import PythonLaunchDescriptionSource


def generate_launch_description():
declare_arg_lidar = DeclareLaunchArgument(
'lidar',
default_value='none',
description='Set "none", "urg", "lds", or "rplidar".')
declare_arg_lidar_frame = DeclareLaunchArgument(
'lidar_frame',
default_value='laser',
description='Set lidar link name.')
declare_arg_use_rgb_camera = DeclareLaunchArgument(
'use_rgb_camera',
default_value='false',
description='Set "true" to mount rgb camera.')

env = {'IGN_GAZEBO_SYSTEM_PLUGIN_PATH': os.environ['LD_LIBRARY_PATH'],
'IGN_GAZEBO_RESOURCE_PATH': os.path.dirname(
get_package_share_directory('raspimouse_description')) + ':' +
os.path.join(get_package_share_directory('raspimouse_gazebo'), 'models'),
}
world_file = os.path.join(
get_package_share_directory('raspimouse_gazebo'), 'worlds', 'color_objects_world.sdf')
gui_config = os.path.join(
get_package_share_directory('raspimouse_gazebo'), 'gui', 'gui.config')
ign_gazebo = ExecuteProcess(
cmd=['ign gazebo -r', world_file, '--gui-config', gui_config],
output='screen',
additional_env=env,
shell=True
)

ignition_spawn_entity = Node(
package='ros_gz_sim',
executable='create',
output='screen',
arguments=['-topic', '/robot_description',
'-name', 'raspimouse',
'-allow_renaming', 'true'],
)

description_loader = RobotDescriptionLoader()
description_loader.lidar = LaunchConfiguration('lidar')
description_loader.lidar_frame = LaunchConfiguration('lidar_frame')
description_loader.use_gazebo = 'true'
description_loader.use_rgb_camera = LaunchConfiguration('use_rgb_camera')
description_loader.gz_control_config_package = 'raspimouse_gazebo'
description_loader.gz_control_config_file_path = 'config/raspimouse_controllers.yaml'

robot_state_publisher = Node(
package='robot_state_publisher',
executable='robot_state_publisher',
output='screen',
parameters=[{'robot_description': description_loader.load()}]
)

spawn_joint_state_broadcaster = ExecuteProcess(
cmd=['ros2 run controller_manager spawner joint_state_broadcaster'],
shell=True,
output='screen',
)

spawn_diff_drive_controller = ExecuteProcess(
cmd=['ros2 run controller_manager spawner diff_drive_controller'],
shell=True,
output='screen',
)

rviz_config_file = get_package_share_directory(
'raspimouse_gazebo') + '/config/config.rviz'
rviz = Node(
package="rviz2",
executable="rviz2",
name="rviz2",
output="screen",
arguments=["-d", rviz_config_file],
)

bridge = Node(
package='ros_gz_bridge',
executable='parameter_bridge',
arguments=['/clock@rosgraph_msgs/msg/Clock[ignition.msgs.Clock'],
output='screen'
)

container = ComposableNodeContainer(
name='fake_raspimouse_container',
namespace='',
package='rclcpp_components',
executable='component_container_mt',
composable_node_descriptions=[
ComposableNode(
package='raspimouse_fake',
plugin='fake_raspimouse::Raspimouse',
name='raspimouse'),
],
output='screen',
get_package_share_directory('raspimouse_gazebo'),
'worlds',
'color_objects_world.sdf')
world_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource([
get_package_share_directory('raspimouse_gazebo'),
'/launch/raspimouse_with_emptyworld.launch.py']),
launch_arguments={
'world_name': world_file
}.items()
)

return LaunchDescription([
SetParameter(name='use_sim_time', value=True),
declare_arg_lidar,
declare_arg_lidar_frame,
declare_arg_use_rgb_camera,
ign_gazebo,
ignition_spawn_entity,
robot_state_publisher,
spawn_joint_state_broadcaster,
spawn_diff_drive_controller,
rviz,
bridge,
container
world_launch
])

0 comments on commit 0942e30

Please sign in to comment.