diff --git a/.github/workflows/check-samples.yml b/.github/workflows/check-samples.yml index 0a54ffb..4c826d1 100644 --- a/.github/workflows/check-samples.yml +++ b/.github/workflows/check-samples.yml @@ -105,7 +105,7 @@ jobs: git config --global user.email "dummy@dummy.com" - name: Generate packages run: | - copier copy --trust --defaults \ + copier copy --trust --defaults --overwrite --vcs-ref=HEAD \ -d template=${{ matrix.template }} \ -d package_name=${{ matrix.package_name }} \ -d node_name=${{ matrix.node_name }} \ diff --git a/ros2-pkg-create/pyproject.toml b/ros2-pkg-create/pyproject.toml index aa36bf5..b943a7d 100644 --- a/ros2-pkg-create/pyproject.toml +++ b/ros2-pkg-create/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "ros2-pkg-create" -version = "1.0.2" +version = "1.1.0" description = "Powerful ROS 2 Package Generator" license = {file = "LICENSE"} readme = "README.md" diff --git a/ros2-pkg-create/src/ros2_pkg_create/__init__.py b/ros2-pkg-create/src/ros2_pkg_create/__init__.py index 26153c4..40f31e0 100644 --- a/ros2-pkg-create/src/ros2_pkg_create/__init__.py +++ b/ros2-pkg-create/src/ros2_pkg_create/__init__.py @@ -1,2 +1,2 @@ __name__ = "ros2-pkg-create" -__version__ = "1.0.2" \ No newline at end of file +__version__ = "1.1.0" \ No newline at end of file diff --git a/samples/generate_samples.sh b/samples/generate_samples.sh index a000239..830b766 100755 --- a/samples/generate_samples.sh +++ b/samples/generate_samples.sh @@ -1,8 +1,9 @@ #!/bin/bash script_dir=$(dirname $0) +template_dir="$script_dir/.." -copier copy --trust --defaults \ +copier copy --trust --defaults --overwrite --vcs-ref=HEAD \ -d template=ros2_cpp_pkg \ -d package_name=ros2_cpp_pkg \ -d node_name=ros2_cpp_node \ @@ -16,9 +17,9 @@ copier copy --trust --defaults \ -d has_action_server=false \ -d has_timer=false \ -d has_docker_ros=true \ - . $script_dir + $template_dir $script_dir -copier copy --trust --defaults \ +copier copy --trust --defaults --overwrite --vcs-ref=HEAD \ -d template=ros2_cpp_pkg \ -d package_name=ros2_cpp_component_pkg \ -d node_name=ros2_cpp_node \ @@ -32,9 +33,9 @@ copier copy --trust --defaults \ -d has_action_server=false \ -d has_timer=false \ -d has_docker_ros=true \ - . $script_dir + $template_dir $script_dir -copier copy --trust --defaults \ +copier copy --trust --defaults --overwrite --vcs-ref=HEAD \ -d template=ros2_cpp_pkg \ -d package_name=ros2_cpp_lifecycle_pkg \ -d node_name=ros2_cpp_node \ @@ -48,9 +49,9 @@ copier copy --trust --defaults \ -d has_action_server=false \ -d has_timer=false \ -d has_docker_ros=true \ - . $script_dir + $template_dir $script_dir -copier copy --trust --defaults \ +copier copy --trust --defaults --overwrite --vcs-ref=HEAD \ -d template=ros2_cpp_pkg \ -d package_name=ros2_cpp_all_pkg \ -d node_name=ros2_cpp_node \ @@ -64,9 +65,9 @@ copier copy --trust --defaults \ -d has_action_server=true \ -d has_timer=true \ -d has_docker_ros=true \ - . $script_dir + $template_dir $script_dir -copier copy --trust --defaults \ +copier copy --trust --defaults --overwrite --vcs-ref=HEAD \ -d template=ros2_python_pkg \ -d package_name=ros2_python_pkg \ -d node_name=ros2_python_node \ @@ -78,9 +79,9 @@ copier copy --trust --defaults \ -d has_action_server=false \ -d has_timer=false \ -d has_docker_ros=true \ - . $script_dir + $template_dir $script_dir -copier copy --trust --defaults \ +copier copy --trust --defaults --overwrite --vcs-ref=HEAD \ -d template=ros2_python_pkg \ -d package_name=ros2_python_all_pkg \ -d node_name=ros2_python_node \ @@ -92,9 +93,9 @@ copier copy --trust --defaults \ -d has_action_server=true \ -d has_timer=true \ -d has_docker_ros=true \ - . $script_dir + $template_dir $script_dir -copier copy --trust --defaults \ +copier copy --trust --defaults --overwrite --vcs-ref=HEAD \ -d template=ros2_interfaces_pkg \ -d package_name=ros2_interfaces_pkg \ - . $script_dir + $template_dir $script_dir diff --git a/samples/ros2_cpp_all_pkg/launch/ros2_cpp_node_launch.py b/samples/ros2_cpp_all_pkg/launch/ros2_cpp_node_launch.py index 9e9b252..f6e6025 100644 --- a/samples/ros2_cpp_all_pkg/launch/ros2_cpp_node_launch.py +++ b/samples/ros2_cpp_all_pkg/launch/ros2_cpp_node_launch.py @@ -12,12 +12,19 @@ def generate_launch_description(): + remappable_topics = [ + DeclareLaunchArgument("input_topic", default_value="~/input"), + DeclareLaunchArgument("output_topic", default_value="~/output"), + ] + args = [ DeclareLaunchArgument("name", default_value="ros2_cpp_node", description="node name"), DeclareLaunchArgument("namespace", default_value="", description="node namespace"), DeclareLaunchArgument("params", default_value=os.path.join(get_package_share_directory("ros2_cpp_all_pkg"), "config", "params.yml"), description="path to parameter file"), DeclareLaunchArgument("log_level", default_value="info", description="ROS logging level (debug, info, warn, error, fatal)"), DeclareLaunchArgument("startup_state", default_value="None", description="initial lifecycle state"), + DeclareLaunchArgument("use_sim_time", default_value="false", description="use simulation clock"), + *remappable_topics, ] nodes = [ @@ -35,6 +42,7 @@ def generate_launch_description(): name=LaunchConfiguration("name"), parameters=[LaunchConfiguration("params")], arguments=["--ros-args", "--log-level", LaunchConfiguration("log_level")], + remappings=[(la.default_value[0].text, LaunchConfiguration(la.name)) for la in remappable_topics], output="screen", emulate_tty=True, ) @@ -44,5 +52,6 @@ def generate_launch_description(): return LaunchDescription([ *args, + SetParameter("use_sim_time", LaunchConfiguration("use_sim_time")), *nodes, ]) diff --git a/samples/ros2_cpp_component_pkg/launch/ros2_cpp_node_launch.py b/samples/ros2_cpp_component_pkg/launch/ros2_cpp_node_launch.py index c1cb24f..6f8c6d4 100644 --- a/samples/ros2_cpp_component_pkg/launch/ros2_cpp_node_launch.py +++ b/samples/ros2_cpp_component_pkg/launch/ros2_cpp_node_launch.py @@ -6,16 +6,23 @@ from launch import LaunchDescription from launch.actions import DeclareLaunchArgument from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node +from launch_ros.actions import Node, SetParameter def generate_launch_description(): + remappable_topics = [ + DeclareLaunchArgument("input_topic", default_value="~/input"), + DeclareLaunchArgument("output_topic", default_value="~/output"), + ] + args = [ DeclareLaunchArgument("name", default_value="ros2_cpp_node", description="node name"), DeclareLaunchArgument("namespace", default_value="", description="node namespace"), DeclareLaunchArgument("params", default_value=os.path.join(get_package_share_directory("ros2_cpp_component_pkg"), "config", "params.yml"), description="path to parameter file"), DeclareLaunchArgument("log_level", default_value="info", description="ROS logging level (debug, info, warn, error, fatal)"), + DeclareLaunchArgument("use_sim_time", default_value="false", description="use simulation clock"), + *remappable_topics, ] nodes = [ @@ -26,6 +33,7 @@ def generate_launch_description(): name=LaunchConfiguration("name"), parameters=[LaunchConfiguration("params")], arguments=["--ros-args", "--log-level", LaunchConfiguration("log_level")], + remappings=[(la.default_value[0].text, LaunchConfiguration(la.name)) for la in remappable_topics], output="screen", emulate_tty=True, ) @@ -33,5 +41,6 @@ def generate_launch_description(): return LaunchDescription([ *args, + SetParameter("use_sim_time", LaunchConfiguration("use_sim_time")), *nodes, ]) diff --git a/samples/ros2_cpp_lifecycle_pkg/launch/ros2_cpp_node_launch.py b/samples/ros2_cpp_lifecycle_pkg/launch/ros2_cpp_node_launch.py index 98ba960..f6f632b 100644 --- a/samples/ros2_cpp_lifecycle_pkg/launch/ros2_cpp_node_launch.py +++ b/samples/ros2_cpp_lifecycle_pkg/launch/ros2_cpp_node_launch.py @@ -12,12 +12,19 @@ def generate_launch_description(): + remappable_topics = [ + DeclareLaunchArgument("input_topic", default_value="~/input"), + DeclareLaunchArgument("output_topic", default_value="~/output"), + ] + args = [ DeclareLaunchArgument("name", default_value="ros2_cpp_node", description="node name"), DeclareLaunchArgument("namespace", default_value="", description="node namespace"), DeclareLaunchArgument("params", default_value=os.path.join(get_package_share_directory("ros2_cpp_lifecycle_pkg"), "config", "params.yml"), description="path to parameter file"), DeclareLaunchArgument("log_level", default_value="info", description="ROS logging level (debug, info, warn, error, fatal)"), DeclareLaunchArgument("startup_state", default_value="None", description="initial lifecycle state"), + DeclareLaunchArgument("use_sim_time", default_value="false", description="use simulation clock"), + *remappable_topics, ] nodes = [ @@ -35,6 +42,7 @@ def generate_launch_description(): name=LaunchConfiguration("name"), parameters=[LaunchConfiguration("params")], arguments=["--ros-args", "--log-level", LaunchConfiguration("log_level")], + remappings=[(la.default_value[0].text, LaunchConfiguration(la.name)) for la in remappable_topics], output="screen", emulate_tty=True, ) @@ -44,5 +52,6 @@ def generate_launch_description(): return LaunchDescription([ *args, + SetParameter("use_sim_time", LaunchConfiguration("use_sim_time")), *nodes, ]) diff --git a/samples/ros2_cpp_pkg/launch/ros2_cpp_node_launch.py b/samples/ros2_cpp_pkg/launch/ros2_cpp_node_launch.py index c270c91..4d3b809 100644 --- a/samples/ros2_cpp_pkg/launch/ros2_cpp_node_launch.py +++ b/samples/ros2_cpp_pkg/launch/ros2_cpp_node_launch.py @@ -6,16 +6,23 @@ from launch import LaunchDescription from launch.actions import DeclareLaunchArgument from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node +from launch_ros.actions import Node, SetParameter def generate_launch_description(): + remappable_topics = [ + DeclareLaunchArgument("input_topic", default_value="~/input"), + DeclareLaunchArgument("output_topic", default_value="~/output"), + ] + args = [ DeclareLaunchArgument("name", default_value="ros2_cpp_node", description="node name"), DeclareLaunchArgument("namespace", default_value="", description="node namespace"), DeclareLaunchArgument("params", default_value=os.path.join(get_package_share_directory("ros2_cpp_pkg"), "config", "params.yml"), description="path to parameter file"), DeclareLaunchArgument("log_level", default_value="info", description="ROS logging level (debug, info, warn, error, fatal)"), + DeclareLaunchArgument("use_sim_time", default_value="false", description="use simulation clock"), + *remappable_topics, ] nodes = [ @@ -26,6 +33,7 @@ def generate_launch_description(): name=LaunchConfiguration("name"), parameters=[LaunchConfiguration("params")], arguments=["--ros-args", "--log-level", LaunchConfiguration("log_level")], + remappings=[(la.default_value[0].text, LaunchConfiguration(la.name)) for la in remappable_topics], output="screen", emulate_tty=True, ) @@ -33,5 +41,6 @@ def generate_launch_description(): return LaunchDescription([ *args, + SetParameter("use_sim_time", LaunchConfiguration("use_sim_time")), *nodes, ]) diff --git a/samples/ros2_python_all_pkg/launch/ros2_python_node_launch.py b/samples/ros2_python_all_pkg/launch/ros2_python_node_launch.py index 9d31fcf..2a36216 100644 --- a/samples/ros2_python_all_pkg/launch/ros2_python_node_launch.py +++ b/samples/ros2_python_all_pkg/launch/ros2_python_node_launch.py @@ -6,16 +6,23 @@ from launch import LaunchDescription from launch.actions import DeclareLaunchArgument from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node +from launch_ros.actions import Node, SetParameter def generate_launch_description(): + remappable_topics = [ + DeclareLaunchArgument("input_topic", default_value="~/input"), + DeclareLaunchArgument("output_topic", default_value="~/output"), + ] + args = [ DeclareLaunchArgument("name", default_value="ros2_python_node", description="node name"), DeclareLaunchArgument("namespace", default_value="", description="node namespace"), DeclareLaunchArgument("params", default_value=os.path.join(get_package_share_directory("ros2_python_all_pkg"), "config", "params.yml"), description="path to parameter file"), DeclareLaunchArgument("log_level", default_value="info", description="ROS logging level (debug, info, warn, error, fatal)"), + DeclareLaunchArgument("use_sim_time", default_value="false", description="use simulation clock"), + *remappable_topics, ] nodes = [ @@ -26,6 +33,7 @@ def generate_launch_description(): name=LaunchConfiguration("name"), parameters=[LaunchConfiguration("params")], arguments=["--ros-args", "--log-level", LaunchConfiguration("log_level")], + remappings=[(la.default_value[0].text, LaunchConfiguration(la.name)) for la in remappable_topics], output="screen", emulate_tty=True, ) @@ -33,5 +41,6 @@ def generate_launch_description(): return LaunchDescription([ *args, + SetParameter("use_sim_time", LaunchConfiguration("use_sim_time")), *nodes, ]) diff --git a/samples/ros2_python_pkg/launch/ros2_python_node_launch.py b/samples/ros2_python_pkg/launch/ros2_python_node_launch.py index c4d5a5b..7f78a02 100644 --- a/samples/ros2_python_pkg/launch/ros2_python_node_launch.py +++ b/samples/ros2_python_pkg/launch/ros2_python_node_launch.py @@ -6,16 +6,23 @@ from launch import LaunchDescription from launch.actions import DeclareLaunchArgument from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node +from launch_ros.actions import Node, SetParameter def generate_launch_description(): + remappable_topics = [ + DeclareLaunchArgument("input_topic", default_value="~/input"), + DeclareLaunchArgument("output_topic", default_value="~/output"), + ] + args = [ DeclareLaunchArgument("name", default_value="ros2_python_node", description="node name"), DeclareLaunchArgument("namespace", default_value="", description="node namespace"), DeclareLaunchArgument("params", default_value=os.path.join(get_package_share_directory("ros2_python_pkg"), "config", "params.yml"), description="path to parameter file"), DeclareLaunchArgument("log_level", default_value="info", description="ROS logging level (debug, info, warn, error, fatal)"), + DeclareLaunchArgument("use_sim_time", default_value="false", description="use simulation clock"), + *remappable_topics, ] nodes = [ @@ -26,6 +33,7 @@ def generate_launch_description(): name=LaunchConfiguration("name"), parameters=[LaunchConfiguration("params")], arguments=["--ros-args", "--log-level", LaunchConfiguration("log_level")], + remappings=[(la.default_value[0].text, LaunchConfiguration(la.name)) for la in remappable_topics], output="screen", emulate_tty=True, ) @@ -33,5 +41,6 @@ def generate_launch_description(): return LaunchDescription([ *args, + SetParameter("use_sim_time", LaunchConfiguration("use_sim_time")), *nodes, ]) diff --git a/templates/ros2_cpp_pkg/{{ package_name }}/{% if has_launch_file %}launch{% endif %}/{% if launch_file_type == 'py' %}{{ node_name }}_launch.py{% endif %}.jinja b/templates/ros2_cpp_pkg/{{ package_name }}/{% if has_launch_file %}launch{% endif %}/{% if launch_file_type == 'py' %}{{ node_name }}_launch.py{% endif %}.jinja index 98e5dac..12dd3d7 100644 --- a/templates/ros2_cpp_pkg/{{ package_name }}/{% if has_launch_file %}launch{% endif %}/{% if launch_file_type == 'py' %}{{ node_name }}_launch.py{% endif %}.jinja +++ b/templates/ros2_cpp_pkg/{{ package_name }}/{% if has_launch_file %}launch{% endif %}/{% if launch_file_type == 'py' %}{{ node_name }}_launch.py{% endif %}.jinja @@ -12,12 +12,21 @@ from launch_ros.actions import LifecycleNode, SetParameter {% else %} from launch.actions import DeclareLaunchArgument from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node +from launch_ros.actions import Node, SetParameter {% endif %} def generate_launch_description(): + remappable_topics = [ +{% if has_subscriber %} + DeclareLaunchArgument("input_topic", default_value="~/input"), +{% endif %} +{% if has_publisher %} + DeclareLaunchArgument("output_topic", default_value="~/output"), +{% endif %} + ] + args = [ DeclareLaunchArgument("name", default_value="{{ node_name }}", description="node name"), DeclareLaunchArgument("namespace", default_value="", description="node namespace"), @@ -26,6 +35,8 @@ def generate_launch_description(): {% if is_lifecycle %} DeclareLaunchArgument("startup_state", default_value="None", description="initial lifecycle state"), {% endif %} + DeclareLaunchArgument("use_sim_time", default_value="false", description="use simulation clock"), + *remappable_topics, ] {% if is_lifecycle %} @@ -48,6 +59,7 @@ def generate_launch_description(): parameters=[], {% endif %} arguments=["--ros-args", "--log-level", LaunchConfiguration("log_level")], + remappings=[(la.default_value[0].text, LaunchConfiguration(la.name)) for la in remappable_topics], output="screen", emulate_tty=True, ) @@ -67,6 +79,7 @@ def generate_launch_description(): parameters=[], {% endif %} arguments=["--ros-args", "--log-level", LaunchConfiguration("log_level")], + remappings=[(la.default_value[0].text, LaunchConfiguration(la.name)) for la in remappable_topics], output="screen", emulate_tty=True, ) @@ -75,5 +88,6 @@ def generate_launch_description(): return LaunchDescription([ *args, + SetParameter("use_sim_time", LaunchConfiguration("use_sim_time")), *nodes, ]) diff --git a/templates/ros2_python_pkg/{{ package_name }}/{% if has_launch_file %}launch{% endif %}/{% if launch_file_type == 'py' %}{{ node_name }}_launch.py{% endif %}.jinja b/templates/ros2_python_pkg/{{ package_name }}/{% if has_launch_file %}launch{% endif %}/{% if launch_file_type == 'py' %}{{ node_name }}_launch.py{% endif %}.jinja index 59ad2ac..e2f371e 100644 --- a/templates/ros2_python_pkg/{{ package_name }}/{% if has_launch_file %}launch{% endif %}/{% if launch_file_type == 'py' %}{{ node_name }}_launch.py{% endif %}.jinja +++ b/templates/ros2_python_pkg/{{ package_name }}/{% if has_launch_file %}launch{% endif %}/{% if launch_file_type == 'py' %}{{ node_name }}_launch.py{% endif %}.jinja @@ -6,16 +6,27 @@ from ament_index_python import get_package_share_directory from launch import LaunchDescription from launch.actions import DeclareLaunchArgument from launch.substitutions import LaunchConfiguration -from launch_ros.actions import Node +from launch_ros.actions import Node, SetParameter def generate_launch_description(): + remappable_topics = [ +{% if has_subscriber %} + DeclareLaunchArgument("input_topic", default_value="~/input"), +{% endif %} +{% if has_publisher %} + DeclareLaunchArgument("output_topic", default_value="~/output"), +{% endif %} + ] + args = [ DeclareLaunchArgument("name", default_value="{{ node_name }}", description="node name"), DeclareLaunchArgument("namespace", default_value="", description="node namespace"), DeclareLaunchArgument("params", default_value=os.path.join(get_package_share_directory("{{ package_name }}"), "config", "params.yml"), description="path to parameter file"), DeclareLaunchArgument("log_level", default_value="info", description="ROS logging level (debug, info, warn, error, fatal)"), + DeclareLaunchArgument("use_sim_time", default_value="false", description="use simulation clock"), + *remappable_topics, ] nodes = [ @@ -30,6 +41,7 @@ def generate_launch_description(): parameters=[], {% endif %} arguments=["--ros-args", "--log-level", LaunchConfiguration("log_level")], + remappings=[(la.default_value[0].text, LaunchConfiguration(la.name)) for la in remappable_topics], output="screen", emulate_tty=True, ) @@ -37,5 +49,6 @@ def generate_launch_description(): return LaunchDescription([ *args, + SetParameter("use_sim_time", LaunchConfiguration("use_sim_time")), *nodes, ])