Plane follow script Applet#28546
Conversation
b2021a5 to
c6bec54
Compare
|
Could you take a look @peterbarker and @tridge ? |
c6bec54 to
a85ee8f
Compare
|
I wonder if you'd be able to take a look at my Lua @yuri-rage - any suggestions appreciated. |
I'd be happy to take a look, Tim, but I have some external commitments upcoming that may prevent me from diving in right away. Please remind me either here, Discuss, or Discord if I don't reply in a week. |
a85ee8f to
b9de7f9
Compare
b9de7f9 to
3cbe60d
Compare
db44c23 to
8910d83
Compare
52d0f53 to
2183684
Compare
2821e85 to
3a0b2c3
Compare
9e6a6a8 to
7b22a30
Compare
b0db2e8 to
8b99bef
Compare
8f59dc2 to
47f44b2
Compare
| next_WP_loc = loc; | ||
|
|
||
| // used to control FBW and limit the rate of climb | ||
| // cannot be applied in Guided as this prevents the guided set altitude from working correctly |
There was a problem hiding this comment.
I guess it's because this code assumes that GUIDED is always running in "location" sub-mode (i.e. flying towards a location), but my follow code needs to switch between "location" sub-mode and "heading" sub mode. This line prevents the target altitude being reset when switching between sub-modes.
There was a problem hiding this comment.
I think this would prevent a simple mode change to GUIDED from locking the current alt
181025f to
07a0e56
Compare
timtuxworth
left a comment
There was a problem hiding this comment.
Implemented changes from the Dev call on 31 March 2025
| _target_location.lng = packet.lon; | ||
|
|
||
| // select altitude source based on FOLL_ALT_TYPE param | ||
| #if APM_BUILD_TYPE(APM_BUILD_ArduPlane) |
There was a problem hiding this comment.
i think this should be available on copter
| next_WP_loc = loc; | ||
|
|
||
| // used to control FBW and limit the rate of climb | ||
| // cannot be applied in Guided as this prevents the guided set altitude from working correctly |
There was a problem hiding this comment.
I think this would prevent a simple mode change to GUIDED from locking the current alt
| // check for timeout | ||
| if ((_last_heading_update_ms == 0) || (AP_HAL::millis() - _last_heading_update_ms > AP_FOLLOW_TIMEOUT_MS)) { | ||
| if ((_last_heading_update_ms == 0) || (AP_HAL::millis() - _last_heading_update_ms > (uint32_t)_timeout_ms)) { | ||
| gcs().send_text(MAV_SEVERITY_NOTICE, "gthd timeout %d", (int)(AP_HAL::millis() - _last_location_update_ms)); |
There was a problem hiding this comment.
could flood the link with msgs?
| AP_Follow follow; | ||
| #endif | ||
|
|
||
| AP_Int32 guided_timeout; |
| AP_Enum<Location::AltFrame> _alt_type; // altitude source for follow mode | ||
| AC_P _p_pos; // position error P controller | ||
| AP_Int16 _options; // options for mount behaviour follow mode | ||
| AP_Int32 _timeout_ms; // position estimate timeout after x milliseconds |
There was a problem hiding this comment.
AP_Float and update comment for seconds.
| return false; | ||
| } | ||
| // ignore message if we already received a more recent one | ||
| if(_target_location_last_time_boot_ms != 0 && packet.time_boot_ms <= _target_location_last_time_boot_ms ) { |
There was a problem hiding this comment.
What happens if the follow target vehicle is rebooted? Its boot time will go backwards so it will be ignored. Maybe if the time is more than 5 or 10 seconds in the past it would reset the boot time.
| local xy_dist = follow:get_distance_to_target() -- this value is set by get_target_dist_and_vel_ned() - why do I have to know this? | ||
| local target_heading = follow:get_target_heading_deg() | ||
| */ | ||
| bool AP_Follow::get_target_info(Vector3f &dist_ned, Vector3f &dist_with_offs, |
There was a problem hiding this comment.
I find it odd to be fetching both with and without the offset, why would a consumer want both?
There was a problem hiding this comment.
I think we need to fix the API so you don't need to call function A in order to get the correct value for function B
07a0e56 to
be40b54
Compare
eccc87a to
f4065aa
Compare
f4065aa to
27ccc36
Compare
|
Replaced by #30654 |
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.
I've also included 3 Lua modules that are used by the script but might also be useful to others.
This PR depends on
#28526 - this has now been included into this PR
ArduPilot/mavlink#372 - this has been merged
#28527 - this has been merged