Advertisement

Wheel angular velocity torque integration

Started by October 04, 2024 11:27 AM
2 comments, last by EllisCopper 18 hours, 50 minutes ago

Hello, i was wondering if anyone here knows good methods to integrate 3 torques into a wheel's angular velocity in a physically correct manner? The 3 torque's i have are:

  1. Torque from drivetrain
  2. Torque from brakes
  3. Torque from friction

For now the friction torque is calculated as the following pseudo code:

frictionTorque = sign(vehicleLinearVelocity / radius - angularVelocity) * 1000 * frictionCoefficient * radius; // 1000 is Nm normalForce

The brakeTorque is just calculated as:

singedbrakeTorque = -sign(angularVelocity) * abs(brakeTorque);

The total torque i apply to the wheel is just a sum of the 3:

netTorque = drivetrainTorque + frictionTorque + signedBrakeTorque;

The issue here is that integrating the net torque like this does not display correct results. If the brakeTorque dominates, the angular velocity will try to go to 0 but there is no limit on the brake torque and this can cause overshooting. If the frictionTorque dominates, the angular velocity will try to match the vehicle speed, here overshoot is also possible.

I have now calculated a limit for the brake torque and for the friction torque which states how much we need to reach the desired angular velocity instantly.

maxFrictionTorque = (vehicleVelocity / radius - angularVelocity) / deltaTime * inertia;

maxBrakeTorque = -(angularVelocity) / radius * inertia;

If we apply these limits before adding the torque to the net torque then we get something more correct if the other torques were 0 but that's not the case in 99.99% of the time. I was thinking about applying to the netTorque but i have no idea how to detect when to limit a torque like the brake or friction torque.
This is where i kind of am lost. Below is the full pseudo code what i know is probably correct so far if i could get the clamps to work after the net torque.

frictionTorque = sign(vehicleLinearVelocity / radius - angularVelocity) * 1000 * frictionCoefficient;

signedBrakeTorque = sign(angularVelocity) * abs(brakeTorque);

netTorque = frictionTorque + signedBrakeTorque + drivetrainTorque;

maxFrictionTorque = (vehicleLinearVelocity / radius - angularVelocity) / deltaTime * inertia; // angular vel to force
maxBrakeTorque = (angularVelocity) / deltaTime * inertia; // angular vel to force

// TODO: adjust netTorque if neccesary based on conditions like the dominant force of the 3

angularVelocity = angularVelocity + (netTorque / inertia * deltaTime);

If anyone has experience with this it would be of great help. I hope i can figure out how to integrate the 3 torques correctly into the wheel angular velocity.

Since brake torque should always be something like -k_brake*angularVelocity * brakeInput, with k_brake a constant > 0, 0< brakeInput < 1, brake torque will always be the opposite sign ov angular velocity, you don’t need those abs() and sign(), getting rid of them will make your code easier to work with.

The problem you’re facing is what everybody face while integrating differential equations. You’re dealing with stiffness (sensitiveness to initial conditions) and instability. You’re actually using the simplest numerical method which is Euler explicit method. It is known to bring the kind of problem you’re facing unless you take a very small time step. You should search and read about other integration methods such as midpoint method, Heun’s method, implicit Euler method (quite hard to understand and implement if you’re new to this field) or Runge Kutta 4 just to name a few. I don’t know if there is a method better suited than the others for your case. But they will lead to better results than explicit Euler for sure.

Advertisement

To integrate the torques correctly, apply individual torque clamps based on the dominant force for each time step, using `min(maxFrictionTorque, frictionTorque)` and `min(maxBrakeTorque, signedBrakeTorque)` before summing them to prevent overshooting.

Advertisement