Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions msg/TransponderReport.msg
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,20 @@ uint16 flags # Flags to indicate various statuses including valid data fields
uint16 squawk # Squawk code
uint8[18] uas_id # Unique UAS ID

# ADSB flags
# ADSB flags, bit values match MAVLink's ADSB_FLAGS enum (common.xml)
uint16 PX4_ADSB_FLAGS_VALID_COORDS = 1
uint16 PX4_ADSB_FLAGS_VALID_ALTITUDE = 2
uint16 PX4_ADSB_FLAGS_VALID_HEADING = 4
uint16 PX4_ADSB_FLAGS_VALID_VELOCITY = 8
uint16 PX4_ADSB_FLAGS_VALID_CALLSIGN = 16
uint16 PX4_ADSB_FLAGS_VALID_SQUAWK = 32
uint16 PX4_ADSB_FLAGS_RETRANSLATE = 256
uint16 PX4_ADSB_FLAGS_SIMULATED = 64
uint16 PX4_ADSB_FLAGS_VERTICAL_VELOCITY_VALID = 128
uint16 PX4_ADSB_FLAGS_BARO_VALID = 256
uint16 PX4_ADSB_FLAGS_SOURCE_UAT = 32768

# PX4-internal flag, not part of the MAVLink ADSB_FLAGS bitmask: uses a bit MAVLink leaves unused
uint16 PX4_ADSB_FLAGS_RETRANSLATE = 512

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could make it the last bit (32768) for now to not change value until there's a conflict with the last bit in MAVLink.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last bit is used in MAVLink 🤯 Someone else had the same broken strategy 👀
https://github.com/mavlink/mavlink/blob/f9cb1f9e482977446c3dd953a16368d4834c6aa5/message_definitions/v1.0/common.xml#L3665

Should we make it a separate field to avoid future conflicts or is that overengineered? Let me check 👀

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate field works for me as it avoids any future conflicts with the MAVLink enum. Let me know your final recommendation


#ADSB Emitter Data:
#from mavlink/v2.0/common/common.h
Expand Down
8 changes: 8 additions & 0 deletions src/modules/mavlink/mavlink_receiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2885,6 +2885,14 @@ MavlinkReceiver::handle_message_adsb_vehicle(mavlink_message_t *msg)

if (adsb.flags & ADSB_FLAGS_VALID_SQUAWK) { t.flags |= transponder_report_s::PX4_ADSB_FLAGS_VALID_SQUAWK; }

if (adsb.flags & ADSB_FLAGS_SIMULATED) { t.flags |= transponder_report_s::PX4_ADSB_FLAGS_SIMULATED; }

if (adsb.flags & ADSB_FLAGS_VERTICAL_VELOCITY_VALID) { t.flags |= transponder_report_s::PX4_ADSB_FLAGS_VERTICAL_VELOCITY_VALID; }

if (adsb.flags & ADSB_FLAGS_BARO_VALID) { t.flags |= transponder_report_s::PX4_ADSB_FLAGS_BARO_VALID; }

if (adsb.flags & ADSB_FLAGS_SOURCE_UAT) { t.flags |= transponder_report_s::PX4_ADSB_FLAGS_SOURCE_UAT; }

//PX4_INFO("code: %d callsign: %s, vel: %8.4f, tslc: %d", (int)t.ICAO_address, t.callsign, (double)t.hor_velocity, (int)t.tslc);

_transponder_report_pub.publish(t);
Expand Down
8 changes: 8 additions & 0 deletions src/modules/mavlink/streams/ADSB_VEHICLE.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ class MavlinkStreamADSBVehicle : public MavlinkStream

if (pos.flags & transponder_report_s::PX4_ADSB_FLAGS_VALID_SQUAWK) { msg.flags |= ADSB_FLAGS_VALID_SQUAWK; }

if (pos.flags & transponder_report_s::PX4_ADSB_FLAGS_SIMULATED) { msg.flags |= ADSB_FLAGS_SIMULATED; }

if (pos.flags & transponder_report_s::PX4_ADSB_FLAGS_VERTICAL_VELOCITY_VALID) { msg.flags |= ADSB_FLAGS_VERTICAL_VELOCITY_VALID; }

if (pos.flags & transponder_report_s::PX4_ADSB_FLAGS_BARO_VALID) { msg.flags |= ADSB_FLAGS_BARO_VALID; }

if (pos.flags & transponder_report_s::PX4_ADSB_FLAGS_SOURCE_UAT) { msg.flags |= ADSB_FLAGS_SOURCE_UAT; }

mavlink_msg_adsb_vehicle_send_struct(_mavlink->get_channel(), &msg);
sent = true;
}
Expand Down
Loading