From ac8a945006182bf7f4be138c5fd3580d57ccfc84 Mon Sep 17 00:00:00 2001 From: GuillaumeLaine Date: Thu, 31 Oct 2024 15:17:54 +0100 Subject: [PATCH] apply review suggestions --- px4_ros2_cpp/CMakeLists.txt | 5 --- .../px4_ros2/vehicle_state/battery.hpp | 3 +- .../px4_ros2/vehicle_state/home_position.hpp | 3 +- .../px4_ros2/vehicle_state/land_detected.hpp | 41 ++----------------- .../px4_ros2/vehicle_state/vehicle_status.hpp | 4 +- .../px4_ros2/vehicle_state/vtol_status.hpp | 5 ++- px4_ros2_cpp/src/vehicle_state/battery.cpp | 18 -------- .../src/vehicle_state/home_position.cpp | 18 -------- .../src/vehicle_state/land_detected.cpp | 18 -------- .../src/vehicle_state/vehicle_status.cpp | 18 -------- .../src/vehicle_state/vtol_status.cpp | 18 -------- 11 files changed, 14 insertions(+), 137 deletions(-) delete mode 100644 px4_ros2_cpp/src/vehicle_state/battery.cpp delete mode 100644 px4_ros2_cpp/src/vehicle_state/home_position.cpp delete mode 100644 px4_ros2_cpp/src/vehicle_state/land_detected.cpp delete mode 100644 px4_ros2_cpp/src/vehicle_state/vehicle_status.cpp delete mode 100644 px4_ros2_cpp/src/vehicle_state/vtol_status.cpp diff --git a/px4_ros2_cpp/CMakeLists.txt b/px4_ros2_cpp/CMakeLists.txt index 170b24a..efb2268 100644 --- a/px4_ros2_cpp/CMakeLists.txt +++ b/px4_ros2_cpp/CMakeLists.txt @@ -80,11 +80,6 @@ add_library(px4_ros2_cpp src/odometry/angular_velocity.cpp src/utils/geodesic.cpp src/utils/map_projection_impl.cpp - src/vehicle_state/battery.cpp - src/vehicle_state/home_position.cpp - src/vehicle_state/land_detected.cpp - src/vehicle_state/vehicle_status.cpp - src/vehicle_state/vtol_status.cpp ) ament_target_dependencies(px4_ros2_cpp ament_index_cpp Eigen3 rclcpp px4_msgs) diff --git a/px4_ros2_cpp/include/px4_ros2/vehicle_state/battery.hpp b/px4_ros2_cpp/include/px4_ros2/vehicle_state/battery.hpp index 945404f..96d44e9 100644 --- a/px4_ros2_cpp/include/px4_ros2/vehicle_state/battery.hpp +++ b/px4_ros2_cpp/include/px4_ros2/vehicle_state/battery.hpp @@ -24,7 +24,8 @@ namespace px4_ros2 class Battery : public Subscription { public: - explicit Battery(Context & context); + explicit Battery(Context & context) + : Subscription(context, "fmu/out/battery_status") {} /** * @brief Get the vehicle's battery voltage. diff --git a/px4_ros2_cpp/include/px4_ros2/vehicle_state/home_position.hpp b/px4_ros2_cpp/include/px4_ros2/vehicle_state/home_position.hpp index 4aa3d14..de50733 100644 --- a/px4_ros2_cpp/include/px4_ros2/vehicle_state/home_position.hpp +++ b/px4_ros2_cpp/include/px4_ros2/vehicle_state/home_position.hpp @@ -24,7 +24,8 @@ namespace px4_ros2 class HomePosition : public Subscription { public: - explicit HomePosition(Context & context); + explicit HomePosition(Context & context) + : Subscription(context, "fmu/out/home_position") {} /** * @brief Get the vehicle's home position in local coordinates. diff --git a/px4_ros2_cpp/include/px4_ros2/vehicle_state/land_detected.hpp b/px4_ros2_cpp/include/px4_ros2/vehicle_state/land_detected.hpp index b93fed2..2329d39 100644 --- a/px4_ros2_cpp/include/px4_ros2/vehicle_state/land_detected.hpp +++ b/px4_ros2_cpp/include/px4_ros2/vehicle_state/land_detected.hpp @@ -23,50 +23,17 @@ namespace px4_ros2 class LandDetected : public Subscription { public: - explicit LandDetected(Context & context); + explicit LandDetected(Context & context) + : Subscription(context, "fmu/out/vehicle_land_detected") {} /** - * @brief Check if vehicle has made ground contact, but is not landed (stage 1). - * - * @return true if ground contact, false otherwise - */ - bool groundContact() const - { - const px4_msgs::msg::VehicleLandDetected & land_detected = last(); - return land_detected.ground_contact; - } - - /** - * @brief Check if vehicle has maybe landed (stage 2). - * - * @return true if maybe landed, false otherwise - */ - bool maybeLanded() const - { - const px4_msgs::msg::VehicleLandDetected & land_detected = last(); - return land_detected.maybe_landed; - } - - /** - * @brief Check if vehicle is landed on the ground (stage 3). + * @brief Check if vehicle is landed on the ground. * * @return true if landed, false otherwise */ bool landed() const { - const px4_msgs::msg::VehicleLandDetected & land_detected = last(); - return land_detected.landed; - } - - /** - * @brief Check if vehicle is descending. - * - * @return true if descending, false otherwise - */ - bool inDescend() const - { - const px4_msgs::msg::VehicleLandDetected & land_detected = last(); - return land_detected.in_descend; + return last().landed; } }; diff --git a/px4_ros2_cpp/include/px4_ros2/vehicle_state/vehicle_status.hpp b/px4_ros2_cpp/include/px4_ros2/vehicle_state/vehicle_status.hpp index 35a9fe4..bf483a2 100644 --- a/px4_ros2_cpp/include/px4_ros2/vehicle_state/vehicle_status.hpp +++ b/px4_ros2_cpp/include/px4_ros2/vehicle_state/vehicle_status.hpp @@ -23,7 +23,8 @@ namespace px4_ros2 class VehicleStatus : public Subscription { public: - explicit VehicleStatus(Context & context); + explicit VehicleStatus(Context & context) + : Subscription(context, "fmu/out/vehicle_status") {} /** * @brief Get the vehicle's arming status. @@ -39,6 +40,7 @@ class VehicleStatus : public Subscription * @brief Get the vehicle's current active flight mode. * * @return the int value describing the mode + * @see navigation state values: https://github.com/PX4/PX4-Autopilot/blob/v1.15.0/msg/VehicleStatus.msg#L34-L65 */ uint8_t navState() const { diff --git a/px4_ros2_cpp/include/px4_ros2/vehicle_state/vtol_status.hpp b/px4_ros2_cpp/include/px4_ros2/vehicle_state/vtol_status.hpp index 6f48852..50ea559 100644 --- a/px4_ros2_cpp/include/px4_ros2/vehicle_state/vtol_status.hpp +++ b/px4_ros2_cpp/include/px4_ros2/vehicle_state/vtol_status.hpp @@ -23,10 +23,11 @@ namespace px4_ros2 class VtolStatus : public Subscription { public: - explicit VtolStatus(Context & context); + explicit VtolStatus(Context & context) + : Subscription(context, "fmu/out/vtol_vehicle_status") {} /** - * @brief Check if VTOL is in an undefined state. + * @brief Check if vehicle is in an undefined state. This indicates the vehicle is not a VTOL. * * @return true if undefined state, false otherwise. */ diff --git a/px4_ros2_cpp/src/vehicle_state/battery.cpp b/px4_ros2_cpp/src/vehicle_state/battery.cpp deleted file mode 100644 index 6c23da9..0000000 --- a/px4_ros2_cpp/src/vehicle_state/battery.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************** - * Copyright (c) 2023-2024 PX4 Development Team. - * SPDX-License-Identifier: BSD-3-Clause - ****************************************************************************/ - -#include - -namespace px4_ros2 -{ - -Battery::Battery(Context & context) -: Subscription(context, "fmu/out/battery_status") -{ - RequirementFlags requirements{}; - context.setRequirement(requirements); -} - -} // namespace px4_ros2 diff --git a/px4_ros2_cpp/src/vehicle_state/home_position.cpp b/px4_ros2_cpp/src/vehicle_state/home_position.cpp deleted file mode 100644 index 0bc1454..0000000 --- a/px4_ros2_cpp/src/vehicle_state/home_position.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************** - * Copyright (c) 2023-2024 PX4 Development Team. - * SPDX-License-Identifier: BSD-3-Clause - ****************************************************************************/ - -#include - -namespace px4_ros2 -{ - -HomePosition::HomePosition(Context & context) -: Subscription(context, "fmu/out/home_position") -{ - RequirementFlags requirements{}; - context.setRequirement(requirements); -} - -} // namespace px4_ros2 diff --git a/px4_ros2_cpp/src/vehicle_state/land_detected.cpp b/px4_ros2_cpp/src/vehicle_state/land_detected.cpp deleted file mode 100644 index c5b42d0..0000000 --- a/px4_ros2_cpp/src/vehicle_state/land_detected.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************** - * Copyright (c) 2023-2024 PX4 Development Team. - * SPDX-License-Identifier: BSD-3-Clause - ****************************************************************************/ - -#include - -namespace px4_ros2 -{ - -LandDetected::LandDetected(Context & context) -: Subscription(context, "fmu/out/vehicle_land_detected") -{ - RequirementFlags requirements{}; - context.setRequirement(requirements); -} - -} // namespace px4_ros2 diff --git a/px4_ros2_cpp/src/vehicle_state/vehicle_status.cpp b/px4_ros2_cpp/src/vehicle_state/vehicle_status.cpp deleted file mode 100644 index 38a8cc5..0000000 --- a/px4_ros2_cpp/src/vehicle_state/vehicle_status.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************** - * Copyright (c) 2023-2024 PX4 Development Team. - * SPDX-License-Identifier: BSD-3-Clause - ****************************************************************************/ - -#include - -namespace px4_ros2 -{ - -VehicleStatus::VehicleStatus(Context & context) -: Subscription(context, "fmu/out/vehicle_status") -{ - RequirementFlags requirements{}; - context.setRequirement(requirements); -} - -} // namespace px4_ros2 diff --git a/px4_ros2_cpp/src/vehicle_state/vtol_status.cpp b/px4_ros2_cpp/src/vehicle_state/vtol_status.cpp deleted file mode 100644 index 7660862..0000000 --- a/px4_ros2_cpp/src/vehicle_state/vtol_status.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************** - * Copyright (c) 2023-2024 PX4 Development Team. - * SPDX-License-Identifier: BSD-3-Clause - ****************************************************************************/ - -#include - -namespace px4_ros2 -{ - -VtolStatus::VtolStatus(Context & context) -: Subscription(context, "fmu/out/vtol_vehicle_status") -{ - RequirementFlags requirements{}; - context.setRequirement(requirements); -} - -} // namespace px4_ros2