From 9faab231e79f9f05ddc7d81e108d7c16f5a79df6 Mon Sep 17 00:00:00 2001 From: Sem van der Hoeven Date: Fri, 12 May 2023 12:19:03 +0200 Subject: [PATCH] change checking of set bit --- src/px4_connection/src/heartbeat.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/px4_connection/src/heartbeat.cpp b/src/px4_connection/src/heartbeat.cpp index 09718930..2a99a67c 100644 --- a/src/px4_connection/src/heartbeat.cpp +++ b/src/px4_connection/src/heartbeat.cpp @@ -82,17 +82,17 @@ private: void publish_new_control_mode() { auto msg = drone_services::msg::DroneControlMode(); - if ((this->control_mode >> CONTROL_ATTITUDE_POS) & 1) + if (this->control_mode & (1 << CONTROL_ATTITUDE_POS)) { msg.control_mode = CONTROL_MODE_ATTITUDE; RCLCPP_INFO(this->get_logger(), "set control mode to attitude"); } - else if ((this->control_mode >> CONTROL_VELOCITY_POS) & 1) + else if (this->control_mode & (1 << CONTROL_VELOCITY_POS)) { msg.control_mode = CONTROL_MODE_VELOCITY; RCLCPP_INFO(this->get_logger(), "set control mode to velocity"); } - else if ((this->control_mode >> CONTROL_POSITION_POS) & 1) + else if (this->control_mode & (1 << CONTROL_POSITION_POS)) { msg.control_mode = CONTROL_MODE_POSITION; RLCPP_INFO(this->get_logger(), "set control mode to position");