-
Notifications
You must be signed in to change notification settings - Fork 990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ADSB Plugin #696
ADSB Plugin #696
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who is gonna to use that plugin? Which FCU support that?
I don't want to merge plugin without a users.
mavros/include/mavros/utils.h
Outdated
@@ -35,6 +35,10 @@ namespace utils { | |||
|
|||
using mavconn::utils::format; | |||
|
|||
using mavlink::common::ADSB_ALTITUDE_TYPE; | |||
using mavlink::common::ADSB_EMITTER_TYPE; | |||
using mavlink::common::ADSB_FLAGS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where then? I put there so the below code in utils.h
could work.
mavros/src/lib/enum_to_string.cpp
Outdated
static const std::array<const std::string, 2> adsb_altitude_type_strings{{ | ||
/* 0 */ "ADSB_ALTITUDE_TYPE_PRESSURE_QNH", // Altitude reported from a Baro source using QNH reference | ||
/* 1 */ "ADSB_ALTITUDE_TYPE_GEOMETRIC", // Altitude reported from a GNSS source | ||
}}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ADSB_ALTITUDE_TYPE_
prefix should be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep
mavros/src/lib/enum_to_string.cpp
Outdated
} | ||
|
||
ROS_ERROR_STREAM_NAMED("uas", "ADSB_ALTITUDE_TYPE: Unknown type: " << type); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No return
- error! And what you will return if there is no requested type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion?
mavros/src/lib/enum_to_string.cpp
Outdated
// for k, e in enum: | ||
// value = e.name | ||
// value = value.replace("ADSB_EMITTER_TYPE_",'') | ||
// value.replace("{ename}",'') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wtf? Look at sensor orientation code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
mavros/src/lib/enum_to_string.cpp
Outdated
/* 16 */ "VALID_CALLSIGN", // | ||
/* 32 */ "VALID_SQUAWK", // | ||
/* 64 */ "SIMULATED", // | ||
}}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You cannot decode bit field that way!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a bit field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind
mavros_msgs/msg/ADSBVehicle.msg
Outdated
|
||
uint32 ICAO_address | ||
geographic_msgs/GeoPoint lla | ||
std_msgs/String altitude_type # Type from ADSB_ALTITUDE_TYPE enum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seriously?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
char[]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mavros_msgs/msg/ADSBVehicle.msg
Outdated
uint16 heading # cog | ||
uint16 hor_velocity | ||
int16 ver_velocity | ||
char[9] callsign # callsign, 8+null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is string!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
k
mavros_extras/src/plugins/adsb.cpp
Outdated
|
||
std_msgs::Header header; | ||
header.stamp = ros::Time::now();//TODO: request add time_boot_ms to msg definition | ||
header.frame_id = frame_id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? Did you use that header twice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok sure
mavros_msgs/msg/ADSBVehicle.msg
Outdated
char[9] callsign # callsign, 8+null | ||
std_msgs/String emitter_type # Type from ADSB_EMITTER_TYPE enum | ||
std_msgs/Time tslc | ||
std_msgs/String data_status # Flags from ADSB_FLAGS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave binary data here. Who want to parse strings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's more useful parsed than otherwise. For debugging and for usage. They are INFO fields...
mavros_msgs/msg/ADSBVehicle.msg
Outdated
uint16 hor_velocity | ||
int16 ver_velocity | ||
char[9] callsign # callsign, 8+null | ||
std_msgs/String emitter_type # Type from ADSB_EMITTER_TYPE enum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Numeric.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not parse it?
Check the link. Both APM and PX4 compatible FCU. I'm buying one myself. Even useful for global planning and avoidance. |
da9ecab
to
bc373b8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That to_stirng and back is completely unneeded.
mavros/include/mavros/utils.h
Outdated
@@ -65,6 +64,9 @@ std::string to_string(mavlink::common::MAV_AUTOPILOT e); | |||
std::string to_string(mavlink::common::MAV_TYPE e); | |||
std::string to_string(mavlink::common::MAV_STATE e); | |||
std::string to_string(timesync_mode e); | |||
std::string to_string(mavlink::common::ADSB_ALTITUDE_TYPE e); | |||
std::string to_string(mavlink::common::ADSB_EMITTER_TYPE e); | |||
std::string to_string(const uint16_t &bitmask); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope! Unacceptable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is for debugging purposes. it's not for msg parsing. if you just tell it is not acceptable but don't suggest a solution, it's the same as nothing...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it is generic type. How you suppose to deal when another uin16_t bit field will be needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you may leave to_string for that enums.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if I change to
std::string flags_to_string(const uint16_t &adsb_bitmask);
is it ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. Shouldn't be in lib.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. Shouldn't be in lib.
Hmm ok
mavros_extras/src/plugins/adsb.cpp
Outdated
adsb.hor_velocity = req->hor_velocity * 1E2; | ||
adsb.ver_velocity = req->ver_velocity * 1E2; // up is positive | ||
mavlink::set_string(adsb.callsign, req->callsign); | ||
adsb.emitter_type = utils::emitter_type_from_str(req->emitter_type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NO!
mavros_extras/src/plugins/adsb.cpp
Outdated
adsb.lat = req->lla.latitude * 1E7; | ||
adsb.lon = req->lla.longitude * 1E7; | ||
adsb.altitude = req->lla.altitude; // in meters, TODO: #693 | ||
adsb.altitude_type = utils::alt_type_from_str(req->altitude_type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NO!
mavros_extras/src/plugins/adsb.cpp
Outdated
adsb_msg->hor_velocity = adsb.hor_velocity / 1E2; | ||
adsb_msg->ver_velocity = adsb.ver_velocity / 1E2; // up is positive | ||
std::copy(adsb_callsign.cbegin(), adsb_callsign.cend(), adsb_msg->callsign.begin()); | ||
adsb_msg->emitter_type = utils::to_string(emitter_type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NO!
mavros_extras/src/plugins/adsb.cpp
Outdated
adsb_msg->lla.latitude = adsb.lat / 1E7; | ||
adsb_msg->lla.longitude = adsb.lon / 1E7; | ||
adsb_msg->lla.altitude = adsb.altitude; // in meters, TODO: #693 | ||
adsb_msg->altitude_type = utils::to_string(altitude_type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NO!
std_msgs/Header header | ||
|
||
uint32 ICAO_address | ||
geographic_msgs/GeoPoint lla |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace with:
float64 latitude
float64 longitude
float32 altitude
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm following ROS conventions. Also: ros-geographic-info/geographic_info@b8043a9#commitcomment-21800531.
So don't see any problem on this. After conversion applied, everything is good
mavros_msgs/msg/ADSBVehicle.msg
Outdated
|
||
uint32 ICAO_address | ||
geographic_msgs/GeoPoint lla | ||
string altitude_type # Type from ADSB_ALTITUDE_TYPE enum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No! Add constants to msg, and leave it integer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you want me to add 29 constants to a msg just because you don't like a to_string
parser on the cb?
mavros_msgs/msg/ADSBVehicle.msg
Outdated
uint16 hor_velocity | ||
int16 ver_velocity | ||
string callsign # callsign, 8+null | ||
string emitter_type # Type from ADSB_EMITTER_TYPE enum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Integer!
@@ -22,6 +22,7 @@ | |||
<exec_depend>message_runtime</exec_depend> | |||
<depend>std_msgs</depend> | |||
<depend>geometry_msgs</depend> | |||
<depend>geographic_msgs</depend> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mavros_extras/src/plugins/adsb.cpp
Outdated
adsb.heading = req->heading * 1E2 * 180.0f / M_PI + M_PI; | ||
adsb.hor_velocity = req->hor_velocity * 1E2; | ||
adsb.ver_velocity = req->ver_velocity * 1E2; // up is positive | ||
mavlink::set_string(adsb.callsign, req->callsign); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be mavlink::set_string_z()
, _z is important.
set_string()
is for message fields like param_id, where '\0'
may be omitted and only indicate shorter strings than buffer.
set_string_z()
ensures that last byte is '\0'
, which required by adsb message desc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok thanks
mavros_extras/src/plugins/adsb.cpp
Outdated
ros::Subscriber adsb_sub; | ||
|
||
ADSB_ALTITUDE_TYPE altitude_type; | ||
ADSB_EMITTER_TYPE emitter_type; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For what purpose that two enums are here?
mavros_msgs/msg/ADSBVehicle.msg
Outdated
int16 ver_velocity | ||
string callsign # callsign, 8+null | ||
uint16 emitter_type # Type from ADSB_EMITTER_TYPE enum | ||
std_msgs/Time tslc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, again. tslc.data
- you think i did not stumble at this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it better to convert to ros:time in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And more over, that is not time! It is duration.
tslc uint8_t Time since last communication in seconds
} | ||
|
||
void adsb_cb(const mavros_msgs::ADSBVehicle::ConstPtr &req) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use ROS_DEBUG_NAMED_STREAM("adsb", "ADSB: at type " << utils::to_string(e));
For enums! Use C++ streams for std::string
.
Use 0x%02x
format for bit-filed.
mavros_extras/src/plugins/adsb.cpp
Outdated
adsb_msg->altitude_type = adsb.altitude_type; | ||
adsb_msg->heading = adsb.heading / 1E2 / 180.0f * M_PI - M_PI; | ||
adsb_msg->hor_velocity = adsb.hor_velocity / 1E2; | ||
adsb_msg->ver_velocity = adsb.ver_velocity / 1E2; // up is positive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your heading, hor_, ver_velocity is int16! Check your message spec!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use / 100
? or 1e2
?
mavros_extras/src/plugins/adsb.cpp
Outdated
adsb_msg->heading = adsb.heading / 1E2 / 180.0f * M_PI - M_PI; | ||
adsb_msg->hor_velocity = adsb.hor_velocity / 1E2; | ||
adsb_msg->ver_velocity = adsb.ver_velocity / 1E2; // up is positive | ||
std::copy(adsb_callsign.cbegin(), adsb_callsign.cend(), adsb_msg->callsign.begin()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, man, look at available API first! mavlink::to_string()
mavros_msgs/msg/ADSBVehicle.msg
Outdated
|
||
uint32 ICAO_address | ||
geographic_msgs/GeoPoint lla | ||
uint16 altitude_type # Type from ADSB_ALTITUDE_TYPE enum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In mavlink it is uint8_t.
Replaced. |
This adds a ADS-B (Automatic dependent surveillance-broadcast) wrapper so it can allow data reception/publish of modules.
ADSB_VEHICLE
and publish data to ROS msg - Ping RX