PX4 / PX4-Autopilot

PX4 Autopilot Software
https://px4.io
BSD 3-Clause "New" or "Revised" License
8.53k stars 13.52k forks source link

Detect if drone is in air on offboard mode #18982

Open DevJav opened 2 years ago

DevJav commented 2 years ago

I have a self made state machine implmented with ROS for controlling missions. One of the states is "armed", and I'm trying to find a way to detect that the drone did the take off after sending a waypoint to jump to a new state. I tried by checking the z-axis but it may not be the most efficient way to check it as you may not always take off starting from 0.

antonio-sc66 commented 2 years ago

Hi @DevJav, I think that checking the _landedstate field of the ExtendedState message should be enough. You need to make sure its value is _LANDED_STATE_INAIR

http://docs.ros.org/en/noetic/api/mavros_msgs/html/msg/ExtendedState.html

DevJav commented 2 years ago

Hi @antonio-sc66. I didn't know about that message so thank you!

However I've been making some experiments with the simulator and it seems like if you add a waypoint to make it take off, it changes to LANDED_STATE_IN_AIR immediately, which it's not true as it takes some time before it actually stops touching the ground.

benjinne commented 2 years ago

Maybe the takeoff_status topic is what you're looking for. https://github.com/PX4/PX4-Autopilot/blob/master/msg/takeoff_status.msg It gets updated in the mc_pos_control module. This is assuming you're using ROS2/RTPS. I'm not sure about mavros or mavsdk

DevJav commented 2 years ago

@benjinne I'm actually using ROS1 with mavros and this topic dosn't seem to be published :(

ytaskiran commented 2 years ago

I do not know your exact use case and what is your aim but here are my suggestions @DevJav :

dasol-aero commented 1 year ago

@DevJav it's been a long time, but I'm writing a comment. You can try /mavros/extended_state topic, and its message type is mavros_msgs/ExtendedState. I used this topic in ROS1 Melodic and Noetic.

Reference Links http://docs.ros.org/en/api/mavros_msgs/html/msg/ExtendedState.html http://wiki.ros.org/mavros