Need help with finding out a way to automatically calculate a value

(not so sure if this is the right category…)

For a while I’ve attempted to find a formula to try and calculate the wait time inbetween pushes for my bell system.

However, I’ve encountered one specific issue which is, well, calculating the value itself.

Here’s what I wanna achieve.
I want a wait time to be auto calculated so that the bell can swing up properly without needing to constantly play test to try and guess the right number.

Now… The ISSUE.
If say, I duplicated a bell, who’s wait time is 1.1, and quadrupled it’s size, you’d expect the wait time to also quadruple, right? You’d be dead wrong. The actual wait time for it to swing up properly is 1.3, FAR from quadruple…

Now, here’s the actual values…

Smaller bell’s mass - 5349.214715863694
Smaller bell’s wait time - 1.1

Bigger bell’s mass - 20849.91020227736
Bigger bell’s wait time - 1.3

And of course, in case that’s needed, the workspace’s gravity is 196.2 (default one)

So uh, yea, hopefully this will be able to go somewhere…

I’m rlly struggling to picture what’s happening so, images and maybe some code/description of the motion would be nice

But

For a ‘simple pendulum’ the approximate equation is:

image

Notice how it is independant of mass. Assuming your smaller bell is about 25cm from pivot to end, (L=0.25m) then at Earth’s gravity of 9.8 you get a period of 1.0035 seconds.

Your mass quadrupled so your length probably doubled. At L= 0.5m, thats 1.4192 seconds.

At small values of L, T hardly changes. Note that this equation is in real-life units, I’m unsure if using roblox studs for L and roblox gravity for g will work. Also this is for a simpler pendulum than you likely have, and who knows how accurate roblox physics is anyway, also roblox may have air resistance to some extend, idk.

I also may have interpreted your situation very wrong.

But if you’re lucky this may be helpful.

3 Likes

That’s uh, another issue… Here all we’re accounting for is mass really (and possibly that in relation with garvity?)… Not speed or anything…

Here’s some pictures here, there’s no need for code snippets as all there is is just a mass calculation one which calculates the bells’ masses, there’s nothing that auto calculates the wait time yet.

How the bell works is that it’s pulled by 2 ropes, pulled by prismatic constraints, so it’s basically not really a pendulum…



Oh and uh, going back to this, lenght here won’t really work, as a bell might be of that lenght but also be of a different mass, so the bell might swing too fast / too slow so it will never get to it’s full swinging state, so it won’t really work.

Actually, here’s a little snipped on how it handles the swinging…

--LOOP

local LOOP = coroutine.create(function()
	while true do
		script.PULL1.Velocity = -BELL_MODULE.BELL_INFORMATION.MOTOR_VELOCITY_1
		script.PULL2.Velocity = 0

		script.PULL1.MotorMaxForce = BELL_MODULE.BELL_INFORMATION.MOTOR_FORCE
		script.PULL2.MotorMaxForce = 0

		script.PULL1.ActuatorType = Enum.ActuatorType.Motor
		script.PULL2.ActuatorType = Enum.ActuatorType.None

		if BELL_MODULE.BELL_SETTINGS.AUTOMATIC_WAIT_TIME == false then
			task.wait(BELL_MODULE.BELL_INFORMATION.WAIT_TIME)
		else
			task.wait(AUTOMATIC_WAITTIME)
		end

		script.PULL1.Velocity = 0
		script.PULL2.Velocity = -BELL_MODULE.BELL_INFORMATION.MOTOR_VELOCITY_1

		script.PULL1.MotorMaxForce = 0
		script.PULL2.MotorMaxForce = BELL_MODULE.BELL_INFORMATION.MOTOR_FORCE

		script.PULL1.ActuatorType = Enum.ActuatorType.None
		script.PULL2.ActuatorType = Enum.ActuatorType.Motor

		if BELL_MODULE.BELL_SETTINGS.AUTOMATIC_WAIT_TIME == false then
			task.wait(BELL_MODULE.BELL_INFORMATION.WAIT_TIME)
		else
			task.wait(AUTOMATIC_WAITTIME)
		end
	end
end)

ASSISTED_PUSH_PARTS.S1.Touched:Connect(function(hit)
	if hit.Name == TOUCHY_THINGY.Name then
		ASSISTED_PUSH.Value = true
		print("Pull 2!")
		script.PULL1.Velocity = 0
		script.PULL2.Velocity = -BELL_MODULE.BELL_INFORMATION.MOTOR_VELOCITY_1

		script.PULL1.MotorMaxForce = 0
		script.PULL2.MotorMaxForce = BELL_MODULE.BELL_INFORMATION.MOTOR_FORCE

		script.PULL1.ActuatorType = Enum.ActuatorType.None
		script.PULL2.ActuatorType = Enum.ActuatorType.Motor
	end
end)

ASSISTED_PUSH_PARTS.S2.Touched:Connect(function(hit)
	if hit.Name == TOUCHY_THINGY.Name then
		ASSISTED_PUSH.Value = true
		print("Pull 1!")
		script.PULL1.Velocity = -BELL_MODULE.BELL_INFORMATION.MOTOR_VELOCITY_1
		script.PULL2.Velocity = 0

		script.PULL1.MotorMaxForce = BELL_MODULE.BELL_INFORMATION.MOTOR_FORCE
		script.PULL2.MotorMaxForce = 0

		script.PULL1.ActuatorType = Enum.ActuatorType.Motor
		script.PULL2.ActuatorType = Enum.ActuatorType.None
	end
end)

Some questions:
-Do you just want something to happen whenever the bell reaches a certain angle/stops moving or do you rlly need the wait time
-Is the wait time the time between its rest position and maximum angle?

It looks like your bell turns until you tell it not to so, assuming your code wishes to wait for a certain angle, and the angle should be the same regardless of bell size, you can constantly check the angle:

local downVector = Vector3.new(0,-1,0)

while (bellEndPosition - pivotPosition):Angles(downVector) < targetAngleInRadians do
 task.wait()
end

You could even just run that once and store how long you waited and use that later as a near-accurate approximation

local delta

if not delta then
  local startTime = tick()
  
  while (bellEndPosition - pivotPosition):Angles(downVector) < targetAngleInRadians do
    task.wait()
  end
  delta = tick()-delta
end

You probably need to account for negative angles and stuff

If the angle isn’t meant to be the same then I ask, what is the wait time waiting for?

Ok, hold on, here’s a video demonstrating what the system does.

Basically, there’s a detector, and there’s 2 parts.

If the detector touches the parts, the bell starts swinging on it’s own without the need of wait time.

External Media

(ignore the spring on the clapper, that’s gonna be implemented soon to make it stop more realistically)

ALRIGHT WELL, THE TABLES HAVE TURNED, I MANAGED TO GET THIS WORKING.

Well, partially that is.
How I got it working is that the bell has invisible weights which of course, depending on bell scale, that would variate.

Here’s the specific snippet!

math.pi*2*math.sqrt(BELL_WEIGHTS.MAIN_WEIGHT.Size.Y/workspace.Gravity)

I fine tuned it to fit the original result of the original bell better and well, let’s just say that it works, until we get to the originally scaled up bell (quadruple of the original bell’s size).

It seems like doubling (?) and halfing it’s scale works but quadruple still requires some fine tuning… Which I’ve implemented with a value that you can change to have it be actually functional.

It does get qutie close to the desired value! (1.4875892140804279 to be precise) so I will consider this as a… Partial win? Possibly I’ll try and figure out a way to auto calculate the fine tune value, which should be WAY easier knowing all of this now…

Thank you so much for the help!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.