From 62e843674e5359470914e0d0a4ec494079df928e Mon Sep 17 00:00:00 2001 From: rafal-gorecki <126687345+rafal-gorecki@users.noreply.github.com> Date: Mon, 30 Sep 2024 16:20:38 +0200 Subject: [PATCH] Unify arguments and config names (#416) * Unify arguments and config names * led_config_file -> animations_config_path --- .gitignore | 6 ++---- README.md | 7 +++++-- panther_gazebo/CONFIGURATION.md | 2 +- panther_gazebo/README.md | 2 +- ...plugin_config.yaml => battery_plugin.yaml} | 0 .../launch/simulate_robot.launch.py | 2 +- panther_lights/README.md | 4 ++-- .../panther_lights/lights_controller_node.hpp | 4 ++-- panther_lights/launch/lights.launch.py | 20 +++++++++---------- panther_lights/src/lights_controller_node.cpp | 18 ++++++++--------- .../test/integration/panther_lights.test.py | 4 ++-- .../test/unit/test_lights_controller_node.cpp | 13 +++++++----- panther_manager/CONFIGURATION.md | 2 +- panther_manager/README.md | 2 +- ..._hosts_config.yaml => shutdown_hosts.yaml} | 0 panther_manager/launch/manager.launch.py | 2 +- 16 files changed, 46 insertions(+), 42 deletions(-) rename panther_gazebo/config/{battery_plugin_config.yaml => battery_plugin.yaml} (100%) rename panther_manager/config/{shutdown_hosts_config.yaml => shutdown_hosts.yaml} (100%) diff --git a/.gitignore b/.gitignore index f42d579a3..ac9f2a85e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ -devel/ -logs/ build/ +log/ +install/ bin/ lib/ msg_gen/ @@ -13,8 +13,6 @@ msg/*Feedback.msg msg/*Goal.msg msg/*Result.msg msg/_*.py -build_isolated/ -devel_isolated/ # Generated by dynamic reconfigure *.cfgc diff --git a/README.md b/README.md index da2a5affc..e887b3cb9 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,9 @@ Simulation: ros2 launch panther_gazebo simulation.launch.py ``` +> [!IMPORTANT] +> You can change spawning robot in simulation, by adding `robot_model:={robot_model}` argument. + ### Launch Arguments Launch arguments are largely common to both simulation and physical robot. However, there is a group of arguments that apply only to hardware or only to the simulator. Below is a legend to the tables with all launch arguments. @@ -84,6 +87,7 @@ Launch arguments are largely common to both simulation and physical robot. Howev | --- | ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 🖥️ | `add_wheel_joints` | Flag enabling joint_state_publisher to publish information about the wheel position. Should be false when there is a controller that sends this information.
***bool:*** `False` | | 🖥️ | `add_world_transform` | Adds a world frame that connects the tf trees of individual robots (useful when running multiple robots).
***bool:*** `False` | +| 🤖🖥️ | `animations_config_path` | Path to a YAML file with a description of led configuration. This file includes definition of robot panels, virtual segments and default animations.
***string:*** [`led_config.yaml`](./panther_lights/config/led_config.yaml) | | 🖥️ | `battery_config_path` | Path to the Ignition LinearBatteryPlugin configuration file. This configuration is intended for use in simulations only.
***string:*** `None` | | 🤖🖥️ | `components_config_path` | Additional components configuration file. Components described in this file are dynamically included in Panther's urdf. Panther options are described in [the manual](https://husarion.com/manuals/panther/panther-options).
***string:*** [`components.yaml`](./panther_description/config/components.yaml) | | 🤖🖥️ | `controller_config_path` | Path to controller configuration file. A path to custom configuration can be specified here.
***string:*** [`{wheel_type}_controller.yaml`](./panther_controller/config/) | @@ -95,7 +99,6 @@ Launch arguments are largely common to both simulation and physical robot. Howev | 🖥️ | `gz_log_level` | Adjust the level of console output.
***int:*** `1` (choices: `0`, `1`, `2`, `3`, `4`) | | 🖥️ | `gz_world` | Absolute path to SDF world file.
***string:*** [`husarion_world.sdf`](https://github.com/husarion/husarion_gz_worlds/blob/main/worlds/husarion_world.sdf) | | 🤖 | `launch_nmea_gps` | Whether to launch the NMEA NavSat driver node. Advisable when the robot is equipped with the [ANT02](https://husarion.com/manuals/panther/panther-options/#ant02---wi-fi--lte--gps).
***bool:*** `False` | -| 🤖🖥️ | `led_config_file` | Path to a YAML file with a description of led configuration. This file includes definition of robot panels, virtual segments and default animations.
***string:*** [`led_config.yaml`](./panther_lights/config/led_config.yaml) | | 🤖🖥️ | `lights_bt_project_path` | Path to BehaviorTree project file, responsible for lights management.
***string:*** [`PantherLightsBT.btproj`](./panther_manager/behavior_trees/PantherLightsBT.btproj) | | 🤖🖥️ | `localization_config_path` | Specify the path to the localization configuration file.
***string:*** [`relative_localization.yaml`](./panther_localization/config/relative_localization.yaml) | | 🤖🖥️ | `localization_mode` | Specifies the localization mode:
- 'relative' `odometry/filtered` data is relative to the initial position and orientation.
- 'enu' `odometry/filtered` data is relative to initial position and ENU (East North Up) orientation.
***string:*** `relative` (choices: `relative`, `enu`) | @@ -106,7 +109,7 @@ Launch arguments are largely common to both simulation and physical robot. Howev | 🤖🖥️ | `shutdown_hosts_config_path` | Path to file with list of hosts to request shutdown.
***string:*** [`shutdown_hosts_config.yaml`](./panther_manager/config/shutdown_hosts_config.yaml) | | 🤖🖥️ | `use_ekf` | Enable or disable EKF.
***bool:*** `True` | | 🤖🖥️ | `use_sim` | Whether simulation is used.
***bool:*** `False` | -| 🤖🖥️ | `user_led_animations_file` | Path to a YAML file with a description of the user-defined animations.
***string:*** `''` | +| 🤖🖥️ | `user_led_animations_path` | Path to a YAML file with a description of the user-defined animations.
***string:*** `''` | | 🤖🖥️ | `wheel_config_path` | Path to wheel configuration file.
***string:*** [`{wheel_type}.yaml`](./panther_description/config) | | 🤖🖥️ | `wheel_type` | Specify the wheel type. If the selected wheel type is not 'custom', the wheel_config_path and controller_config_path arguments will be automatically adjusted and can be omitted.
***string:*** `WH01` (for Panther), `WH05` (for Lynx) (choices: `WH01`, `WH02`, `WH04`, `WH05`, `custom`) | | 🖥️ | `x` | Initial robot position in the global 'x' axis.
***float:*** `0.0` | diff --git a/panther_gazebo/CONFIGURATION.md b/panther_gazebo/CONFIGURATION.md index c41cc924c..d83baf523 100644 --- a/panther_gazebo/CONFIGURATION.md +++ b/panther_gazebo/CONFIGURATION.md @@ -33,7 +33,7 @@ To obtain GPS data in Ignition, follow these steps: ## Linear Battery Plugin -It is possible to simulate the battery operation of the Panther robot. By default, this feature is disabled, but you can enable it by setting the `simulate_discharging` parameter to `true` in the `battery_plugin_config.yaml` file or in the file pointed to by the `battery_config_path` parameter. Below, you will find the plugin parameters that enable battery simulation. +It is possible to simulate the battery operation of the Panther robot. By default, this feature is disabled, but you can enable it by setting the `simulate_discharging` parameter to `true` in the `battery_plugin.yaml` file or in the file pointed to by the `battery_config_path` parameter. Below, you will find the plugin parameters that enable battery simulation. - `simulate_discharging` [*bool*, default: **false**]: Enables battery simulation. If set to `true`, the battery will discharge **at a constant rate** (regardless of joint torque), and if it depletes completely, the robot will stop moving. When set to `false`, the battery will not discharge, but the battery status information will still be published on the `battery/battery_status` topic. - `initial_charge_percentage` [*float*, default: **70.0**]: Sets the initial charge percentage of the battery. diff --git a/panther_gazebo/README.md b/panther_gazebo/README.md index a4d3bb85a..7a8189153 100644 --- a/panther_gazebo/README.md +++ b/panther_gazebo/README.md @@ -11,7 +11,7 @@ The package contains a launch file and source files used to run the robot simula ## Configuration Files -- [`battery_plugin_config.yaml`](./config/battery_plugin_config.yaml): Simulated LinearBatteryPlugin configuration. +- [`battery_plugin.yaml`](./config/battery_plugin.yaml): Simulated LinearBatteryPlugin configuration. - [`gz_bridge.yaml`](./config/gz_bridge.yaml): Specify data to exchange between ROS and Gazebo simulation. - [`teleop_with_estop.config`](./config/teleop_with_estop.config): Gazebo layout configuration file, which adds E-Stop and Teleop widgets. diff --git a/panther_gazebo/config/battery_plugin_config.yaml b/panther_gazebo/config/battery_plugin.yaml similarity index 100% rename from panther_gazebo/config/battery_plugin_config.yaml rename to panther_gazebo/config/battery_plugin.yaml diff --git a/panther_gazebo/launch/simulate_robot.launch.py b/panther_gazebo/launch/simulate_robot.launch.py index cf2829481..2bd4f822b 100644 --- a/panther_gazebo/launch/simulate_robot.launch.py +++ b/panther_gazebo/launch/simulate_robot.launch.py @@ -51,7 +51,7 @@ def generate_launch_description(): "This configuration is intended for use in simulations only." ), default_value=PathJoinSubstitution( - [FindPackageShare("panther_gazebo"), "config", "battery_plugin_config.yaml"] + [FindPackageShare("panther_gazebo"), "config", "battery_plugin.yaml"] ), ) diff --git a/panther_lights/README.md b/panther_lights/README.md index 8c1a7331f..44b288c18 100644 --- a/panther_lights/README.md +++ b/panther_lights/README.md @@ -29,9 +29,9 @@ This node is of type rclcpp_components is responsible for processing animations #### Parameters +- `~animations_config_path` [*string*, default: **$(find panther_lights)/panther_lights/config/led_config.yaml**]: Path to a YAML file with a description of led configuration. This file includes definition of robot panels, virtual segments and default animations. - `~controller_frequency` [*float*, default: **50.0**]: Frequency [Hz] at which the lights controller node will process animations. -- `~led_config_file` [*string*, default: **$(find panther_lights)/panther_lights/config/led_config.yaml**]: Path to a YAML file with a description of led configuration. This file includes definition of robot panels, virtual segments and default animations. -- `~user_led_animations_file` [*string*, default: **None**]: Path to a YAML file with a description of the user defined animations. +- `~user_led_animations_path` [*string*, default: **None**]: Path to a YAML file with a description of the user defined animations. ### LightsDriverNode diff --git a/panther_lights/include/panther_lights/lights_controller_node.hpp b/panther_lights/include/panther_lights/lights_controller_node.hpp index ef051bd3a..eb98f16f9 100644 --- a/panther_lights/include/panther_lights/lights_controller_node.hpp +++ b/panther_lights/include/panther_lights/lights_controller_node.hpp @@ -90,9 +90,9 @@ class LightsControllerNode : public rclcpp::Node /** * @brief Adds animations to an unordered map with animations * - * @param user_led_animations_file path to YAML file with user animations description + * @param user_led_animations_path path to YAML file with user animations description */ - void LoadUserAnimations(const std::string & user_led_animations_file); + void LoadUserAnimations(const std::string & user_led_animations_path); /** * @brief Adds animation to an unordered map with animations diff --git a/panther_lights/launch/lights.launch.py b/panther_lights/launch/lights.launch.py index f42846f53..eced73925 100644 --- a/panther_lights/launch/lights.launch.py +++ b/panther_lights/launch/lights.launch.py @@ -29,9 +29,9 @@ def generate_launch_description(): - led_config_file = LaunchConfiguration("led_config_file") - declare_led_config_file_arg = DeclareLaunchArgument( - "led_config_file", + animations_config_path = LaunchConfiguration("animations_config_path") + declare_animations_config_path_arg = DeclareLaunchArgument( + "animations_config_path", default_value=PathJoinSubstitution( [FindPackageShare("panther_lights"), "config", "led_config.yaml"] ), @@ -52,9 +52,9 @@ def generate_launch_description(): description="Whether simulation is used", ) - user_led_animations_file = LaunchConfiguration("user_led_animations_file") - declare_user_led_animations_file_arg = DeclareLaunchArgument( - "user_led_animations_file", + user_led_animations_path = LaunchConfiguration("user_led_animations_path") + declare_user_led_animations_path_arg = DeclareLaunchArgument( + "user_led_animations_path", default_value="", description="Path to a YAML file with a description of the user defined animations.", ) @@ -82,8 +82,8 @@ def generate_launch_description(): name="lights_controller", namespace=namespace, parameters=[ - {"led_config_file": led_config_file}, - {"user_led_animations_file": user_led_animations_file}, + {"animations_config_path": animations_config_path}, + {"user_led_animations_path": user_led_animations_path}, ], extra_arguments=[ {"use_intra_process_comms": True}, @@ -95,10 +95,10 @@ def generate_launch_description(): ) actions = [ - declare_led_config_file_arg, + declare_animations_config_path_arg, declare_namespace_arg, declare_use_sim_arg, - declare_user_led_animations_file_arg, + declare_user_led_animations_path_arg, lights_container, ] diff --git a/panther_lights/src/lights_controller_node.cpp b/panther_lights/src/lights_controller_node.cpp index fb2d461f5..d77443ef7 100644 --- a/panther_lights/src/lights_controller_node.cpp +++ b/panther_lights/src/lights_controller_node.cpp @@ -48,23 +48,23 @@ LightsControllerNode::LightsControllerNode(const rclcpp::NodeOptions & options) using namespace std::placeholders; - this->declare_parameter("led_config_file"); - this->declare_parameter("user_led_animations_file", ""); + this->declare_parameter("animations_config_path"); + this->declare_parameter("user_led_animations_path", ""); this->declare_parameter("controller_freq", 50.0); - const auto led_config_file = this->get_parameter("led_config_file").as_string(); - const auto user_led_animations_file = this->get_parameter("user_led_animations_file").as_string(); + const auto animations_config_path = this->get_parameter("animations_config_path").as_string(); + const auto user_led_animations_path = this->get_parameter("user_led_animations_path").as_string(); const float controller_freq = this->get_parameter("controller_freq").as_double(); - YAML::Node led_config_desc = YAML::LoadFile(led_config_file); + YAML::Node led_config_desc = YAML::LoadFile(animations_config_path); InitializeLEDPanels(led_config_desc["panels"]); InitializeLEDSegments(led_config_desc["segments"], controller_freq); InitializeLEDSegmentsMap(led_config_desc["segments_map"]); LoadDefaultAnimations(led_config_desc["led_animations"]); - if (user_led_animations_file != "") { - LoadUserAnimations(user_led_animations_file); + if (user_led_animations_path != "") { + LoadUserAnimations(user_led_animations_path); } segment_converter_ = std::make_shared(); @@ -159,12 +159,12 @@ void LightsControllerNode::LoadDefaultAnimations(const YAML::Node & animations_d RCLCPP_INFO(this->get_logger(), "Loaded default animations."); } -void LightsControllerNode::LoadUserAnimations(const std::string & user_led_animations_file) +void LightsControllerNode::LoadUserAnimations(const std::string & user_led_animations_path) { RCLCPP_DEBUG(this->get_logger(), "Loading user's animations."); try { - YAML::Node user_led_animations = YAML::LoadFile(user_led_animations_file); + YAML::Node user_led_animations = YAML::LoadFile(user_led_animations_path); auto user_animations = panther_utils::GetYAMLKeyValue>( user_led_animations, "user_animations"); diff --git a/panther_lights/test/integration/panther_lights.test.py b/panther_lights/test/integration/panther_lights.test.py index fafd6bf19..bcc52087a 100644 --- a/panther_lights/test/integration/panther_lights.test.py +++ b/panther_lights/test/integration/panther_lights.test.py @@ -36,14 +36,14 @@ def generate_test_description(): - led_config_file = ( + animations_config_path = ( PathJoinSubstitution([FindPackageShare("panther_lights"), "config", "led_config.yaml"]), ) lights_controller_node = Node( package="panther_lights", executable="lights_controller_node", - parameters=[{"led_config_file": led_config_file}], + parameters=[{"animations_config_path": animations_config_path}], ) lights_driver_node = Node( diff --git a/panther_lights/test/unit/test_lights_controller_node.cpp b/panther_lights/test/unit/test_lights_controller_node.cpp index 7a27f3a40..37fcff3bb 100644 --- a/panther_lights/test/unit/test_lights_controller_node.cpp +++ b/panther_lights/test/unit/test_lights_controller_node.cpp @@ -77,18 +77,18 @@ class TestLightsControllerNode : public testing::Test static constexpr char kTestSegmentName[] = "test"; static constexpr char kTestSegmentLedRange[] = "0-9"; - std::filesystem::path led_config_file_; + std::filesystem::path animations_config_path_; std::shared_ptr lights_controller_node_; }; TestLightsControllerNode::TestLightsControllerNode() { - led_config_file_ = testing::TempDir() + "/led_config.yaml"; + animations_config_path_ = testing::TempDir() + "/led_config.yaml"; - CreateLEDConfig(led_config_file_); + CreateLEDConfig(animations_config_path_); std::vector params; - params.push_back(rclcpp::Parameter("led_config_file", led_config_file_)); + params.push_back(rclcpp::Parameter("animations_config_path", animations_config_path_)); rclcpp::NodeOptions options; options.parameter_overrides(params); @@ -96,7 +96,10 @@ TestLightsControllerNode::TestLightsControllerNode() lights_controller_node_ = std::make_shared(options); } -TestLightsControllerNode::~TestLightsControllerNode() { std::filesystem::remove(led_config_file_); } +TestLightsControllerNode::~TestLightsControllerNode() +{ + std::filesystem::remove(animations_config_path_); +} void TestLightsControllerNode::CreateLEDConfig(const std::filesystem::path file_path) { diff --git a/panther_manager/CONFIGURATION.md b/panther_manager/CONFIGURATION.md index 3317e43a2..6454c886a 100644 --- a/panther_manager/CONFIGURATION.md +++ b/panther_manager/CONFIGURATION.md @@ -5,7 +5,7 @@ For more information regarding shutdown behavior, refer to `ShutdownSingleHost` BT node in the [Actions](#actions) section. An example of a shutdown hosts YAML file can be found below. ``` yaml -# My shutdown_hosts_config.yaml +# My shutdown_hosts.yaml hosts: # Intel NUC, user computer - ip: 10.15.20.3 diff --git a/panther_manager/README.md b/panther_manager/README.md index f58327f03..718abece8 100644 --- a/panther_manager/README.md +++ b/panther_manager/README.md @@ -17,7 +17,7 @@ This package contains: - [`shutdown.xml`](./behavior_trees/shutdown.xml): BehaviorTree for initiating shutdown procedures. - [`lights_manager.yaml`](./config/lights_manager.yaml): Contains parameters for the `lights_manager` node. - [`safety_manager.yaml`](./config/safety_manager.yaml): Contains parameters for the `safety_manager` node. -- [`shutdown_hosts_config.yaml`](./config/shutdown_hosts_config.yaml): List with all hosts to request shutdown. +- [`shutdown_hosts.yaml`](./config/shutdown_hosts.yaml): List with all hosts to request shutdown. ## ROS Nodes diff --git a/panther_manager/config/shutdown_hosts_config.yaml b/panther_manager/config/shutdown_hosts.yaml similarity index 100% rename from panther_manager/config/shutdown_hosts_config.yaml rename to panther_manager/config/shutdown_hosts.yaml diff --git a/panther_manager/launch/manager.launch.py b/panther_manager/launch/manager.launch.py index 510fb2834..0aaf5385b 100644 --- a/panther_manager/launch/manager.launch.py +++ b/panther_manager/launch/manager.launch.py @@ -62,7 +62,7 @@ def generate_launch_description(): [ FindPackageShare("panther_manager"), "config", - "shutdown_hosts_config.yaml", + "shutdown_hosts.yaml", ] ), description="Path to file with list of hosts to request shutdown.",