23 #include <type_traits> 33 #include <GeographicLib/Geoid.hpp> 35 #include <sensor_msgs/Imu.h> 36 #include <sensor_msgs/NavSatFix.h> 42 #define UAS_FCU(uasobjptr) \ 43 ((uasobjptr)->fcu_link) 48 #define UAS_DIAG(uasobjptr) \ 49 ((uasobjptr)->diag_updater) 74 using MAV_CAP = mavlink::common::MAV_PROTOCOL_CAPABILITY;
80 using lock_guard = std::lock_guard<std::recursive_mutex>;
108 void update_heartbeat(uint8_t type_, uint8_t autopilot_, uint8_t base_mode_);
124 std::underlying_type<MAV_TYPE>::type type_ =
type;
125 return static_cast<MAV_TYPE>(type_);
132 std::underlying_type<MAV_AUTOPILOT>::type autopilot_ =
autopilot;
170 inline void set_tgt(uint8_t sys, uint8_t comp) {
227 float eph,
float epv,
228 int fix_type,
int satellites_visible);
231 void get_gps_epts(
float &eph,
float &epv,
int &fix_type,
int &satellites_visible);
243 std::shared_ptr<GeographicLib::Geoid>
egm96_5;
253 return GeographicLib::Geoid::GEOIDTOELLIPSOID * (*egm96_5)(lla->latitude, lla->longitude);
266 return GeographicLib::Geoid::ELLIPSOIDTOGEOID * (*egm96_5)(lla->latitude, lla->longitude);
286 void add_static_transform(
const std::string &frame_id,
const std::string &child_id,
const Eigen::Affine3d &tr, std::vector<geometry_msgs::TransformStamped>& vector);
325 static_assert(std::is_enum<T>::value,
"Only query capabilities using the UAS::MAV_CAP enum.");
335 template<
typename ... Ts>
338 std::initializer_list<bool> capabilities_list{has_capability<Ts>(capabilities) ...};
339 for (
auto has_cap : capabilities_list) ret &= has_cap;
376 std_msgs::Header out;
377 out.frame_id = frame_id;
387 template<
typename _T>
445 bool cmode_from_str(std::string cmode_str, uint32_t &custom_mode);
bool is_connected()
Return connection status.
std::atomic< uint8_t > autopilot
bool cmode_from_str(std::string cmode_str, uint32_t &custom_mode)
Lookup custom mode for given string.
mavlink::minimal::MAV_TYPE MAV_TYPE
mavconn::MAVConnInterface::Ptr fcu_link
MAVLink FCU device conection.
std_msgs::Header synchronized_header(const std::string &frame_id, const T time_stamp)
Create message header from time_boot_ms or time_usec stamps and frame_id.
sensor_msgs::NavSatFix::Ptr gps_fix
double ellipsoid_to_geoid_height(T lla)
Conversion from height above ellipsoid (WGS-84) to height above geoid (AMSL)
void add_capabilities_change_handler(CapabilitiesCb cb)
Adds a function to the capabilities callback queue.
bool has_capabilities(Ts...capabilities)
Function to check if the flight controller has a set of capabilities.
void publish_static_transform(const std::string &frame_id, const std::string &child_id, const Eigen::Affine3d &tr)
Publishes static transform.
tf2_ros::TransformListener tf2_listener
geometry_msgs::Quaternion get_attitude_orientation_enu()
Get Attitude orientation quaternion.
uint64_t get_time_offset(void)
MAV_AUTOPILOT get_autopilot()
Returns autopilot type.
mavlink::minimal::MAV_STATE MAV_STATE
void update_connection_status(bool conn_)
void set_time_offset(uint64_t offset_ns)
diagnostic_updater::Updater diag_updater
Mavros diagnostic updater.
sensor_msgs::Imu::Ptr imu_enu_data
void msg_set_target(_T &msg)
bool has_capability(T capability)
Function to check if the flight controller has a capability.
tf2_ros::StaticTransformBroadcaster tf2_static_broadcaster
bool get_hil_state()
Returns HIL status.
std::function< void(bool)> ConnectionCb
tf2_ros::TransformBroadcaster tf2_broadcaster
geometry_msgs::Quaternion get_attitude_orientation_ned()
Get Attitude orientation quaternion.
void update_capabilities(bool known, uint64_t caps=0)
Update the capabilities if they've changed every VERSION/timeout.
void update_attitude_imu_enu(sensor_msgs::Imu::Ptr &imu)
Store IMU data [ENU].
uint8_t get_tgt_system()
Return communication target system.
std::atomic< uint8_t > type
std::string str_mode_v10(uint8_t base_mode, uint32_t custom_mode)
Represent FCU mode as string.
tf2_ros::Buffer tf2_buffer
std::shared_ptr< GeographicLib::Geoid > egm96_5
Geoid dataset used to convert between AMSL and WGS-84.
void add_connection_change_handler(ConnectionCb cb)
Add connection change handler callback.
bool is_ardupilotmega()
Check that FCU is APM.
ros::Time synchronise_stamp(uint32_t time_boot_ms)
Compute FCU message time from time_boot_ms or time_usec field.
void set_timesync_mode(timesync_mode mode)
mavlink::common::MAV_PROTOCOL_CAPABILITY MAV_CAP
mavlink::minimal::MAV_MODE_FLAG MAV_MODE_FLAG
void set_tgt(uint8_t sys, uint8_t comp)
geometry_msgs::Vector3 get_attitude_angular_velocity_ned()
Get angular velocity from IMU data.
std::lock_guard< std::recursive_mutex > lock_guard
std::atomic< bool > connected
std::atomic< bool > fcu_caps_known
std::vector< CapabilitiesCb > capabilities_cb_vec
bool get_armed()
Returns arming status.
MAV_TYPE get_type()
Returns vehicle type.
std::function< void(MAV_CAP)> CapabilitiesCb
sensor_msgs::Imu::Ptr get_attitude_imu_ned()
Get IMU data [NED].
bool is_my_target(uint8_t sysid, uint8_t compid)
Check that sys/comp id's is my target.
std::recursive_mutex mutex
void update_heartbeat(uint8_t type_, uint8_t autopilot_, uint8_t base_mode_)
std::unique_lock< std::recursive_mutex > unique_lock
sensor_msgs::NavSatFix::Ptr get_gps_fix()
Retunrs last GPS RAW message.
mavlink::minimal::MAV_AUTOPILOT MAV_AUTOPILOT
timesync_mode get_timesync_mode(void)
uint64_t get_capabilities()
std::atomic< uint8_t > base_mode
bool is_my_target(uint8_t sysid)
Check that system id is my target.
sensor_msgs::Imu::Ptr imu_ned_data
void update_attitude_imu_ned(sensor_msgs::Imu::Ptr &imu)
Store IMU data [NED].
std::atomic< uint64_t > time_offset
sensor_msgs::Imu::Ptr get_attitude_imu_enu()
Get IMU data [ENU].
Frame transformation utilities.
bool is_px4()
Check that FCU is PX4.
void update_gps_fix_epts(sensor_msgs::NavSatFix::Ptr &fix, float eph, float epv, int fix_type, int satellites_visible)
Store GPS RAW data.
std::atomic< uint64_t > fcu_capabilities
uint8_t get_tgt_component()
Return communication target component.
geometry_msgs::Vector3 get_attitude_angular_velocity_enu()
Get angular velocity from IMU data.
double geoid_to_ellipsoid_height(T lla)
Conversion from height above geoid (AMSL) to height above ellipsoid (WGS-84)
void add_static_transform(const std::string &frame_id, const std::string &child_id, const Eigen::Affine3d &tr, std::vector< geometry_msgs::TransformStamped > &vector)
Add static transform. To publish all static transforms at once, we stack them in a std::vector...
int gps_satellites_visible
std::vector< ConnectionCb > connection_cb_vec
constexpr std::underlying_type< _T >::type enum_value(_T e)
void get_gps_epts(float &eph, float &epv, int &fix_type, int &satellites_visible)
Returns EPH, EPV, Fix type and satellites visible.
std::shared_ptr< MAVConnInterface > Ptr