Skip to content

Commit 7d842ce

Browse files
committed
throttle and remove some osd updates
1 parent 9863a25 commit 7d842ce

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

libraries/AP_Avoidance/AP_Avoidance.cpp

+10-3
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ void AP_Avoidance::get_adsb_samples()
343343
void AP_Avoidance::get_odid_samples()
344344
{
345345
//TODO: Process samples here
346-
GCS_SEND_TEXT(MAV_SEVERITY_INFO,"Avoidance: Get %d drones", AP::vehicle()->odidscanner.get_count());
346+
// GCS_SEND_TEXT(MAV_SEVERITY_INFO,"Avoidance: Get %d drones", AP::vehicle()->odidscanner.get_count());
347347
for(int i = 0;i<AP::vehicle()->odidscanner.get_count();i++) {
348348
auto v = AP::vehicle()->odidscanner.get_vehicle(i);
349349
uint8_t mac[6];
@@ -621,12 +621,19 @@ void AP_Avoidance::handle_avoidance_local(AP_Avoidance::Obstacle *threat)
621621
{
622622
MAV_COLLISION_THREAT_LEVEL new_threat_level = MAV_COLLISION_THREAT_LEVEL_NONE;
623623
MAV_COLLISION_ACTION action = MAV_COLLISION_ACTION_NONE;
624-
GCS_SEND_TEXT(MAV_SEVERITY_INFO,"Threat level: %d", new_threat_level);
624+
// GCS_SEND_TEXT(MAV_SEVERITY_INFO,"Threat level: %d", new_threat_level);
625625
AP::logger().Write("ODID", "TimeUS,Threat_level", "Qb", AP_HAL::micros64(), new_threat_level);
626626

627627

628628
if (threat != nullptr) {
629-
GCS_SEND_TEXT(MAV_SEVERITY_INFO,"xy: %f,z: %f", threat->closest_approach_xy, threat->closest_approach_z);
629+
// xxx need a timer here, update to OSD is too often at 10 Hz...
630+
// pseudo code:
631+
// now=millis()
632+
// if now-_time_of_last_GCS_nearest_drone_update > 1000 ms then post new message...
633+
uint32_t now = AP_HAL::millis();
634+
if ( (now - time_of_last_GCS_nearest_drone_update ) > 1000){
635+
GCS_SEND_TEXT(MAV_SEVERITY_INFO,"xy: %f,z: %f", threat->closest_approach_xy, threat->closest_approach_z);
636+
}
630637
// double closest_approach_xy = threat->closest_approach_xy;
631638
// double closest_approach_z = threat->closest_approach_z;
632639
// AP::logger().Write("ODID", "TimeUS,xy,z", "Qff", AP_HAL::micros64(), closest_approach_xy, closest_approach_z);

libraries/AP_Avoidance/AP_Avoidance.h

+3
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ class AP_Avoidance {
154154
static Vector3f perpendicular_xyz(const Location &p1, const Vector3f &v1, const Location &p2);
155155
static Vector2f perpendicular_xy(const Location &p1, const Vector3f &v1, const Location &p2);
156156

157+
// ODID avoidance variables
158+
uint32_t time_of_last_GCS_nearest_drone_update;
159+
157160
private:
158161

159162
void send_collision_all(const AP_Avoidance::Obstacle &threat, MAV_COLLISION_ACTION behaviour) const;

libraries/AP_ODIDScanner/AP_ODIDScanner.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -87,22 +87,24 @@ case MAVLINK_MSG_ID_OPEN_DRONE_ID_LOCATION:
8787
}
8888
void AP_ODIDScanner::update() {
8989
const uint32_t now_ms = AP_HAL::millis();
90-
if (now_ms - last_dev_hb_ms > 5000 && now_ms - last_dev_hb_msg_ms > 5000) {
90+
91+
if (now_ms - last_dev_hb_ms > 15000 && now_ms - last_dev_hb_msg_ms > 15000) {
9192
last_dev_hb_msg_ms = now_ms;
92-
GCS_SEND_TEXT(MAV_SEVERITY_INFO, "Scanner: Device Not Found");
93+
GCS_SEND_TEXT(MAV_SEVERITY_INFO, "Scanner: Device Not Found at %f",float(now_ms));
9394
_port->printf("Scanner: Where is this printing?");
9495
}
95-
if (now_ms - last_hb_send_ms > 1000) {
9696

97+
if (now_ms - last_hb_send_ms > 1000) { // why this?
9798
last_hb_send_ms = now_ms;
98-
mavlink_msg_heartbeat_send(
99+
mavlink_msg_heartbeat_send(
99100
_chan,
100101
gcs().frame_type(),
101102
MAV_AUTOPILOT_ARDUPILOTMEGA,
102103
0,
103104
gcs().custom_mode(),
104105
0);
105-
}
106+
}
107+
106108
}
107109

108110
bool AP_ODIDScanner::message_from_rx(mavlink_channel_t& chan) {

libraries/AP_Vehicle/AP_Vehicle.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ const AP_Scheduler::Task AP_Vehicle::scheduler_tasks[] = {
398398
SCHED_TASK_CLASS(AP_OpenDroneID, &vehicle.opendroneid, update, 10, 50, 236),
399399
#endif
400400
// test comment...
401-
SCHED_TASK_CLASS(AP_ODIDScanner,&vehicle.odidscanner, update, 1, 50, 237),
401+
SCHED_TASK_CLASS(AP_ODIDScanner,&vehicle.odidscanner, update, 10, 50, 237),
402402
#if OSD_ENABLED
403403
SCHED_TASK(publish_osd_info, 1, 10, 240),
404404
#endif

0 commit comments

Comments
 (0)