Fight Detection in Software

Hi all,
Been playing around with ways of sensing whether the user has grabbed the steering wheel, without using any hardware.

My solution was to calculate the derivative of the WAS values, and compare them to the PWM value. If PWM is high but the WAS is not moving (or vice versa), it indicates that either something is broken or the steering wheel is being turned. Either way the system should be disabled under this condition.
As you can see in the video it works fairly reliably, and can be set to be more or less sensitive using the encoder counts value. I’m yet to test it successfully with u-turn, the extreme wheel movements tend to cause disengagement. However, I never did get u-turn to work well on the combine. I will refine the code when I’m testing it on the tractor.

Here’s my proof of concept algorithm, placed into autosteerPID.ino

  angleD = abs(steerAngleActual - steerAngleLast);     
  dCompare = abs((angleD * steerSettings.Kp) - pValue);    
  
  if ((dCompare > steerConfig.PulseCountMax) && (fightDetTimer < millis() - 5000) && abs(steerAngleError < 5)) steerKillCount++;
  if (dCompare < 10) steerKillCount = 0;
  if (steerKillCount > 10) {steerEnable = false; steerKillCount = 0;}

  steerAngleLast = steerAngleActual;
14 Likes

Good work, as much as I like wiring in extra sensors the inferred mathematical detection method is preferred as it gives everyone the chance for steering wheel disengagement.

ACS712 works well but you still have to set it high to keep uturn from popping it off.

I have a feeling you are on the right track! Cool Idea.

Funny, i was just thinking about this as i am creating an autosteer wizard. Very inspiring and this will feed the minds. Great work Charles!

We should be able to do this directly in AOG. Perhaps add it in with the panic stop code.

1 Like

I only work with hydraulic valves and use a pressure sensor (pressure switch) connected to the “remote” input. It works very well if the sensor is in the Ls line, but this is not always possible. For example, in the Lexion combine there is a CC system without Ls (constant pressure in the system) in the valve block I used a swing valve connected to the L, R outputs of the orbitrol. And in such a configuration there is a small problem with the speed of reaction, if we turn on the AS, the proportional valve is faster than the shut-off valves and when we are far from the line, the stroke is high and it disconnects the AS. It would be nice to have a slight delay, e.g. 1 second operation of the remote input. Then all the valves would close, the pressure equalized and the sensor could work well with less pressure.

You could easily tweak your arduino code to do that!

@CQuick did you take this any further?

Similar to @bricbric method;

Yes, it works really well, even in u-turn after some small changes to the algorithm:

if (steerConfig.CurrentSensor)        //If fight detection mode is ON
  {     
      angleDeriv = abs(steerAngleActual - steerAngleLast);                //Fight Detection code - Calculate rate of change of the steering angle
      setPointDeriv = abs(steerAngleSetPoint - setPointLast);
      slippage = abs((angleDeriv * (steerConfig.PulseCountMax / 25.5)) - abs(pValue));      //Compare pValue to change in steering rate. Multiply by user set pulsecount to make a reasonable slippage factor
      sensorReading = constrain(slippage, 0, 255);                        //Send slippage to AOG
      if ((slippage > 200) && steerEnableTimer > 3000) steerKillCount++;    //If slippage is over threshold, and we're more than 3s into steering
      if (slippage < (180)) steerKillCount = 0;                                     //If slippage returns to normal, reset.
      if (setPointDeriv > 3) steerKillCount = 0;          //If the setpoint is moving really fast then just go with it
      if (steerKillCount > 5)                                           //If slippage is not just a spurious value, cut steering.
      {     
        steerEnable = false; 
        steerKillCount = 0;
      }
      steerAngleLast = steerAngleActual;
      setPointLast = steerAngleSetPoint;
    }
2 Likes

I’ve just altered the plumbing on my Baraki valve, Teeing into steering lines rather than routing into valve and out again.

So would like to try your code out of that’s ok?

Powered from Power Beyond so pressure transducer is redundant.

Totally, you’ll need to make a couple changes - my code uses steerEnable because… reasons. But you can just replace it with watchdogTimer = WATCHDOG_FORCE_VALUE instead.

Add the code block in previous post to calcSteeringPID in autosteerPID.ino

Add these variable declarations to the top of autosteer.ino:

float steerAngleLast = 0;           //For fight detection
float angleDeriv = 0;               //Fight detection - steering angle rate of change
float slippage = 0;                 //Output for the comparison function
int steerKillCount = 0;     
float setPointDeriv = 0;
float setPointLast = 0;

Then at the top of the main .ino, instantiate the timer:
elapsedMillis steerEnableTimer;

And set it to zero at the point in the code you read the button press:
steerEnableTimer = 0;

In terms of setting it up, you’ll need to increment the current sensor value in AgOpen’s steer settings by about 10 at a time until you see it start to work, then dial it in.
The green bar should be hovering around 0 - 20 when driving a straight AB line. When you move the steering wheel, then you should see the value rise.
It’s quite sensitive to small variations. I have mine set at about 80, it would be good to hear what value you end up at.

Edited to add some points I missed in the code!

1 Like

Thank you, I will give it a try tomorrow and let you know how it goes and at what values

Whouah ! i missed this !
great @CQuick !

but funny to have a similar idea

we do test with @Daniel ( i need to share )

and we find some other feature
Some delay after engaged because the time to aog to give a result can be disconnect in some condition
Cancel in case of small angle target
and also cancel in low speed

but also i think all this can be put in AOG

1 Like

@bricbric your code working really well with Baraki valve.

@CQuick I may have messed the code up, but when I try it I need a very high % for it not to disengage when acquiring line (like 80%), but then it won’t disengage

If I start on line then it works, but only around 20%.

So with @bricbric code, with Baraki valve and RQH100030 (Land Rover sensor)

Setting Turn sensor to 25 and you have to turn the steering wheel quite fast to reliably disengage.

Setting to 15 and it disengages too easily when trying to acquire AB line, unless you are very close.

I’ve found a setting 18 works really well, easy to disengage when turning the steering wheel calmly. But engages even when far off line.

If going fast and far from the line it disengages immediately, but this is good as it’s likely an accidental engagement of autosteer, so a good safety feature.

Really pleased with how well it works.

Will have a look again at @CQuick code, I think I must of changed something incorrectly.

As one code uses Turn sensor and the other Current sensor, I assume could combine and have the choice of either?

IMO this type of kickout sensing is perhaps superior to the normal Pressure/Turn sensors as it will immediately detect if the WAS arm is physically broken.
If the WAS is electrically broken then autosteer will disengage as soon as AOG doesn’t see a WAS signal, but if the WAS arm breaks or becomes detached it will potentially steer hard left or right until such time (if at all) it reaches the max steer angle limit set in AOG.
Using a WAS error for autosteer disengagement will cause it to disengage long before it reaches full lock.

Thank you, brilliant work @bricbric and @CQuick

Thanks for testing, if @bricbric code is easy to setup and works with u-turn, then I’m happy to say his code is better.
Mine always was a bit difficult to set up - even single digit changes in the value can have a large impact. Looks like his code kicks out with a gentler steering wheel movement than I have to use, too.

I strongly suspect I changed the code with your changes incorrectly I was a bit unsure, however it worked, but I did use big changes in % rather than small increments!

Sorry wasn’t trying to make it a competition! :slightly_smiling_face:

Played with @bricbric for about an hour this morning, I’m pretty confident to trust it and would say its better than having to alter the OEM steering circuit.

@CQuick this was with your code, set at 22%