Page 1 of 1

How to write script about Spring?

Posted: 03 Jan 2020, 09:56
by Elin
Hello,

I want to make a simulation like this: There is a spring standing on the floor, an object falls down on the spring, the spring shorten and the object's height reduce. Then the spring oscillations and object follows it. Because I don't know how to make the simulation of a spring's motion. So could you offer some tutorials or learning materials ?

Thanks.

Re: How to write script about Spring?

Posted: 03 Jan 2020, 15:54
by fferri
If the question is about how to make a spring:
coppelia wrote: 14 Feb 2014, 10:44 For a spring, you have Hook's law: \(F=k x\)

where \(F\) is the force of a spring, \(k\) its constant, and \(x\) its displacement (or stretch/compression).

In CoppeliaSim, set your joint (let's suppose it's a prismatic joint) into torque/force mode, the motor enabled, the Control loop enabled, Position control (PID) selected, and Regulate torque/force selected. You can do all this in the joint dynamics properties.

With above settings, your joint will exert a force: \(F=F_{max} \left[x P + e I + (x-x_{previous}) D\right]\)

where \(F_{max}\) is the max. torque/force item, and \(e\) the integrated errors