Rover/Boat QuikTune alpha testers wanted!

We’ve recently made progress towards creating a Rover/Boat Quick Tune lua script based on the VTOL-Quiktune script shown off in this video and so now I’d like some help from brave alpha testers willing to try it on their vehicles and provide feedback so we can determine that it works on all frames (and if not I’ll make changes).

This way the script works is it slowly increases the relevant gains until it detects an oscillation. It then backs off the gains by 50% or so and moves onto the next gain. In total the script attempts to tune all these parameter values:

  • ATC_STR_RAT_P ← steering rate controller P gain (corrects for short-term errors)
  • ATC_STR_RAT_I ← steering rate controller I gain (corrects for long-term errors)
  • ATC_STR_RAT_D ← steering rate controller D gain (provides “damping” or stability)
  • ATC_STR_RAT_FF ← steering rate controller feed forward gain (the most important actually)
  • ATC_SPEED_P, I and D ← speed controller gains
  • CRUISE_SPEED & CRUISE_THROTTLE ← speed controller “base” values, equivalent to feed-foward
  • PSC_VEL_P, I and D ← position controller’s velocity control gains

Installing the script

  • Install the Rover-4.4.0-beta4 (or higher) using MP or QGC… Note that Lua scripts generally only run on autopilots with an F7 or H7 processor (e.g. CubeOrange, Durandal, MatekH7, etc)
  • Set SCR_ENABLE = 1 and reboot the autopilot
  • Install the rover-quicktune.lua script on your autopilot’s SD card in the APM/scripts directory. It may be easiest to use MP’s MAVFTP feature to do this.

Testing Circle mode

  • Rover-4.4 (and higher) includes Circle mode (mode 9) which can be setup using a flight mode switch or you can switch to it using a recent version of Mission Planner’s Action tab.
  • Before switching into the mode please check the CIRC_RADIUS is at least 2m. Larger values could be better if the vehicle and/or testing area is large.
  • Optionally set the CIRC_SPEED to a comfortable speed for the vehicle where “comfortable” means the vehicle uses between 30% to 60% throttle. If left at zero the WP_SPEED will be used. Note that while in Circle mode MP’s Action tab’s “Change Speed” button may also be used to change the vehicle’s speed.
  • Once switched into Circle mode the vehicle will drive slowly forward to the edge of the circle and then turn sharply right and continue around the circle. Of course at any time you may retake control of the vehicle by switching to another mode
  • Note that currently Circle mode’s target (which moves around the circle) does not slow down even if the vehicle doesn’t keep up. If the vehicle can’t drive a circle at all it may help to reduce the speed.

Running Quiktune

  • Set RTUN_ENABLE = 1 (no reboot should be required)
  • RTUN_AXES controls which axis will be tuned. The default of “7” means steering, speed and velocity will all be tuned one after the other but if you only want to tune one axis set the parameter to:
    • 1: steering tuning only
    • 2: speed tuning only
    • 4: position controller velocity tuning only
  • Setup an RC auxiliary switch to “scripting1” by setting RCx_OPTION = 300 (“scripting1”). Low position stops the tune, Middle position starts the tune. High position saves gains (if a tune has completed successfully). Alternatively MP’s Aux Function screen can be used (this is my preferred method).
  • Switch the vehicle to Circle mode (see above) and once it is moving around the circle move the auxiliary function to the middle to start the tune.
  • The ground stations’s Messages tab will show text messages re the progress of the tune. The stages of the tune are:
    • First the _D gain (e.g. ATC_STR_RAT_D) is increased until the vehicle oscillates (aka Slew Rate) and then the _D will be reduced (by the RTUN_GAIN_MARGIN)
    • Next the _P gain will be increased until the vehicle oscillates after which it will also be reduced.
    • Finally the FeedForward (FF) will be tuned but this simply involves driving the vehicle around the circle gathering data. Usually this completes within one rotation.
    • If more than one axis has been setup (see RTUN_AXES) then the tune will move onto the next axis (the order is Steering, Speed then finally Velocity control)
  • Once tuning has completed successfully you may raise the RC aux switch to the High position to save gains. You may wish to then drive it around in Acro mode or execute a mission to see if it performs better or worse than it did before tuning.

Monitoring the Tune

  • Progress on the tune appears in the Messages tab
  • A real-time view of the actively tuned PID can be seen by on MP’s Data screen. Check the “Tuning” checkbox at the bottom, then double click on the graphing area and (from the huge selection screen) select “piddesired” and “pidachieved”. Alternatively you can view the oscillation number by selecting “pidSRate”

By the way, if possible please capture the parameters before and after the tuning process. Ideally a log file from when the tuning was run would also be greatly appreciated.

Thanks very much!

6 Likes

Would you post (or point to) a Pixhawk4 binary?

1 Like

@Christopher_Milner,

Great, thanks very much for helping test. I’ve posted a link for the Pixhawk4 above (I’m keeping the links consolidated so that they’re easier to maintain in case of updates)

I’ll take a PixRacer firmware please. The Rover is pretty dialed in but why not try it!

1 Like

@dkemxr,

Thanks very much! I’ve added a link for the pixracer above as well. Hearing that it makes things worse is also useful feedback :-).

By the way, the biggest issue I’ve seen in simulator testing is actually with Circle mode if the target speed (e.g. CIRC_SPEED) is set too high. The vehicle’s path can get very wonky if the vehicle can’t keep up. I’ll add an automatic slow-down feature over the next week or so to avoid this.

I also run this quiktune script on my AION robotics skid-steering rover yesterday and it seemed to work. It came up with gains that were quite a bit higher than I had set them but I got the feeling that they worked better than the original tune. What I haven’t checked for yet is over active motor outputs… which is a danger if the gains are too high.

What would be the best way to perform a current version test before a Flash and run with the Alpha firmware Quicktune for comparison purposes?

@dkemxr,

Yes, very good question. I was thinking that a square (or rectangular) mission with at least some legs long enough that the vehicle can reasonably get back on the path.

We’ve received reports of problems with vehicles wobbling on long straight paths and also with bad (or inconsistent) performance at corners.

Here are the relevant issues just for reference (not expecting anyone to actually read all this)

1 Like

Worked thru one simple issue but now getting
-quicktune.lua
06-Jun-23 09:04:40 PM : Lua: Insufficent memory loading /APM/scripts/rover

Hi @dkemxr,

I think the issue is the autopilot may not have enough memory. Hopefully it is possible to increase the SCR_HEAP_SIZE parameter. H7 boards get 204800 by default but the script shouldn’t require quite this much. Maybe try 130000?

Guess it’s time to upgrade the old PixRacer. With 130000 I get:
Scripting: Unable to allocate memory
PreArm: Scripting: out of memory

1 Like

The first error you got indicated more heap size needed. The second indicates the heap size was too much. Maybe try small decrements from 130k and see if you can get it to barely scrape by at some point.

Thanks Yuri. I did try incrementing down and at 2X the default for the PixRacer (which is 44032) it still wasn’t getting it. Didn’t try lower. I’ll put something newer on it.

1 Like

Darn I have a boat with a cube black and a cpl little rovers with pixracers. It just seems that the code is really pushing these little boards a bit nowadays. I was really excited to see a rover tune but looks like I’ll have to wait until I upgrade to H7’s across the board!! I have struggled to grasp rover tune hahaha. @rmackay9 is there nothing we could cut out in custom build server that would allow scripting on the f427 which is what the pixracer and OG cube black have (i think)

Pretty sure most F4 boards simply won’t suffer the demand of the scripting engine. Even the F7 based boards can present challenges depending on the variant. The Cube Black supports scripting but runs low on RAM pretty fast.

I hope to get some QuikTune testing done by early next week. Looking forward to it!

2 Likes

May I request for a pixhawk6c binary please?

Any chance I could get it for pixpilot v6? making better progress with my one arm than I thought!

1 Like

@leichen, @406FPV,

Thanks for the help! I’ve put links above to the two binaries.

2 Likes

How tuned does this rover need to be before we use quicktune. I am starting from scratch with this build.

@406FPV,

Ideally it shouldn’t need to be tuned before using Quiktune but there is a risk that it might drive all over the place until it finds good gains. So if you have a wide enough testing area it will eventually work I think. … just make sure that the motor directions are correct though, 'cuz it won’t correct reversed steering or throttle on its own.

We can improve on this early wild driving by improving Circle mode actually so that when the vehicle is too far away the target point moving around the circle stops until the vehicle catches up. This is on my to-do list…

1 Like

Hi @rmackay9,

I would like to try cube black for rover and boat, which binary to use with cube black,

I’m try pixhawk 1 with my old pixhawk but it’s show message like not enough memory to run script.

Regards,
Kai

Phuket
Thailand