From 4daf79cdc021ddee11f6fa3e82c1114a93db3d69 Mon Sep 17 00:00:00 2001 From: Sem van der Hoeven Date: Thu, 8 Jun 2023 21:21:12 +0200 Subject: [PATCH] add land service --- api/views/index.ejs | 6 ++++-- src/api_communication/api_communication/api_listener.py | 9 +++++---- src/drone_controls/src/PositionChanger.cpp | 8 ++++++++ src/drone_services/srv/Land.srv | 2 ++ 4 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 src/drone_services/srv/Land.srv diff --git a/api/views/index.ejs b/api/views/index.ejs index 16cc2e65..0d3724b7 100644 --- a/api/views/index.ejs +++ b/api/views/index.ejs @@ -65,6 +65,7 @@

Current speed

Current position

+

Height

Failsafe not activated

lidar_subscription = this->create_subscription("/drone/object_detection", qos, std::bind(&PositionChanger::handle_lidar_message, this, std::placeholders::_1)); + this->height_subscription = this->create_subscription("/drone/height", qos, std::bind(&PositionChanger::handle_height_message, this, std::placeholders::_1)); // vehicle_local_position_subscription_ = this->create_subscription("/fmu/out/vehicle_local_position", qos, std::bind(&PX4Controller::on_local_position_receive, this, std::placeholders::_1)); this->odometry_subscription = this->create_subscription("/fmu/out/vehicle_odometry", qos, std::bind(&PositionChanger::handle_odometry_message, this, std::placeholders::_1)); this->move_position_service = this->create_service("/drone/move_position", std::bind(&PositionChanger::handle_move_position_request, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); @@ -270,6 +271,11 @@ public: apply_collision_weights(); } + void handle_height_message(const drone_services::msg::HeightData::SharedPtr message) + { + this->current_height = message->height; + } + /** * @brief Callback function for receiving new LIDAR data * @@ -462,6 +468,8 @@ private: float current_speed_x = 0; float current_speed_y = 0; float current_speed_z = 0; + float current_height = 0; + bool is_landing = false; bool move_direction_allowed[4] = {true}; // whether the drone can move in a certain direction float collision_prevention_weights[4] = {0}; // the amount to move away from an object in a certain direction if the drone is too close bool failsafe_enabled = false; diff --git a/src/drone_services/srv/Land.srv b/src/drone_services/srv/Land.srv new file mode 100644 index 00000000..bdc6893e --- /dev/null +++ b/src/drone_services/srv/Land.srv @@ -0,0 +1,2 @@ +--- +bool is_landing \ No newline at end of file