 So I’ve been working on my chassis for the past week, experimenting with unsprung mass, and now I’ve moved onto realistically simulating suspension and I feel like I have my chassis, in terms of constraints and physics, in a valid state.

However, now comes the part that involves a lot of calculations: transmission, rpm etc.

I read a post here about vehicles (I specifically read the solution) and right at the very bottom of the solution, Wunder_Wulfe mentions:

So I’ve read online that, to calculate RPM of a wheel, I get the speed of the vehicle and divide it by the circumference of the wheel. However, here Wunder_Wulfe mentions that the “better” way is by “checking slowest and fastest spinning wheel”.

Could anyone provide an explanation as to what he means by this? What would I do with such information? How would this tie into calculating the RPM?

Any help is appreciated!

Thanks, DaR3ka

2 Likes

So I take it this would have something to do with gear ratios?
The car I’m simulating is a Mazda RX-7 and I found some sort of site to do with gear ratios here.

Do you by chance have any sort of idea/knowledge of what I’d do with these ratios to calculate RPM or are they unlinked?

I found this article on Quora and it seems helpful, so I’ll do some digging and see what I can figure out for myself!

I appreciate the reply too, you put things in a different perspective for me. I was beginning to worry my post would never be seen or replied to- guess I’m too impatient lol

Car Gears:

Neutral: any speed?
Reverse: any speed?
1st gear: 0 - 10 mph
2nd gear: 10-25 mph
3rd gear: 25-45 mph
4th gear: 45-65 mph
5th gear: 65+ mph

That being said, lets pretend that you are in 1st gear…

Let’s pretend that your RPMs can go anywhere from 0 to 8 RPM (x1000)

if you are going 10 mph, you could make a ratio between the max speed (for the current gear) and the car’s speed to determine the RPMs (simulation)

In this example, you could take your car speed of 10 mph / gear speed range * max RPM (8) to find the estimated RPM

3 Likes

If you are in 1st gear and going 10 mph, you could estimate that you are at 8 RPMs (which shows that the car should shift to 2nd gear as soon as possible).

Example:

*Current Car Gear: 1st gear --> Current Car Gear Max Speed: 10 MPH
*Current Car Speed: 9 MPH
*Max RPM = 8

Car RPM = (Current Car Speed / Current Car Gear Max Speed) * (Max RPM)

^Which equals 7.2 (x1000) RPM (in 1st gear, going 9 mph)

note: None of the math above is actually real, but it does a good job of simulating the RPM numbers which can be used in vehicle speedometer GUIs. The logic I provided resembles the behavior of automatic transmission cars (which is most cars). That being said, your script should make sure that the current selected gear integer variable changes when it gets to a certain range. Also, the speeds correlating to the ideal gear are in MPH, so you will have to make up your own numbers using studs per second.

4 Likes

Just finished re-reading and this is beginning to make a lot more sense to me now, thanks a bumch for the reply. From what you’ve said here I’m fairly certain I should be able to do all the calculations for now.

Thanks a bunch for the help! (Side note: if anyone wants to add more, feel free, I’ll still be keeping an eye on the thread)

3 Likes

The way I worded it is a little confusing, but it should provide a decent simulated way to calculate rpms.

Within your code, you could have the car’s gear change whenever its speed falls into 1 of those categories (ignoring neutral and reverse right now).

example: car speed = 5 mph --> set gear to 1st gear

–> then calculate rpm based on the selected gear

1 Like

In actuality, RPM is based on the wheels that are powered by the engine. Much like how you could derive wheel torque and RPM from the engine, you can do the opposite and reverse the process (you would need a clutch or torque converter when the wheel is idling to prevent engine stalls, (0 RPM)) and gears would divide the gear ratio because higher gear ratios mean more torque is gained in turn for less speed. You would also need to account for things like Final Drive (or the wheel differential ratio). This of course is the more complex and accurate way of simulating a vehicle, in accordance with vehicle engineering and the topic someone else replied with.

To get the rpm accurately regardless of what orientation the axis that the wheel is spinning on, use RotVelocity.Magnitude in your scripts

Incorrect as the wheel RPM is based specifically on the axis of rotation. `RotVelocity:Dot(spinAxis)` where `spinAxis` is the axis the wheel rotates around, i.e. the RightVector for all Cylinders. Not only does this get the direction the wheel is spinning in (forward / backward) but it also its more accurate, not taking into account the rotation of the wheel if the vehicle was say, spinning out.
Also, that is not the RPM (Revolutions Per Minute) it is actually the rad / s (Radians Per Second), so you would need to use unit conversions to convert. One full revolution is `2π`, so `X rad/s / 2π = X RPS` and if this is how long it takes for one second, you need how long it would be for a minute (60s), so `X RPS * 60 = X RPM`, the final conversion being `X * 30/π` after simplification. Also don’t forget that the RPM of the wheel is not the same as that of the engine. You could also use tangential velocity if you want to do stuff like make all wheels rotate at differing speeds, but move at the same speed. That equation is `vel = radius * rad/s`, so to solve for `rad/s` for the `AngularVelocity` property, you could use basic algebra and get `vel / radius = rad/s` with `vel` being the target velocity for the wheel, and `radius` being the diameter of the wheel (from .Size property) divided by 2. I suggest working with these values rather than RPM directly, as this gives you much simpler control over the speed of the vehicle without worrying about things like differential ratios.

3 Likes
`````` Very nice explanation, I have also discovered something that could be considered important. According to what I've observed, if you multiply the Rotvelocity number by 10 you get the actual RPM in real life. How did I figure this out?
It may sound strange but I have calculated this by using my washing machine (which can display the rpm of the drum if you press certain buttons) and a spinning part with a clicker that clicks once every revolution. The part with a RotVelocity of 50 was spinning the same speed as the washer spinbasket when it was spinning 500 rpm. The same thing occured when the machine was spinning at 800 and 950 rpm which suggest the relationship in rpm to be linear. Every rpm of a real life object I have compared to my testing model, the ratio was the same; the actual rpm was 10x the RotVelocity``````

Very nice explanation, I have also discovered something that could be considered important. According to what I’ve observed, if you multiply the Rotvelocity number by 10 you get the actual RPM in real life. How did I figure this out?
It may sound strange but I have calculated this by using my washing machine (which can display the rpm of the drum if you press certain buttons) and a spinning part with a clicker that clicks once every revolution. The part with a RotVelocity of 50 was spinning the same speed as the washer spinbasket when it was spinning 500 rpm. The same thing occured when the machine was spinning at 800 and 950 rpm which suggest the relationship in rpm to be linear. Every rpm of a real life object I have compared to my testing model, the ratio was the same; the actual rpm was 10x the RotVelocity

what…? No, it is not actually 10. it is `60 / 2π (aka 30 / π)`, do you know what `π` is? `3.14......` and `30 / 3` is `10`, but you are not supposed to round `π` in equations. I showed the calculations above, make sure to read through them to understand. Also, of course the relationship is linear. RotVelocity is in `radians per second`, so `revolutions per minute` is just a simple unit conversion that represents the same exact value. It is still `rotation_type / time_type`.

1 Like

But yet at 50 RotVelocity the part is spinning at 500 rpm,10 RotVelocity is spinning at 100 Rpm, the relationship is linear. I literally timed it with sound and visuals. Every click is 1 rpm and the rotation speed matches by x10. I figured this out because my washing machine can display the rpm on its screen. No need for complex math here. It is a simple comparison using the senses that has proven accurate for me time and time again

Im gonna use this way, but do I need to calculate RPM in a while loop? On client? On Server?

If you are simulating an RPM number for distorting the engine audio, then maybe in a server script. I’m pretty sure this is what Rocket League does for their engine audio mechanics…

If it’s for an animated GUI or something similar, then I would script it inside a local script.

Little off-topic but here’s an interesting video from Rocket League’s lead programmer that talks about some of these concepts:
Rocket League Physics Explained

client-side example:

``````local rs = game:GetService("RunService")

rs.RenderStepped:connect(function(dt)
--inside the loop
end)
``````

server-side example:

``````local rs = game:GetService("RunService")

rs.Heartbeat:connect(function(dt)
--inside the loop
end)
``````

Multiply the RotVelocity.Magnitude of the part x10 to get the actual rpm that the part is spinning at. Not Rotvelocity.X, Y, or Z, because they depend on the vector of which the part is orientated to calculate a number. For straight RPM no matter which direction the part is facing multiply the RotVelocity.Magnitude of the part x10

Besides, again, wheels always rotate around their axes. Wheels rotate on a hinge, and that hinge only spins in one direction. So you need to use `RotVelocity:Dot(spinAxis)` to get the correct rotation direction and amount. This not only allows you to get whether or not a wheel is spinning forward or backward, but also how much it is spinning in the only axis that actually matters. Also, again, `30 / π` is `9.5492965855...` which may be close to 10, but it is not the same thing. Accurate calculations should use this ratio instead. Your calculations were probably inaccurate / estimates of the actual values. I recommend learning about dot products and some rotation conversion calculations.
http://hyperphysics.phy-astr.gsu.edu/hbase/rotq.html and https://en.wikipedia.org/wiki/Radian_per_second are good starts.

(the 60/(2π) aka 30/π already mentioned to verify). It is not complicated math, but it is pretty useful.

``````local ratio: number = 30 / math.pi

local angularVelocity: number =
cylinder.RotVelocity:Dot(
cylinder.CFrame.RightVector --or you can use the WorldAxis for the attachment
)

local wheelRPM: number = angularVelocity * ratio
local wheelVelocity: number = angularVelocity * wheelRadius --tangential velocity
``````

Some useful things to do with this information:
Weighted average of wheelVelocities:

``````local totalTorque: number = 0
local averagedVelocity: number = 0
for i, wheel in ipairs(myWheels) do
totalTorque += wheel.TorquePercent
averagedVelocity += wheel:TangentialVelocity() * wheel.TorquePercent --or base it off of wheelRPM
--this way might be easier because it works for wheels of all sizes and allows for easier speed limiting
end
if totalTorque > 0 then
averagedVelocity /= totalTorque --this would get the average wheel movement speed
--this is great because free-spinning wheels (0% of torque output) have no effect on this number
--and you can balance this value based on power output, so this works for FWD, RWD, and AWD cars
end
--then you can use this property in things such as pitch shifting
``````
2 Likes