Hi
I'm a beginner and using CoppeliaSim Edu, ver. 4.2.0.
I wanna incorporate a lead screw(actuation and passive joint) to my model, but I can't.
In my scene hierarchy, I set objects and joints like:
"static object" → "revolute joint" → "auxiliary shape(using cuboid)" →
"prismatic joint" → "screw part"
And then I added a jointCallback function into non-threaded script, I added
child script to prismatic joint.
Using the function, I wanna control the position, but I'm in trouble because I don't
know how to write a script or how to set the pitch for that purpose.
Please let me know if there is an example of how to write a script or one
that actually controls the position of the lead screw actuator.
Thanks.
How to use Screw joint and actuation?
Re: How to use Screw joint and actuation?
Hello,
so you want to create a dynamically enabled screw, which is composed by a revolute and a prismatic joint? Then your approach is correct. You'll also have to make sure that both joints are dynamically enabled, in force/torque mode, the motor enabled, the control loop enabled (e.g. in position control), and add a joint callback function for your prismatic joint, e.g.:
The callback function is basically a simple P controller.
Cheers
so you want to create a dynamically enabled screw, which is composed by a revolute and a prismatic joint? Then your approach is correct. You'll also have to make sure that both joints are dynamically enabled, in force/torque mode, the motor enabled, the control loop enabled (e.g. in position control), and add a joint callback function for your prismatic joint, e.g.:
Code: Select all
function sysCall_init()
revJoint=sim.getObjectHandle('revoluteJoint')
PID_P=0.5
end
function sysCall_jointCallback(inData)
local revJointAngle=sim.getJointPosition(revJoint)
local errorValue=revJointAngle*pitch-inData.currentPos
local ctrl=errorValue*PID_P
local maxVelocity=ctrl/inData.dynStepSize
if (maxVelocity>inData.velUpperLimit) then
maxVelocity=inData.velUpperLimit
end
if (maxVelocity<-inData.velUpperLimit) then
maxVelocity=-inData.velUpperLimit
end
local forceOrTorqueToApply=inData.maxForce
local outData={}
outData.velocity=maxVelocity
outData.force=forceOrTorqueToApply
return outData
end
Cheers