-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
Treat UAVS diffrently from manned aviation #13159
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
0627f5d
ready 4 test
LowOrbitIonCannon 792e182
Parameters and changes
LowOrbitIonCannon a37b245
Parameter for Unmanned and Manned Aviation Avoid Distance
LowOrbitIonCannon d80c566
Parameters Updated
LowOrbitIonCannon 46683ed
Referenc ADSB_EMITER_TYPE Variable,
LowOrbitIonCannon eec96b5
Fixed Compiler Error by -Wno-cast-align
LowOrbitIonCannon 2d6e930
Added Testing functionality,
LowOrbitIonCannon 2df30d3
Added NAV_TRAFF_AVOID Hold and Landmode
LowOrbitIonCannon e52acc5
Added ADSB parameter to Transponder_report
LowOrbitIonCannon 2bb5cd3
Fixed aligment issue from float to double by converting to INT.
LowOrbitIonCannon 9191348
added Seperation as a value to Warning
LowOrbitIonCannon a3e580b
added Land Mode
LowOrbitIonCannon 717d2fd
testing Traffic avoidance, distance and modes
LowOrbitIonCannon 9632efb
Changed Warning messages and Merged HoldPosition and Collision Avoidance
LowOrbitIonCannon 3c8e440
Merge branch 'testing' into r4t
LowOrbitIonCannon 2d7ecfd
ignore selfsend UTM msg.
LowOrbitIonCannon 4d5460d
Changed mavlink reciever to ignore selfüublished messages
LowOrbitIonCannon 8afe944
Fixed boards with no GUID giving build Errors
LowOrbitIonCannon b9d1137
Reduced size to fit into px4-fmu-v2
LowOrbitIonCannon 71d4a81
Merge branch 'master' into r4t
LowOrbitIonCannon c217c6a
Merge branch 'master' into r4t
LowOrbitIonCannon cbce64e
Merge branch 'master' into r4t
dagar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -899,7 +899,7 @@ Navigator::load_fence_from_file(const char *filename) | |
* | ||
*/ | ||
void Navigator::fake_traffic(const char *callsign, float distance, float direction, float traffic_heading, | ||
float altitude_diff, float hor_velocity, float ver_velocity) | ||
float altitude_diff, float hor_velocity, float ver_velocity, int emitter_type) | ||
{ | ||
double lat, lon; | ||
waypoint_from_heading_and_distance(get_global_position()->lat, get_global_position()->lon, direction, distance, &lat, | ||
|
@@ -922,14 +922,30 @@ void Navigator::fake_traffic(const char *callsign, float distance, float directi | |
tr.ver_velocity = ver_velocity; //-vel_d; // The vertical velocity in m/s, positive is up | ||
strncpy(&tr.callsign[0], callsign, sizeof(tr.callsign) - 1); | ||
tr.callsign[sizeof(tr.callsign) - 1] = 0; | ||
tr.emitter_type = 0; // Type from ADSB_EMITTER_TYPE enum | ||
tr.emitter_type = emitter_type; // Type from ADSB_EMITTER_TYPE enum | ||
tr.tslc = 2; // Time since last communication in seconds | ||
tr.flags = transponder_report_s::PX4_ADSB_FLAGS_VALID_COORDS | transponder_report_s::PX4_ADSB_FLAGS_VALID_HEADING | | ||
transponder_report_s::PX4_ADSB_FLAGS_VALID_VELOCITY | | ||
transponder_report_s::PX4_ADSB_FLAGS_VALID_ALTITUDE | | ||
transponder_report_s::PX4_ADSB_FLAGS_VALID_CALLSIGN; // Flags to indicate various statuses including valid data fields | ||
(transponder_report_s::ADSB_EMITTER_TYPE_UAV & emitter_type ? 0 : | ||
transponder_report_s::PX4_ADSB_FLAGS_VALID_CALLSIGN); // Flags to indicate various statuses including valid data fields | ||
tr.squawk = 6667; | ||
|
||
|
||
|
||
|
||
#ifndef BOARD_HAS_NO_UUID | ||
px4_guid_t px4_guid; | ||
board_get_px4_guid(px4_guid); | ||
memcpy(tr.uas_id, px4_guid, sizeof(px4_guid_t)); //simulate own GUID | ||
#else | ||
|
||
for (int i = 0; i < PX4_GUID_BYTE_LENGTH ; i++) { | ||
tr.uas_id[i] = 0xe0 + i; //simulate GUID | ||
} | ||
|
||
#endif /* BOARD_HAS_NO_UUID */ | ||
|
||
uORB::PublicationQueued<transponder_report_s> tr_pub{ORB_ID(transponder_report)}; | ||
tr_pub.publish(tr); | ||
} | ||
|
@@ -948,11 +964,16 @@ void Navigator::check_traffic() | |
|
||
bool changed = _traffic_sub.updated(); | ||
|
||
float horizontal_separation = 500; | ||
float vertical_separation = 500; | ||
char uas_id[11]; //GUID of incoming UTM messages | ||
|
||
float NAVTrafficAvoidUnmanned = _param_nav_traff_a_radu.get(); | ||
float NAVTrafficAvoidManned = _param_nav_traff_a_radm.get(); | ||
float horizontal_separation = NAVTrafficAvoidManned; | ||
float vertical_separation = NAVTrafficAvoidManned; | ||
|
||
while (changed) { | ||
|
||
//vehicle_status_s vs{}; | ||
transponder_report_s tr{}; | ||
_traffic_sub.copy(&tr); | ||
|
||
|
@@ -965,6 +986,17 @@ void Navigator::check_traffic() | |
continue; | ||
} | ||
|
||
//convert UAS_id byte array to char array for User Warning | ||
for (int i = 0; i < 5; i++) { | ||
snprintf(&uas_id[i * 2], sizeof(uas_id) - i * 2, "%02x", tr.uas_id[PX4_GUID_BYTE_LENGTH - 5 + i]); | ||
} | ||
|
||
//Manned/Unmanned Vehicle Seperation Distance | ||
if (tr.emitter_type == transponder_report_s::ADSB_EMITTER_TYPE_UAV) { | ||
horizontal_separation = NAVTrafficAvoidUnmanned; | ||
vertical_separation = NAVTrafficAvoidUnmanned; | ||
} | ||
|
||
float d_hor, d_vert; | ||
get_distance_to_point_global_wgs84(lat, lon, alt, | ||
tr.lat, tr.lon, tr.altitude, &d_hor, &d_vert); | ||
|
@@ -999,27 +1031,33 @@ void Navigator::check_traffic() | |
|
||
// direction of traffic in human-readable 0..360 degree in earth frame | ||
int traffic_direction = math::degrees(tr.heading) + 180; | ||
int traffic_seperation = (int)fabsf(cr.distance); | ||
|
||
switch (_param_nav_traff_avoid.get()) { | ||
|
||
case 0: { | ||
/* ignore */ | ||
PX4_WARN("TRAFFIC %s, hdg: %d", tr.flags & transponder_report_s::PX4_ADSB_FLAGS_VALID_CALLSIGN ? tr.callsign : | ||
"unknown", | ||
/* Ignore */ | ||
PX4_WARN("TRAFFIC %s! dst %d, hdg %d", | ||
tr.flags & transponder_report_s::PX4_ADSB_FLAGS_VALID_CALLSIGN ? tr.callsign : uas_id, | ||
traffic_seperation, | ||
traffic_direction); | ||
break; | ||
} | ||
|
||
case 1: { | ||
mavlink_log_critical(&_mavlink_log_pub, "WARNING TRAFFIC %s at heading %d, land immediately", | ||
tr.flags & transponder_report_s::PX4_ADSB_FLAGS_VALID_CALLSIGN ? tr.callsign : "unknown", | ||
/* Warn only */ | ||
mavlink_log_critical(&_mavlink_log_pub, "Warning TRAFFIC %s! dst %d, hdg %d", | ||
tr.flags & transponder_report_s::PX4_ADSB_FLAGS_VALID_CALLSIGN ? tr.callsign : uas_id, | ||
traffic_seperation, | ||
traffic_direction); | ||
break; | ||
} | ||
|
||
case 2: { | ||
mavlink_log_critical(&_mavlink_log_pub, "AVOIDING TRAFFIC %s heading %d, returning home", | ||
tr.flags & transponder_report_s::PX4_ADSB_FLAGS_VALID_CALLSIGN ? tr.callsign : "unknown", | ||
/* RTL Mode */ | ||
mavlink_log_critical(&_mavlink_log_pub, "TRAFFIC: %s Returning home! dst %d, hdg %d", | ||
tr.flags & transponder_report_s::PX4_ADSB_FLAGS_VALID_CALLSIGN ? tr.callsign : uas_id, | ||
traffic_seperation, | ||
traffic_direction); | ||
|
||
// set the return altitude to minimum | ||
|
@@ -1031,6 +1069,36 @@ void Navigator::check_traffic() | |
publish_vehicle_cmd(&vcmd); | ||
break; | ||
} | ||
|
||
case 3: { | ||
/* Land Mode */ | ||
mavlink_log_critical(&_mavlink_log_pub, "TRAFFIC: %s Landing! dst %d, hdg % d", | ||
tr.flags & transponder_report_s::PX4_ADSB_FLAGS_VALID_CALLSIGN ? tr.callsign : uas_id, | ||
traffic_seperation, | ||
traffic_direction); | ||
|
||
// ask the commander to land | ||
vehicle_command_s vcmd = {}; | ||
vcmd.command = vehicle_command_s::VEHICLE_CMD_NAV_LAND; | ||
publish_vehicle_cmd(&vcmd); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is okay as a test, but if we want it to exist long term it should really be tied into the state machine a little more directly. |
||
break; | ||
|
||
} | ||
|
||
case 4: { | ||
/* Position hold */ | ||
mavlink_log_critical(&_mavlink_log_pub, "TRAFFIC: %s Holding position! dst %d, hdg %d", | ||
tr.flags & transponder_report_s::PX4_ADSB_FLAGS_VALID_CALLSIGN ? tr.callsign : uas_id, | ||
traffic_seperation, | ||
traffic_direction); | ||
|
||
// ask the commander to Loiter | ||
vehicle_command_s vcmd = {}; | ||
vcmd.command = vehicle_command_s::VEHICLE_CMD_NAV_LOITER_UNLIM; | ||
publish_vehicle_cmd(&vcmd); | ||
break; | ||
|
||
} | ||
} | ||
} | ||
} | ||
|
@@ -1084,9 +1152,12 @@ int Navigator::custom_command(int argc, char *argv[]) | |
return 0; | ||
|
||
} else if (!strcmp(argv[0], "fake_traffic")) { | ||
get_instance()->fake_traffic("LX007", 500, 1.0f, -1.0f, 100.0f, 90.0f, 0.001f); | ||
get_instance()->fake_traffic("LX55", 1000, 0, 0, 100.0f, 90.0f, 0.001f); | ||
get_instance()->fake_traffic("LX20", 15000, 1.0f, -1.0f, 280.0f, 90.0f, 0.001f); | ||
get_instance()->fake_traffic("LX007", 500, 1.0f, -1.0f, 100.0f, 90.0f, 0.001f, | ||
transponder_report_s::ADSB_EMITTER_TYPE_LIGHT); | ||
get_instance()->fake_traffic("LX55", 1000, 0, 0, 100.0f, 90.0f, 0.001f, transponder_report_s::ADSB_EMITTER_TYPE_SMALL); | ||
get_instance()->fake_traffic("LX20", 15000, 1.0f, -1.0f, 280.0f, 90.0f, 0.001f, | ||
transponder_report_s::ADSB_EMITTER_TYPE_LARGE); | ||
get_instance()->fake_traffic("UAV", 10, 1.0f, -2.0f, 10.0f, 10.0f, 0.01f, transponder_report_s::ADSB_EMITTER_TYPE_UAV); | ||
return 0; | ||
} | ||
|
||
|
@@ -1195,7 +1266,7 @@ controller. | |
PRINT_MODULE_USAGE_NAME("navigator", "controller"); | ||
PRINT_MODULE_USAGE_COMMAND("start"); | ||
PRINT_MODULE_USAGE_COMMAND_DESCR("fencefile", "load a geofence file from SD card, stored at etc/geofence.txt"); | ||
PRINT_MODULE_USAGE_COMMAND_DESCR("fake_traffic", "publishes 3 fake transponder_report_s uORB messages"); | ||
PRINT_MODULE_USAGE_COMMAND_DESCR("fake_traffic", "publishes 4 fake transponder_report_s uORB messages"); | ||
PRINT_MODULE_USAGE_DEFAULT_COMMANDS(); | ||
|
||
return 0; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Type should match the size used in the message definition.