76 lines
2.5 KiB
Python
76 lines
2.5 KiB
Python
from launch import LaunchDescription
|
|
from launch.actions import DeclareLaunchArgument
|
|
from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution
|
|
from launch_ros.actions import Node
|
|
from launch_ros.substitutions import FindPackageShare
|
|
|
|
|
|
def generate_launch_description():
|
|
declared_arguments = []
|
|
# General arguments
|
|
declared_arguments.append(
|
|
DeclareLaunchArgument(
|
|
"description_package",
|
|
default_value="rbs_gripper",
|
|
description="Description package with robot URDF/XACRO files. Usually the argument \
|
|
is not set, it enables use of a custom description.",
|
|
)
|
|
)
|
|
declared_arguments.append(
|
|
DeclareLaunchArgument(
|
|
"description_file",
|
|
default_value="rbs_gripper.xacro",
|
|
description="URDF/XACRO description file with the robot.",
|
|
)
|
|
)
|
|
declared_arguments.append(
|
|
DeclareLaunchArgument(
|
|
"prefix",
|
|
default_value='""',
|
|
description="Prefix of the joint names, useful for \
|
|
multi-robot setup. If changed than also joint names in the controllers' configuration \
|
|
have to be updated.",
|
|
)
|
|
)
|
|
|
|
description_package = LaunchConfiguration("description_package")
|
|
description_file = LaunchConfiguration("description_file")
|
|
|
|
robot_description_content = Command(
|
|
[
|
|
PathJoinSubstitution([FindExecutable(name="xacro")]),
|
|
" ",
|
|
PathJoinSubstitution([FindPackageShare(description_package), "urdf", description_file]),
|
|
]
|
|
)
|
|
robot_description = {"robot_description": robot_description_content}
|
|
|
|
rviz_config_file = PathJoinSubstitution(
|
|
[FindPackageShare(description_package), "config", "view_robot.rviz"]
|
|
)
|
|
|
|
joint_state_publisher_node = Node(
|
|
package="joint_state_publisher_gui",
|
|
executable="joint_state_publisher_gui",
|
|
)
|
|
robot_state_publisher_node = Node(
|
|
package="robot_state_publisher",
|
|
executable="robot_state_publisher",
|
|
output="both",
|
|
parameters=[robot_description],
|
|
)
|
|
rviz_node = Node(
|
|
package="rviz2",
|
|
executable="rviz2",
|
|
name="rviz2",
|
|
output="log",
|
|
arguments=["-d", rviz_config_file],
|
|
)
|
|
|
|
nodes_to_start = [
|
|
joint_state_publisher_node,
|
|
robot_state_publisher_node,
|
|
rviz_node,
|
|
]
|
|
|
|
return LaunchDescription(declared_arguments + nodes_to_start)
|