Skip to content

Commit

Permalink
rviz_configの切替えの仕方を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
mizonon committed Dec 12, 2024
1 parent cad9fff commit 3fcac14
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 49 deletions.
56 changes: 28 additions & 28 deletions crane_plus_examples/launch/demo.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand All @@ -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
])
23 changes: 2 additions & 21 deletions crane_plus_moveit_config/launch/run_move_group.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -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
Expand Down

0 comments on commit 3fcac14

Please sign in to comment.