Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PathJoinSubstitution #2

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@ The result is that you can perform the above actions with just 5 lines (not incl
```python
from launch import LaunchDescription
from launch.actions import IncludeLaunchDescription
from launch.substitutions import PathJoinSubstitution
from launch_ros.substitutions import FindPackageShare


def generate_launch_description():
ld = LaunchDescription()

ld.add_action(IncludeLaunchDescription(
[FindPackageShare('urdf_launch'), '/launch/description.launch.py'],
PathJoinSubstitution([FindPackageShare('urdf_launch'), 'launch', 'display.launch.py']),
launch_arguments={
'urdf_package': 'turtlebot3_description',
'urdf_package_path': 'urdf/turtlebot3_burger.urdf'}.items()
'urdf_package_path': PathJoinSubstitution(['urdf', 'turtlebot3_burger.urdf'])}.items()
))

return ld
Expand Down
8 changes: 3 additions & 5 deletions launch/description.launch.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import Command
from launch.substitutions import LaunchConfiguration
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution


from launch_ros.actions import Node
Expand All @@ -17,11 +17,9 @@ def generate_launch_description():
description='The path to the robot description relative to the package root'))

package_dir = FindPackageShare(LaunchConfiguration('urdf_package'))
urdf_path = PathJoinSubstitution([package_dir, LaunchConfiguration('urdf_package_path')])

robot_description_content = ParameterValue(
Command(['xacro ', package_dir, '/', LaunchConfiguration('urdf_package_path')]),
value_type=str,
)
robot_description_content = ParameterValue(Command(['xacro ', urdf_path]), value_type=str)

robot_state_publisher_node = Node(package='robot_state_publisher',
executable='robot_state_publisher',
Expand Down
6 changes: 3 additions & 3 deletions launch/display.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from launch.actions import DeclareLaunchArgument
from launch.actions import IncludeLaunchDescription
from launch.conditions import IfCondition, UnlessCondition
from launch.substitutions import LaunchConfiguration
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution

from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare
Expand All @@ -16,13 +16,13 @@ def generate_launch_description():
ld.add_action(DeclareLaunchArgument(name='jsp_gui', default_value='true', choices=['true', 'false'],
description='Flag to enable joint_state_publisher_gui'))

default_rviz_config_path = [urdf_launch_package, '/config/urdf.rviz']
default_rviz_config_path = PathJoinSubstitution([urdf_launch_package, 'config', 'urdf.rviz'])
ld.add_action(DeclareLaunchArgument(name='rviz_config', default_value=default_rviz_config_path,
description='Absolute path to rviz config file'))

# need to manually pass configuration in because of https://github.com/ros2/launch/issues/313
ld.add_action(IncludeLaunchDescription(
[urdf_launch_package, '/launch/description.launch.py'],
PathJoinSubstitution([urdf_launch_package, 'launch', 'description.launch.py']),
launch_arguments={
'urdf_package': LaunchConfiguration('urdf_package'),
'urdf_package_path': LaunchConfiguration('urdf_package_path')}.items()
Expand Down