- Home /
How to accurately transfer torque?
I've been stuck on the following problem for 2 days.
I have the following scenario: http://i.imgur.com/tgrYtye.png
Red gear that has a motor with ratio 1
Blue gear that receives the torque (ratio 0.5 relative to red)
Green gear that is attached to blue gear (ratio 0.5 relative to blue)
White wheel (roller) that is attached to the platform and moves with it
Black gear that is attached to the roller and to the green gear with an invisible belt (ratio 0.33 relative to roller, ratio 1 relative to green)
For a simpler environment, we are going to ignore friction (except on the roller).
There are two conditions:
- Red gear has to be rotated by applying physics torque
- Transferring torque through collision is forbidden (it won't be accurate with high torque and the simulation will die fast)
I'm not sure how exactly AddTorque(p) works. If:
r = position vector
F = force vector
T = Torque vector
then:
- if p = F. Then is r equal to the length of the unity gameobject taken from the Renderer/Collider?
- it's not possible that p = r and F = unit vector, because I won't be able to specify direction.
- if p = T, then r is an unit vector. But I've tested it, and objects with larger radius rotate slower, which makes it unlikely (unless my tests were not accurate).
It's not that important for our problem though. Continuing with it.
We are going to assume that the pitch is the same for all gears. So:
If I were to rotate the red gear with 10Nm, then:
Blue gear should rotate with 5Nm
Green gear should rotate with 2.5Nm
Black gear should rotate with 2.5Nm
Roller should rotate with 7.5Nm
RPM is irrelevant in this scenario.
I know that it's the wrong end of the chain of where usually the motor is, but ignore that.
One of the first things I tried was Configurable Joints, but they give no option to pass ratio, so in this case, they will all be considered as equal-sized gears.
What I tried was make a script that passes the torque along. I thought it won't be that hard. Well, it is, and with my limited physics expertise (currently learning), I feel like I hit a brick wall.
One thing is certain, I need to lock them all in place, like this:blueGear.angularVelocity = redGear.angularVelocity * -0.5f;
Equalizing them with torque will make an unsynced mess.
If they were all freely floating, it's okay, but the roller has additional weight (the rectangular platform + the hinged gears), and friction with the plane. Angular drag will also disrupt the sync.
Problem one: I need to lock the angular velocity in the reverse order. So if I were to suddenly stop the roller (or the blue gear), red gear should feel the same velocity reduction.
Problem two: Resistance on each object should affect the motor. Passing angularVelocity does not apply it's own force, but is rather duplicating it, and therefore the only energy loss it's experiencing is what the red gear is experiencing (in this case angular drag).
Problem Three: If I were to lock them suddenly, they should all experience velocity increase/decrease.
- If I accelerate the red gear, and lock them all, the roller should slide a little, before regaining traction.
- If the platform is going downhill, and the red gear is stationary, if I lock them, the roller should have a sudden decrease of velocity (Which will cause a slid).
Solution One: Applying Torque with the opposite force vector from end to start.
Problem: To accurately account for the reverse torque, I have to get all the child objects, mass, drag, angular drag, all joints that have axial lock, block, etc. I might as well write my own physics engine.
Solution Two: Take the configurable joint, and add 'ratio' to it.
Problem: Unity is not open source, and I don't see an option to make my own configurable joint. Really, the lack of 'ratio' and 'reversed' (red and blue gear rotate in opposite direction) in the configurable joint is the only thing that is causing this headache.
Is it a trivial problem, or am I trying to do something that is way above my physics knowledge?
On the other hand, have I reached the Unity's capacity? Should I not use Unity's physics for anything more complex than falling cubes?
I don't want to use Torque3D or UE4, since I like Unity's GUI the most, and I do not know C++.
I'd really like to use Unity for my project, but I feel like I hit one of Unity's weaknesses - trying to work with low-level stuff outside of the tools it provides.
Hi. Did you find answer? I'm thinking on this problem too
maybe you'll find answer here http://digitalopus.ca/site/pd-controllers/