2023-04-12 07:04:55 +00:00
|
|
|
import os
|
|
|
|
|
|
|
|
from ament_index_python.packages import get_package_share_directory
|
|
|
|
|
|
|
|
from launch import LaunchDescription
|
2023-07-28 10:02:25 +00:00
|
|
|
from launch.substitutions import LaunchConfiguration, Command, FindExecutable, PathJoinSubstitution
|
2023-04-12 07:04:55 +00:00
|
|
|
from launch.actions import DeclareLaunchArgument
|
|
|
|
from launch_ros.actions import Node
|
|
|
|
|
|
|
|
import xacro
|
|
|
|
|
2023-08-03 08:20:50 +00:00
|
|
|
namespace = "/rmp"
|
2023-04-12 07:04:55 +00:00
|
|
|
def generate_launch_description():
|
|
|
|
|
|
|
|
# Check if we're told to use sim time
|
|
|
|
use_sim_time = LaunchConfiguration('use_sim_time')
|
2023-04-12 08:11:46 +00:00
|
|
|
use_ros2_control = LaunchConfiguration('use_ros2_control')
|
2023-04-12 07:04:55 +00:00
|
|
|
|
|
|
|
# Process the URDF file
|
2023-04-12 08:11:46 +00:00
|
|
|
pkg_path = os.path.join(get_package_share_directory('cps_rmp220_support'))
|
2023-04-12 07:04:55 +00:00
|
|
|
xacro_file = os.path.join(pkg_path,'description','robot.urdf.xacro')
|
2023-04-12 08:11:46 +00:00
|
|
|
robot_description_config = Command(['xacro ', xacro_file, ' use_ros2_control:=', use_ros2_control, ' sim_mode:=', use_sim_time])
|
2023-04-12 07:04:55 +00:00
|
|
|
|
|
|
|
# Create a robot_state_publisher node
|
2023-04-12 08:11:46 +00:00
|
|
|
params = {'robot_description': robot_description_config, 'use_sim_time': use_sim_time}
|
2023-04-12 07:04:55 +00:00
|
|
|
node_robot_state_publisher = Node(
|
|
|
|
package='robot_state_publisher',
|
|
|
|
executable='robot_state_publisher',
|
|
|
|
output='screen',
|
2023-08-03 08:20:50 +00:00
|
|
|
parameters=[params],
|
2023-08-08 09:01:49 +00:00
|
|
|
#namespace=namespace
|
2023-04-12 07:04:55 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# Launch!
|
|
|
|
return LaunchDescription([
|
|
|
|
DeclareLaunchArgument(
|
|
|
|
'use_sim_time',
|
|
|
|
default_value='false',
|
|
|
|
description='Use sim time if true'),
|
2023-04-12 08:11:46 +00:00
|
|
|
DeclareLaunchArgument(
|
|
|
|
'use_ros2_control',
|
|
|
|
default_value='true',
|
|
|
|
description='Use ros2_control if true'),
|
2023-04-12 07:04:55 +00:00
|
|
|
|
|
|
|
node_robot_state_publisher
|
|
|
|
])
|