From 3c3a3accb2434851fb85ba0d573278a004d59077 Mon Sep 17 00:00:00 2001 From: kmakd Date: Wed, 20 Nov 2024 11:59:40 +0000 Subject: [PATCH 1/3] use configs from /config dir --- .../launch/controller.launch.py | 17 +++++++++------- .../config/user_animations.yaml | 20 +++++++++++++++++++ husarion_ugv_lights/launch/lights.launch.py | 11 ++++++---- .../launch/localization.launch.py | 2 +- husarion_ugv_manager/launch/manager.launch.py | 13 ++++++------ 5 files changed, 45 insertions(+), 18 deletions(-) create mode 100644 husarion_ugv_lights/config/user_animations.yaml diff --git a/husarion_ugv_controller/launch/controller.launch.py b/husarion_ugv_controller/launch/controller.launch.py index 2e61a3702..70d262ef9 100644 --- a/husarion_ugv_controller/launch/controller.launch.py +++ b/husarion_ugv_controller/launch/controller.launch.py @@ -34,6 +34,11 @@ def generate_launch_description(): + husarion_ugv_desctiption_pkg = FindPackageShare("husarion_ugv_description") + husarion_ugv_controller_common_dir = PathJoinSubstitution( + ["/config", "husarion_ugv_controller"] + ) + battery_config_path = LaunchConfiguration("battery_config_path") declare_battery_config_path_arg = DeclareLaunchArgument( "battery_config_path", @@ -48,7 +53,7 @@ def generate_launch_description(): declare_components_config_path_arg = DeclareLaunchArgument( "components_config_path", default_value=PathJoinSubstitution( - [FindPackageShare("panther_description"), "config", "components.yaml"] + [husarion_ugv_desctiption_pkg, "config", "components.yaml"] ), description=( "Additional components configuration file. Components described in this file " @@ -64,7 +69,7 @@ def generate_launch_description(): "controller_config_path", default_value=PathJoinSubstitution( [ - FindPackageShare("husarion_ugv_controller"), + husarion_ugv_controller_common_dir, "config", PythonExpression(["'", wheel_type, "_controller.yaml'"]), ] @@ -112,20 +117,19 @@ def generate_launch_description(): choices=["True", "true", "False", "false"], ) - robot_description_pkg = PythonExpression(["'", robot_model, "_description'"]) wheel_config_path = LaunchConfiguration("wheel_config_path") declare_wheel_config_path_arg = DeclareLaunchArgument( "wheel_config_path", default_value=PathJoinSubstitution( [ - FindPackageShare(robot_description_pkg), + FindPackageShare(husarion_ugv_desctiption_pkg), "config", PythonExpression(["'", wheel_type, ".yaml'"]), ] ), description=( "Path to wheel configuration file. By default, it is located in " - "'panther_description/config/{wheel_type}.yaml'. You can also specify the path " + "'husarion_ugv_description/config/{wheel_type}.yaml'. You can also specify the path " "to your custom wheel configuration file here. " ), ) @@ -143,7 +147,6 @@ def generate_launch_description(): ) # Get URDF via xacro - robot_description_pkg = PythonExpression(["'", robot_model, "_description'"]) robot_description_file = PythonExpression(["'", robot_model, ".urdf.xacro'"]) imu_pos_x = os.environ.get("ROBOT_IMU_LOCALIZATION_X", "0.168") imu_pos_y = os.environ.get("ROBOT_IMU_LOCALIZATION_Y", "0.028") @@ -157,7 +160,7 @@ def generate_launch_description(): " ", PathJoinSubstitution( [ - FindPackageShare(robot_description_pkg), + FindPackageShare(husarion_ugv_desctiption_pkg), "urdf", robot_description_file, ] diff --git a/husarion_ugv_lights/config/user_animations.yaml b/husarion_ugv_lights/config/user_animations.yaml new file mode 100644 index 000000000..017713474 --- /dev/null +++ b/husarion_ugv_lights/config/user_animations.yaml @@ -0,0 +1,20 @@ +# This file is a placeholder for user-defined animations for the Husarion UGV +# robots lights system. Users can define their own light animations in this +# YAML file. +# +# For more examples and detailed documentation, please visit: +# https://github.com/husarion/panther_ros/blob/ros2/panther_lights/CONFIGURATION.md#defining-animations +# +# Example including a simple custom animation: +# +# user_animations: +# - id: 21 +# name: CUSTOM_IMAGE_ANIMATION +# priority: 3 +# animations: +# - type: panther_lights::ImageAnimation +# segments: all +# animation: +# image: /config/husarion_ugv_lights/animations/example.png +# duration: 3 +# repeat: 1 diff --git a/husarion_ugv_lights/launch/lights.launch.py b/husarion_ugv_lights/launch/lights.launch.py index fa45aa530..8fd1f466f 100644 --- a/husarion_ugv_lights/launch/lights.launch.py +++ b/husarion_ugv_lights/launch/lights.launch.py @@ -33,13 +33,14 @@ def generate_launch_description(): robot_model = LaunchConfiguration("robot_model") - lights_pkg = FindPackageShare("husarion_ugv_lights") + husarion_ugv_lights_pkg = FindPackageShare("husarion_ugv_lights") + husarion_ugv_lights_common_dir = PathJoinSubstitution(["/config", "husarion_ugv_lights"]) animations_config = PythonExpression(["'", robot_model, "_animations.yaml'"]) animations_config_path = LaunchConfiguration("animations_config_path") declare_animations_config_path_arg = DeclareLaunchArgument( "animations_config_path", - default_value=PathJoinSubstitution([lights_pkg, "config", animations_config]), + default_value=PathJoinSubstitution([husarion_ugv_lights_pkg, "config", animations_config]), description="Path to a YAML file with a description of led configuration.", ) @@ -69,12 +70,14 @@ def generate_launch_description(): user_led_animations_path = LaunchConfiguration("user_led_animations_path") declare_user_led_animations_path_arg = DeclareLaunchArgument( "user_led_animations_path", - default_value="", + default_value=PathJoinSubstitution( + [husarion_ugv_lights_common_dir, "config", "user_animations.yaml"] + ), description="Path to a YAML file with a description of the user defined animations.", ) driver_config = PythonExpression(["'", robot_model, "_driver.yaml'"]) - driver_config_path = PathJoinSubstitution([lights_pkg, "config", driver_config]) + driver_config_path = PathJoinSubstitution([husarion_ugv_lights_pkg, "config", driver_config]) lights_container = ComposableNodeContainer( package="rclcpp_components", name="lights_container", diff --git a/husarion_ugv_localization/launch/localization.launch.py b/husarion_ugv_localization/launch/localization.launch.py index e948eb284..f03843e7f 100644 --- a/husarion_ugv_localization/launch/localization.launch.py +++ b/husarion_ugv_localization/launch/localization.launch.py @@ -90,7 +90,7 @@ def generate_launch_description(): declare_localization_config_path_arg = DeclareLaunchArgument( "localization_config_path", default_value=PathJoinSubstitution( - [FindPackageShare("husarion_ugv_localization"), "config", localization_config_filename] + ["/config", "husarion_ugv_localization", "config", localization_config_filename] ), description="Specify the path to the localization configuration file.", ) diff --git a/husarion_ugv_manager/launch/manager.launch.py b/husarion_ugv_manager/launch/manager.launch.py index 1412e924a..60c0b4f52 100644 --- a/husarion_ugv_manager/launch/manager.launch.py +++ b/husarion_ugv_manager/launch/manager.launch.py @@ -28,13 +28,14 @@ def generate_launch_description(): - husarion_ugv_manager_dir = FindPackageShare("husarion_ugv_manager") + husarion_ugv_manager_pkg = FindPackageShare("husarion_ugv_manager") + husarion_ugv_manager_common_dir = PathJoinSubstitution(["/config", "husarion_ugv_manager"]) lights_bt_project_path = LaunchConfiguration("lights_bt_project_path") declare_lights_bt_project_path_arg = DeclareLaunchArgument( "lights_bt_project_path", default_value=PathJoinSubstitution( - [husarion_ugv_manager_dir, "behavior_trees", "LightsBT.btproj"] + [husarion_ugv_manager_common_dir, "behavior_trees", "LightsBT.btproj"] ), description="Path to BehaviorTree project file, responsible for lights management.", ) @@ -50,7 +51,7 @@ def generate_launch_description(): declare_safety_bt_project_path_arg = DeclareLaunchArgument( "safety_bt_project_path", default_value=PathJoinSubstitution( - [husarion_ugv_manager_dir, "behavior_trees", "SafetyBT.btproj"] + [husarion_ugv_manager_pkg, "behavior_trees", "SafetyBT.btproj"] ), description="Path to BehaviorTree project file, responsible for safety and shutdown management.", ) @@ -60,7 +61,7 @@ def generate_launch_description(): "shutdown_hosts_config_path", default_value=PathJoinSubstitution( [ - FindPackageShare("husarion_ugv_manager"), + husarion_ugv_manager_common_dir, "config", "shutdown_hosts.yaml", ] @@ -80,7 +81,7 @@ def generate_launch_description(): executable="lights_manager_node", name="lights_manager", parameters=[ - PathJoinSubstitution([husarion_ugv_manager_dir, "config", "lights_manager.yaml"]), + PathJoinSubstitution([husarion_ugv_manager_pkg, "config", "lights_manager.yaml"]), {"bt_project_path": lights_bt_project_path}, ], namespace=namespace, @@ -92,7 +93,7 @@ def generate_launch_description(): executable="safety_manager_node", name="safety_manager", parameters=[ - PathJoinSubstitution([husarion_ugv_manager_dir, "config", "safety_manager.yaml"]), + PathJoinSubstitution([husarion_ugv_manager_pkg, "config", "safety_manager.yaml"]), { "bt_project_path": safety_bt_project_path, "shutdown_hosts_path": shutdown_hosts_config_path, From 9d5be9fb71d001e75682b0c35e4ef413d49f54de Mon Sep 17 00:00:00 2001 From: kmakd Date: Thu, 21 Nov 2024 07:53:09 +0000 Subject: [PATCH 2/3] component file --- .../launch/controller.launch.py | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/husarion_ugv_controller/launch/controller.launch.py b/husarion_ugv_controller/launch/controller.launch.py index 70d262ef9..661f67cd3 100644 --- a/husarion_ugv_controller/launch/controller.launch.py +++ b/husarion_ugv_controller/launch/controller.launch.py @@ -34,11 +34,24 @@ def generate_launch_description(): - husarion_ugv_desctiption_pkg = FindPackageShare("husarion_ugv_description") husarion_ugv_controller_common_dir = PathJoinSubstitution( ["/config", "husarion_ugv_controller"] ) + robot_model = LaunchConfiguration("robot_model") + robot_model_dict = {"LNX": "lynx", "PTH": "panther"} + robot_model_env = os.environ.get("ROBOT_MODEL", default="PTH") + + robot_description_pkg = PythonExpression(["'", robot_model, "_description'"]) + robot_description_common_dir = PathJoinSubstitution(["/config", robot_description_pkg]) + + declare_robot_model_arg = DeclareLaunchArgument( + "robot_model", + default_value=robot_model_dict[robot_model_env], + description="Specify robot model", + choices=["lynx", "panther"], + ) + battery_config_path = LaunchConfiguration("battery_config_path") declare_battery_config_path_arg = DeclareLaunchArgument( "battery_config_path", @@ -53,7 +66,7 @@ def generate_launch_description(): declare_components_config_path_arg = DeclareLaunchArgument( "components_config_path", default_value=PathJoinSubstitution( - [husarion_ugv_desctiption_pkg, "config", "components.yaml"] + [robot_description_common_dir, "config", "components.yaml"] ), description=( "Additional components configuration file. Components described in this file " @@ -99,16 +112,6 @@ def generate_launch_description(): choices=["True", "true", "False", "false"], ) - robot_model = LaunchConfiguration("robot_model") - robot_model_dict = {"LNX": "lynx", "PTH": "panther"} - robot_model_env = os.environ.get("ROBOT_MODEL", default="PTH") - declare_robot_model_arg = DeclareLaunchArgument( - "robot_model", - default_value=robot_model_dict[robot_model_env], - description="Specify robot model", - choices=["lynx", "panther"], - ) - use_sim = LaunchConfiguration("use_sim") declare_use_sim_arg = DeclareLaunchArgument( "use_sim", @@ -122,14 +125,14 @@ def generate_launch_description(): "wheel_config_path", default_value=PathJoinSubstitution( [ - FindPackageShare(husarion_ugv_desctiption_pkg), + FindPackageShare(robot_description_pkg), "config", PythonExpression(["'", wheel_type, ".yaml'"]), ] ), description=( "Path to wheel configuration file. By default, it is located in " - "'husarion_ugv_description/config/{wheel_type}.yaml'. You can also specify the path " + "'panther_description/config/{wheel_type}.yaml'. You can also specify the path " "to your custom wheel configuration file here. " ), ) @@ -160,7 +163,7 @@ def generate_launch_description(): " ", PathJoinSubstitution( [ - FindPackageShare(husarion_ugv_desctiption_pkg), + FindPackageShare(robot_description_pkg), "urdf", robot_description_file, ] From 1c29f54d7bd429819fc91cb76cf2310af01ab194 Mon Sep 17 00:00:00 2001 From: kmakd Date: Mon, 25 Nov 2024 13:22:04 +0000 Subject: [PATCH 3/3] fix example --- husarion_ugv_lights/CONFIGURATION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/husarion_ugv_lights/CONFIGURATION.md b/husarion_ugv_lights/CONFIGURATION.md index 986aba94c..a4d8d6dee 100644 --- a/husarion_ugv_lights/CONFIGURATION.md +++ b/husarion_ugv_lights/CONFIGURATION.md @@ -96,7 +96,7 @@ user_animations: - type: husarion_ugv_lights::ImageAnimation segments: all animation: - image: $(find husarion_ugv_lights)/animations/strip01_red.png + image: $(find husarion_ugv_lights)/animations/panther/strip01_red.png duration: 2 repeat: 2 color: 0xffff00