-
Notifications
You must be signed in to change notification settings - Fork 17.2k
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
Make speed changes during missions obey WPNAV_ACCEL #12821
Conversation
6dde95a
to
b763ba8
Compare
@rmackay9 and @peterbarker I have made the requested changes. I did my best to streamline the update wp speed function. I couldn't do a simple if (wp_desired_speed == wp_current_speed) because both variables are floats and the compiler chewed me out for comparing floats. So I put the else statement which I think works just as well. |
On Mon, 11 Nov 2019, Bill Geyer wrote:
@rmackay9 and @peterbarker I have made the requested changes. I did my best to streamline the update wp speed function. I couldn't do a simple if
(wp_desired_speed == wp_current_speed) because both variables are floats and the compiler chewed me out for comparing floats. So I put the else statement
For future reference:
if (is_equal(wp_desired_speed, wp_current_speed))
See also "is_zero".
|
I knew there was a function like that. I tried iszero() and it looks like i got the syntax wrong. thanks for the tips! |
b763ba8
to
463a0fe
Compare
@rmackay9 and @peterbarker I made the requested change and sqaushed the changes. I don't understand why I am getting the error in CI. |
@bnsgeyer One failure was just travis failing to bring up a VM. The second appears to be a result of recent sub tuning changes - that's going to be intermittent, sadly. I've kicked both of them over. |
@peterbarker thanks for the help. |
as discussed on the dev call I'll review this.. |
Looking pretty good but I think maybe we need to set _wp_current_speed_cms within wp_and_spline_init(). Here's the situation where I think it could go wrong:
I think what we will see is the vehicle will speed up to something like 10m/s but then slow down again to 2m/s (the default speed). We can discuss whether when the mission restarts it should go back to the default 2m/s or to the 50m/s but the way master works at the moment it will return to the default... but the way it is it initially climbs up to a high-ish speed and then returns to 2m/s which users will find confusing |
463a0fe
to
e5c07d5
Compare
@rmackay9 I have made a change that has it retain the desired speed once a mission is started. If the mission is stopped and then started again, it updates the current wp speed to the actual aircraft speed and it will accel to the desired speed. See what you think and I will take it to next weeks dev call if you are happy with that logic. |
@rmackay9 not sure why I got an error with Travis CI. Any help would be appreciated. |
@bnsgeyer The Rover tests failing were just travis sucking. The Copter test may be showing a regression. The test appears to set the My guess is you've failed to take into account that we have a separate speed when doing an RTL. Just guessing, haven't reviewed this PR :-) You can run the test locally yourself:
|
@peterbarker and @rmackay9 So I have changed the logic to always set the wpnav speed to wp_speed_cms when it initializes. That seemed to make the autotest happy. I'm assuming that is how we want it to work. anyway, I also have the wpnav take the current speed and set the variable current speed variable in wpnav so it increases/decreases the speed to the desired at the specified accel. if you are happy with this, I will clean up the code and squash the commits. |
d1bb2e1
to
7cb5519
Compare
@lthall I have finished making changes and feel it is ready to be merged if you think this is the right approach. |
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.
This all checks out and is ready to go in. Sorry for the delay!
libraries/AC_WPNav/AC_WPNav.cpp
Outdated
// initialise the current wp speed to current speed along the track | ||
const Vector3f &curr_vel = _inav.get_velocity(); | ||
// get speed along track (note: we convert vertical speed into horizontal speed equivalent) | ||
_wp_current_speed_cms = curr_vel.x * _pos_delta_unit.x + curr_vel.y * _pos_delta_unit.y; |
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.
We don't have a valid _pos_delta_unit at the time that wp_and_spline_init() is called so I think this is using the previous track to initialise the _wp_current_speed_cms...
@rmackay9 check my latest commit. is this what you had in mind? I haven't tested it yet but i think this will behave how we want. |
I had a play around with this today and unfortunately my advice didn't work out well (not that the original solution didn't have problems either of course). I found that in a simple back-and-forth mission, as the vehicle came close to the next waypoint (within the leash length's distance of the waypoint) the vehicle would suddenly stop, then it would start again towards the waypoint. I've rebased this PR on master and then added a couple of changes here: https://github.com/rmackay9/rmackay9-ardupilot/commits/bnsgeyer-obey-wpnav-accel I think the approach in this new branch is correct but it includes a couple of changes that you may or may not like:
|
@rmackay9 the current waypoint speed was added to track the progression of the waypoint’s speed to the desired waypoint speed. I’ve never thought about tracking out through the position controllers max speed. I am a little concerned that if the position controller max speed is written by another caller then you could see the position controller violate the wp accel but I guess the wp library would catch it on the next loop. Otherwise I like this implementation. I will pull it into my branch and test it tonight. Thanks for the help!! |
also small changes in max speed for z-axis
Includes commits by rmackay9 AC_WPNav: fixup max speed acceleration AC_WPNav: simplify the initialisation of poscontrol's max speed Changed at Leonard's request to keep things simpler
3b12466
to
9834b02
Compare
@rmackay9 I checked pulled your commits into my branch and did a quick check of the speed changes and moving in and out of auto. I think this will work fine. thanks for the assist. I rebased and squashed the commits. |
Merged, thanks! |
this is included in Copter-4.0.4-rc1 |
This PR is following up on what @ChristopherOlson did in PR #11068 which was closed for some reason. It fixes issue #11048. This PR is slightly different than Chris' PR in that it slews the WP speed both for increases in speed and decreases in speed.
Still uncertain why when the max XY accel is being passed to the position controller, it doesn't abide by that max accel parameter. This fixes the issue by slewing the wp speed changes passed to the position controller in accordance with the max wp accel.