diff --git a/src/drone_controls/src/PositionChanger.cpp b/src/drone_controls/src/PositionChanger.cpp index 1858271e..4f9ab0d1 100644 --- a/src/drone_controls/src/PositionChanger.cpp +++ b/src/drone_controls/src/PositionChanger.cpp @@ -66,9 +66,6 @@ public: auto status = future.wait_for(1s); if (status == std::future_status::ready) { - // uncomment below line if using Empty() message - // RCLCPP_INFO(this->get_logger(), "Result: success"); - // comment below line if using Empty() message RCLCPP_INFO(this->get_logger(), "Vehicle control mode set result: %d", future.get()->success); } else @@ -76,13 +73,26 @@ public: RCLCPP_INFO(this->get_logger(), "Service In-Progress..."); } } + + void trajectory_message_callback(rclcpp::Client::SharedFuture future) + { + auto status = future.wait_for(1s); + if (status == std::future_status::ready) + { + RCLCPP_INFO(this->get_logger(), "Seet trajectory set result: %d", future.get()->success); + } + else + { + RCLCPP_INFO(this->get_logger(), "Service In-Progress..."); + } + } void send_trajectory_message() { - this->trajectory_request->x = this->current_speed_x; - this->trajectory_request->y = this->current_speed_y; - this->trajectory_request->z = this->current_z_speed; + this->trajectory_request->values[0] = this->current_speed_x; + this->trajectory_request->values[1] = this->current_speed_y; + this->trajectory_request->values[2] = this->current_z_speed; this->trajectory_request->yaw = this->current_yaw; - auto trajectory_response = this->trajectory_client->async_send_request(this->trajectory_request); + auto trajectory_response = this->trajectory_client->async_send_request(this->trajectory_requeststd::bind(&PositionChanger::trajectory_message_callback, this, std::placeholders::_1)); if (rclcpp::spin_until_future_complete(this, trajectory_response) == rclcpp::FutureReturnCode::SUCCESS)