Skip to content

Commit

Permalink
AP_Mount: Scripted follow in Plane
Browse files Browse the repository at this point in the history
  • Loading branch information
timtuxworth committed Oct 15, 2024
1 parent c4718b6 commit d0260ce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions libraries/AP_Mount/AP_Mount_Backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,9 @@ bool AP_Mount_Backend::handle_global_position_int(uint8_t msg_sysid, const mavli
// global_position_int.alt is *UP*, so is location.
_target_sysid_location.set_alt_cm(packet.alt*0.1, Location::AltFrame::ABSOLUTE);
_target_sysid_location_set = true;
// keep track of when we last received the update
//_target_sysid_update_ms = AP_HAL::millis();
_target_sysid_update_ms = _jitter.correct_offboard_timestamp_msec(packet.time_boot_ms, AP_HAL::millis());

return true;
}
Expand Down Expand Up @@ -889,6 +892,10 @@ bool AP_Mount_Backend::get_angle_target_to_sysid(MountTarget& angle_rad) const
if (!_target_sysid) {
return false;
}
// don't update the angle if we haven't received a recent update from the target
if(AP_HAL::millis() - _target_sysid_update_ms > 200) {
return false;
}
return get_angle_target_to_location(_target_sysid_location, angle_rad);
}

Expand Down
4 changes: 4 additions & 0 deletions libraries/AP_Mount/AP_Mount_Backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <RC_Channel/RC_Channel.h>
#include <AP_Camera/AP_Camera_shareddefs.h>
#include "AP_Mount.h"
#include <AP_RTC/JitterCorrection.h>

class AP_Mount_Backend
{
Expand Down Expand Up @@ -341,6 +342,9 @@ class AP_Mount_Backend
uint8_t _target_sysid; // sysid to track
Location _target_sysid_location;// sysid target location
bool _target_sysid_location_set;// true if _target_sysid has been set
uint32_t _target_sysid_update_ms;// timestamp when the target_sysid_location was last updated
// setup jitter correction with max transport lag of 3s
JitterCorrection _jitter{3000};

uint32_t _last_warning_ms; // system time of last warning sent to GCS

Expand Down

0 comments on commit d0260ce

Please sign in to comment.