-
Notifications
You must be signed in to change notification settings - Fork 19.5k
Plane follow lua applet #30654
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
Plane follow lua applet #30654
Conversation
1db472a
to
3becb7e
Compare
28941e2
to
27589aa
Compare
8046766
to
f0f5cee
Compare
60d9854
to
684840c
Compare
c923417
to
f497ce6
Compare
c9571fc
to
ace6a8d
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.
partial review on-call only
ace6a8d
to
acfdcfe
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.
With the changes below I highlighted I think this is good.
acfdcfe
to
9fcefb7
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.
partial review
773bb71
to
f8a523d
Compare
f8a523d
to
d4bcc6f
Compare
libraries/AP_Follow/AP_Follow.h
Outdated
//========================================================================== | ||
|
||
uint32_t _last_location_update_ms; // Time of last target position update (ms) | ||
uint64_t _last_location_update_us; // Time of last target position update (ms) |
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'd make this uint64_t _last_location_update_ms;
libraries/AP_Follow/AP_Follow.cpp
Outdated
} | ||
|
||
// apply jitter-corrected timestamp to this update unless the update is older than the most recently received message or FOLL_TIMEOUT seconds | ||
uint64_t location_update_us = _jitter.correct_offboard_timestamp_usec((uint64_t)packet.time_boot_ms * 1000, AP_HAL::micros()); |
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.
uint64_t location_update_ms = uint64_div1000(_jitter.correct_offboard_timestamp_usec((uint64_t)packet.time_boot_ms * 1000, AP_HAL::micros()));
libraries/AP_Follow/AP_Follow.cpp
Outdated
|
||
// apply jitter-corrected timestamp to this update unless the update is older than the most recently received message or FOLL_TIMEOUT seconds | ||
uint64_t location_update_us = _jitter.correct_offboard_timestamp_usec((uint64_t)packet.time_boot_ms * 1000, AP_HAL::micros()); | ||
if (location_update_us < _last_location_update_us || (location_update_us - _last_location_update_us) > _timeout.cast_to_float() * 1000000 ) { |
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 would do something like:
float tdelta = int32_t(location_update_ms - _last_location_update_ms) * 0.001;
if (tdelta < 0 && tdelta > -10) {
xxx;
}
libraries/AP_Follow/AP_Follow.cpp
Outdated
/// Altitude comes in AMSL | ||
_target_location.set_alt_cm(packet.alt * 0.1, Location::AltFrame::ABSOLUTE); | ||
// convert the incoming altitude to terrain altitude | ||
_target_location.change_alt_frame(Location::AltFrame::ABOVE_TERRAIN); |
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.
what happens if this fails?
This creates a new Lua Script applet that implements "plane follow" - a fixed wing follow/chase functionality that runs in guided mode. The code uses the core AP_Follow library functionality and therefore uses most of the documented FOLL_ parameters that are used in Copter and Rover FOLLOW mode.
The kinematic extrapolation improvements made by @lthall significantly improved the quality and smoothness of the follow.
I've made one small enhancement to make the follow Altitude sensitive as this was required by the partner who I worked with through this process. If FOLL_ALT_TYPE = 3:terrain then the follow altitude will be terrain relative. There is also a scripted FOLLP_OVR_ALT that forces the follow vehicle to use a specific altitude overriding the altitude it receives from the lead plane and the follow library.
I've also included a Lua module that is used by the script but might also be useful to others.
pid.lua - A PID controller extracted/generalized from plane_aerobatics