PX4 ROS 2 Interface Library
Library to interface with PX4 from a companion computer using ROS 2
Loading...
Searching...
No Matches
vehicle_status.hpp
1/****************************************************************************
2 * Copyright (c) 2023-2024 PX4 Development Team.
3 * SPDX-License-Identifier: BSD-3-Clause
4 ****************************************************************************/
5
6#pragma once
7
8#include <px4_msgs/msg/vehicle_status.hpp>
9#include <px4_ros2/common/context.hpp>
10#include <px4_ros2/utils/subscription.hpp>
11
12namespace px4_ros2
13{
23class VehicleStatus : public Subscription<px4_msgs::msg::VehicleStatus>
24{
25public:
26 explicit VehicleStatus(Context & context)
27 : Subscription<px4_msgs::msg::VehicleStatus>(context, "fmu/out/vehicle_status") {}
28
34 bool armed() const
35 {
36 return last().arming_state == px4_msgs::msg::VehicleStatus::ARMING_STATE_ARMED;
37 }
38
45 uint8_t navState() const
46 {
47 return last().nav_state;
48 }
49
50};
51
53} /* namespace px4_ros2 */
Definition context.hpp:20
Provides a subscription to arbitrary ROS topics.
Definition subscription.hpp:23
const px4_msgs::msg::VehicleStatus & last() const
Get the last-received message.
Definition subscription.hpp:58
Provides access to the vehicle's status.
Definition vehicle_status.hpp:24
uint8_t navState() const
Get the vehicle's current active flight mode.
Definition vehicle_status.hpp:45
bool armed() const
Get the vehicle's arming status.
Definition vehicle_status.hpp:34