I am automating a tractor, which runs very slow (less than 1km/h).
It’s running ok, but I wonder about the servo rate. I haven’t changed the default from 50Hz. However, when analyzing logs, it seems the servo rate changes at 10Hz, not 50. Why is that ? And is there a possibility to do this only at 1 or 2Hz and smooth the output accordingly.
Log file, a video and parameters can be found below.
Thanks for the log and the video, the tractor is looking really good.
The output rate (50hz) is separate from the RCOU messages that appear in the logs (10hz) because the log files would become unmanageable if we logged every output to them.
I’m not sure that lowering the servo output rate will help, I suspect it will make things worse because lowering the servo output rate should make the outputs less smooth. Instead of changes being spread out over 25 to 50 output updates, they would be concentrated on larger jumps every 0.5 to 1sec.
Slow vehicles are quite difficult to tune because their gains are a long way from the standard values and also the vehicle’s movements are way down close to the noise level. What I mean by that is that there’s a certain amount of noise in the environment (rocking of the vehicle, even just the random noise that all sensors produce) and as the vehicle slows, its movements eventually fall down into that noise band and it’s difficult for the controllers to see the difference.
The video of the vehicle turning looks quite good, are you seeing some issues?
ArduPilot is doing fine on the tractor. In the log I sent, the error on a straight line of 50m was still +/-20cm, but I got that down to half in the mean time. And the remaining error is due to imperfect steering mechanics (I will do a different topic for that).
I am attaching a screenshot of NTUN XTrack vs Steering RCOut. The RCOut follows the XTrack error (about 2minute oscillations around the straight line, peak to peak 1500 to 1580) but it also has a “noise” component (peak to peak about 10-20) on top of that which is caused by tiny position errors (many reasons for that, but the rocking/vibration of the vehicle is one of them). I wonder whether this can be smoothed out because it doesn’t seem right and although tiny it does consume battery power.
OK, so this is a very mild case of “wobby path” (as we call it). I think the solution is to increase PSC_VEL_FF which is mentioned on the Position Controller wiki page but probably incorrectly says that it should always be zero. I wonder if you could try a value of 0.5 to see if that helps?
That’s a very slow rover! Tuning is a bit difficult at that lower end.
I’ve had some success with similar speed (albeit on a much smaller vehicle). Looking at your logs, a number of maximum speed and steering parameters are set too high (beyond what the vehicle can achieve):
Your CRUISE_SPEED and CRUISE_THROTTLE are way off. I’d suggest a CRUISE_SPEED of 0.13 and CRUISE_THROTTLE of 80
Likewise set WP_SPEED to 0.13
Decrease ATC_STR_RAT_MAX (max turn rate) to a realistic value for the vehicle - that looks to be around 40 degrees/sec. Also decrease ATC_STR_ACC_MAX to 20 degrees/sec/sec
That should (along with @rmackay9’s advice above) help reduce the wobble.
I would note that the sorts of turns you’re doing (<10 degrees/sec) are typically far slower than what a typical vehicle does, and will likely require larger-than-typical PID values.
Actually, for the speed I was going to ask this in a different topic, but here goes.
This tractor has a throttle lever that acts as a binary switch, you kick it in forward and it starts moving at a constant speed. Actual position of the lever doesn’t matter. So, I figured the speed settings didn’t matter that much.
As for the turning parameters, I will try your suggestions.