Skip to content

Commit

Permalink
Fix Panda demo launch for MoveIt 2 tutorials (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
sea-bass committed Oct 24, 2023
1 parent 93aa055 commit 3d6a737
Show file tree
Hide file tree
Showing 3 changed files with 253 additions and 63 deletions.
45 changes: 16 additions & 29 deletions panda_moveit_config/launch/demo.launch.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import os
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from launch.conditions import IfCondition, UnlessCondition
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
from launch.conditions import IfCondition
from launch_ros.actions import Node
from launch.actions import ExecuteProcess
from launch_ros.substitutions import FindPackageShare
from ament_index_python.packages import get_package_share_directory
from moveit_configs_utils import MoveItConfigsBuilder


def generate_launch_description():

# Command-line arguments
tutorial_arg = DeclareLaunchArgument(
"rviz_tutorial", default_value="False", description="Tutorial flag"
rviz_config_arg = DeclareLaunchArgument(
"rviz_config",
default_value="moveit.rviz",
description="RViz configuration file",
)

db_arg = DeclareLaunchArgument(
Expand All @@ -23,7 +25,7 @@ def generate_launch_description():
ros2_control_hardware_type = DeclareLaunchArgument(
"ros2_control_hardware_type",
default_value="mock_components",
description="ROS2 control hardware interface type to use for the launch file -- possible values: [mock_components, isaac]",
description="ROS 2 control hardware interface type to use for the launch file -- possible values: [mock_components, isaac]",
)

moveit_config = (
Expand All @@ -37,6 +39,9 @@ def generate_launch_description():
},
)
.robot_description_semantic(file_path="config/panda.srdf")
.planning_scene_monitor(
publish_robot_description=True, publish_robot_description_semantic=True
)
.trajectory_execution(file_path="config/gripper_moveit_controllers.yaml")
.planning_pipelines(
pipelines=["ompl", "chomp", "pilz_industrial_motion_planner", "stomp"]
Expand All @@ -54,40 +59,23 @@ def generate_launch_description():
)

# RViz
tutorial_mode = LaunchConfiguration("rviz_tutorial")
rviz_base = os.path.join(
get_package_share_directory("moveit_resources_panda_moveit_config"), "launch"
)
rviz_full_config = os.path.join(rviz_base, "moveit.rviz")
rviz_empty_config = os.path.join(rviz_base, "moveit_empty.rviz")
rviz_node_tutorial = Node(
package="rviz2",
executable="rviz2",
name="rviz2",
output="log",
arguments=["-d", rviz_empty_config],
parameters=[
moveit_config.robot_description,
moveit_config.robot_description_semantic,
moveit_config.planning_pipelines,
moveit_config.robot_description_kinematics,
],
condition=IfCondition(tutorial_mode),
rviz_base = LaunchConfiguration("rviz_config")
rviz_config = PathJoinSubstitution(
[FindPackageShare("moveit_resources_panda_moveit_config"), "launch", rviz_base]
)
rviz_node = Node(
package="rviz2",
executable="rviz2",
name="rviz2",
output="log",
arguments=["-d", rviz_full_config],
arguments=["-d", rviz_config],
parameters=[
moveit_config.robot_description,
moveit_config.robot_description_semantic,
moveit_config.planning_pipelines,
moveit_config.robot_description_kinematics,
moveit_config.joint_limits,
],
condition=UnlessCondition(tutorial_mode),
)

# Static TF
Expand Down Expand Up @@ -159,11 +147,10 @@ def generate_launch_description():

return LaunchDescription(
[
tutorial_arg,
rviz_config_arg,
db_arg,
ros2_control_hardware_type,
rviz_node,
rviz_node_tutorial,
static_tf_node,
robot_state_publisher,
move_group_node,
Expand Down
Loading

0 comments on commit 3d6a737

Please sign in to comment.