Dear All
I have built an autonomous grass mowing machine for my garden.
It is set up to mow lanes that are 17 inches apart due to the blade size of the mower. All the software needs to do is drive the chassis up a lane to a waypoint and then makes a 180 degree turn and drive it back down the next lane to the next waypoint which is located 17 inches over to one side of the first waypoint. I need the chassis to stay dead on the track between the 2 way points.
It uses a pair Ublox C94 M8P RTK gps with a reliable AHRS compass (with very little distortion due to magnetic or ferrous material). The vehicle follows waypoints by calculating the difference between the target heading (maths and the gps) and the actual heading (compass) and it uses the difference to send a value in a drive command to the motor controller that alters the speeds to the 2 driving wheels. this variable is called turnSpeed. the chassis is differentially driven.
After many months of work the mower drives well. The heading errors are generally below 5 degrees. However if the mower for some reason gets off the straight line track between the 2 waypoints the code does not do a good job of getting the mower back on the straight line track quickly as it is aiming at a distant waypoint. In short, it is good at heading to a distant point but not good at getting on the straight line track between the 2 way points and then heading to the next point
In order to solve this we started calculating a cross track distance error. And we use a set point of 0 cross track error and use a PID to try to get the vehicle back on the straight tract between the two waypoints.
The problem now is that we have 2 inputs to the motor command variable turnSpeed. One from the heading error and the other from the PID. So this is getting real confusing.
Normally I would use the heading error variable if the heading error is greater than 2 degrees. To get the cross track PID tuned I eased off the heading error so that the heading error only works if the heading error is more than +-20 degrees. I set Ki and Kd to zero and increased Kp until the mower went in to a stable oscillation.
I then timed the period of the oscillation for 1 complete wavelength it was 6 seconds.
I then used the following
New Kp= Kp*0.60
New Ki = Period/2
New Kd = Period/8
this gave Kp=5
ki= 3
Kd= 0.7
before this I did many other runs and got poor control response. After running this the mower is still in an oscilation.
I would really appreciate some help here.
1 What are the general mathematical concepts that need to be employed to drive a robot along a straight path between 2 waypoints. Especially to get back ontrack if it gets off track
2 Can we expect our method to work when with have 2 inputs to the same variable, heading error and the PID
3 Do you have a rule of thumb method to tune the PID in this case
Any help on this will be appreciated
regards
Max