I have a hobby project in Unreal Engine 4, where I try to build some sort of template for simulation of tracked vehicles. It was going rather well until a point where I've tried to investigate why it's so difficult to steer tracked vehicles. If you want to see how it work right now you can grab executable from the first post:
if you have experience with blueprints in UE4, the link to the git repo is in the same post.
I don't think it's possible to describe all implementation details as post will be rather long and difficult to follow, but I'll try my best to squeeze in the description of how friction specific sub-system works and which part is a source of major headache.
There is a simple simulation of the engine connected to gearbox, axle and then steering differential. Angular velocity of axle is integrated and used as input into calculating torque output of the engine and angular velocity of the sprockets which pull tracks.
The traction of the vehicle is based on friction and comes in two parts:
1) Torque coming from the engine, which creates an opposing force at point of contact
2) Relative velocity of the track at point of contact
The way it's processed is rather simple:
- the assumption is that we run calculation only at points of track directly under the road-wheels and only if road-wheels are in "contact" with the ground
- at each contact point we calculate relative velocity of the vehicle (linear velocity of root + linear velocity as a result of vehicle rotation)
- linear velocity of the track itself is calculated from angular velocity of the sprocket which pulls it
- from relative velocity of the vehicle we subtract linear velocity of the track and project it on the surface of the ground, which gives us a final relative velocity of the track in relation to the ground surface
- from final relative velocity we calculate a total force necessary to completely stop the vehicle (taking into account multiple contact point), by multiplying velocity by mass of the vehicle and dividing by delta time to turn "impulse" into force, let's call this velocity induced force
- the other part of friction is calculated as force opposing torque from engine, let's call it torque induced force
- velocity and torque induced forces are summed up and let's call their sum "total stopping force", we can't apply it yet as we need to take into account normal force and friction coefficient
- normal force at contact point is calculated using suspension of the road-wheel
- using normal force and friction coefficient we get an upper bound of friction force
- "total stopping force" is capped in magnitude by upper bound of friction force and resulting force is applied to chassis of vehicle
Now I need to apply some of this friction force to the track itself, so for example tracks can roll in neutral on the slope. This is where it get hairy. My reasoning was that I can take friction force which was applied to vehicle and calculate which portion of it would be applied to track. For this I just
divide final friction force by the mass of the vehicle and then multiply by the mass of the track. Resulting force is turned into torque and applied to the axle after calculating angular acceleration. Does this make sense?
There were couple of problems with my variables, first the moment of inertia of track and sprocket (rest of transmission was ignored) were not calculated properly and total mass of the tracks was 3 times lower than it was supposed to be. I've recalculated moment of inertia into more realistic range but main problem arrived when I changed mass of the tracks. As mass of the track went up, the friction force effecting track became larger as well, at this point of time it's so large that tanks can barely do a neutral turn.
I'm not sure where the bug is, perhaps my engine torque is just too weak (maybe I forgot to take into account gearbox) or my logic of applying friction to the track itself is completely off. In latest compiled version of the project I had to make downsize force effecting track to about 6 times.
Maybe someone has an idea of what I'm doing wrong. Most likely I have some heresy in the physics model that I'm trying to apply or perhaps only "velocity induced force" should be applicable to the track and not "torque induced force" as it already adds velocity to the track (realized this when I was writing this post).