19 #include <mavros_msgs/ADSBVehicle.h> 22 namespace extra_plugins {
23 using mavlink::common::ADSB_EMITTER_TYPE;
24 using mavlink::common::ADSB_ALTITUDE_TYPE;
58 void handle_adsb(
const mavlink::mavlink_message_t *msg, mavlink::common::msg::ADSB_VEHICLE &adsb)
60 auto adsb_msg = boost::make_shared<mavros_msgs::ADSBVehicle>();
91 adsb_msg->ICAO_address = adsb.ICAO_address;
93 adsb_msg->latitude = adsb.lat / 1e7;
94 adsb_msg->longitude = adsb.lon / 1e7;
95 adsb_msg->altitude = adsb.altitude / 1e3;
96 adsb_msg->altitude_type = adsb.altitude_type;
97 adsb_msg->heading = adsb.heading / 1e2;
98 adsb_msg->hor_velocity = adsb.hor_velocity / 1e2;
99 adsb_msg->ver_velocity = adsb.ver_velocity / 1e2;
100 adsb_msg->altitude_type = adsb.altitude_type;
101 adsb_msg->emitter_type = adsb.emitter_type;
103 adsb_msg->flags = adsb.flags;
104 adsb_msg->squawk = adsb.squawk;
107 ROS_DEBUG_STREAM_NAMED(
"adsb",
"ADSB: recv type: " << utils::to_string_enum<ADSB_ALTITUDE_TYPE>(adsb.altitude_type)
108 <<
" emitter: " << utils::to_string_enum<ADSB_EMITTER_TYPE>(adsb.emitter_type)
109 <<
" flags: 0x" << std::hex << adsb.flags);
116 mavlink::common::msg::ADSB_VEHICLE adsb{};
126 adsb.ICAO_address = req->ICAO_address;
128 adsb.lat = req->latitude * 1e7;
129 adsb.lon = req->longitude * 1e7;
130 adsb.altitude = req->altitude * 1e3;
131 adsb.altitude_type = req->altitude_type;
132 adsb.heading = req->heading * 1e2;
133 adsb.hor_velocity = req->hor_velocity * 1e2;
134 adsb.ver_velocity = req->ver_velocity * 1e2;
135 adsb.altitude_type = req->altitude_type;
136 adsb.emitter_type = req->emitter_type;
137 adsb.tslc = req->tslc.sec;
138 adsb.flags = req->flags;
139 adsb.squawk = req->squawk;
142 ROS_DEBUG_STREAM_NAMED(
"adsb",
"ADSB: send type: " << utils::to_string_enum<ADSB_ALTITUDE_TYPE>(adsb.altitude_type)
143 <<
" emitter: " << utils::to_string_enum<ADSB_EMITTER_TYPE>(adsb.emitter_type)
144 <<
" flags: 0x" << std::hex << adsb.flags);
std::shared_ptr< MAVConnInterface const > ConstPtr
#define ROS_DEBUG_STREAM_NAMED(name, args)
void publish(const boost::shared_ptr< M > &message) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
HandlerInfo make_handler(const mavlink::msgid_t id, void(_C::*fn)(const mavlink::mavlink_message_t *msg, const mavconn::Framing framing))
void adsb_cb(const mavros_msgs::ADSBVehicle::ConstPtr &req)
#define UAS_FCU(uasobjptr)
void set_string_z(std::array< char, _N > &a, const std::string &s)
void handle_adsb(const mavlink::mavlink_message_t *msg, mavlink::common::msg::ADSB_VEHICLE &adsb)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
std::vector< HandlerInfo > Subscriptions
void initialize(UAS &uas_)
Subscriptions get_subscriptions()
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
std::string to_string(const std::array< char, _N > &a)
void initialize(UAS &uas_)