diff --git a/crane_plus_examples/launch/demo.launch.py b/crane_plus_examples/launch/demo.launch.py index b09565a..1099c8b 100644 --- a/crane_plus_examples/launch/demo.launch.py +++ b/crane_plus_examples/launch/demo.launch.py @@ -43,39 +43,38 @@ def generate_launch_description(): description='Set video device.' ) + declare_rviz_config = DeclareLaunchArgument( + 'rviz_config', + default_value=get_package_share_directory( + 'crane_plus_moveit_config' + ) + '/config/moveit.rviz', + description='Set the path to rviz configuration file.', + condition=UnlessCondition(LaunchConfiguration('use_camera')), + ) + + declare_rviz_config_camera = DeclareLaunchArgument( + 'rviz_config', + default_value=get_package_share_directory( + 'crane_plus_examples' + ) + '/launch/camera_example.rviz', + description='Set the path to rviz configuration file.', + condition=IfCondition(LaunchConfiguration('use_camera')), + ) + description_loader = RobotDescriptionLoader() description_loader.port_name = LaunchConfiguration('port_name') description_loader.use_camera = LaunchConfiguration('use_camera') description = description_loader.load() - rviz_config_moveit = get_package_share_directory( - 'crane_plus_moveit_config' - ) + '/config/moveit.rviz' - rviz_config_camera = get_package_share_directory( - 'crane_plus_examples' - ) + '/launch/camera_example.rviz' - move_group = IncludeLaunchDescription( - PythonLaunchDescriptionSource([ - get_package_share_directory('crane_plus_moveit_config'), - '/launch/run_move_group.launch.py']), - condition=UnlessCondition(LaunchConfiguration('use_camera')), - launch_arguments={ - 'loaded_description': description, - 'rviz_config': rviz_config_moveit - }.items() - ) - - move_group_camera = IncludeLaunchDescription( - PythonLaunchDescriptionSource([ - get_package_share_directory('crane_plus_moveit_config'), - '/launch/run_move_group.launch.py']), - condition=IfCondition(LaunchConfiguration('use_camera')), - launch_arguments={ - 'loaded_description': description, - 'rviz_config': rviz_config_camera - }.items() - ) + PythonLaunchDescriptionSource([ + get_package_share_directory('crane_plus_moveit_config'), + '/launch/run_move_group.launch.py']), + launch_arguments={ + 'loaded_description': description, + 'rviz_config': LaunchConfiguration('rviz_config') + }.items() + ) control_node = IncludeLaunchDescription( PythonLaunchDescriptionSource([ @@ -102,8 +101,9 @@ def generate_launch_description(): declare_port_name, declare_use_camera, declare_video_device, + declare_rviz_config, + declare_rviz_config_camera, move_group, - move_group_camera, control_node, usb_cam_node ]) diff --git a/crane_plus_moveit_config/launch/run_move_group.launch.py b/crane_plus_moveit_config/launch/run_move_group.launch.py index 99fdc90..82fb40d 100755 --- a/crane_plus_moveit_config/launch/run_move_group.launch.py +++ b/crane_plus_moveit_config/launch/run_move_group.launch.py @@ -12,13 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ament_index_python.packages import get_package_share_directory + +# from ament_index_python.packages import get_package_share_directory from crane_plus_description.robot_description_loader \ import RobotDescriptionLoader from launch import LaunchDescription from launch.actions import DeclareLaunchArgument from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node from moveit_configs_utils import MoveItConfigsBuilder from moveit_configs_utils.launches import generate_move_group_launch from moveit_configs_utils.launches import generate_moveit_rviz_launch @@ -42,19 +42,6 @@ def generate_launch_description(): ) ) - ld.add_action( - DeclareLaunchArgument( - 'rviz_config', - default_value=get_package_share_directory( - 'crane_plus_moveit_config' - ) - + '/config/moveit.rviz', - description='Set the path to rviz configuration file.', - ) - ) - - rviz_config = LaunchConfiguration('rviz_config') - moveit_config = ( MoveItConfigsBuilder('crane_plus') .planning_scene_monitor( @@ -77,12 +64,6 @@ def generate_launch_description(): ld.add_entity(generate_move_group_launch(moveit_config)) # RViz - rviz_entities = generate_moveit_rviz_launch(moveit_config).entities - for entity in rviz_entities: - if isinstance(entity, Node): - entity.cmd.extend(['--ros-args', '--params-file', rviz_config]) - ld.add_entity(entity) - ld.add_entity(generate_moveit_rviz_launch(moveit_config)) # Static TF