Simulating Ratchet Mechanism
Simulating Ratchet Mechanism
Hello, I am trying to simulate a robot that has a ratchet mechanism (which will allow the joint and robot to rotate clockwise, but restrict rotation in the counterclockwise direction). I was wondering how I could achieve this using CoppeliaSim as I am a fairly new user. Is there a feature that restricts passive joint rotation in one direction? If not how exactly could I accomplish this?
Re: Simulating Ratchet Mechanism
So I was thinking of achieving this using sim.getjointForce to check if the torque applied to the joint was positive or negative. And if it is negative then write a zero velocity to the joint to restrict it from moving in the opposite direction. I do not require specific position control from the joint that the joint callback provides. Would you recommend implementing this method in the joint callback function within the joint child script or writing it in the main robot control script?
Thank you
Thank you
Re: Simulating Ratchet Mechanism
Hello,
I would put that inside of a joint callback function, inside of a child script attached to that joint. And don't check the torque applied to it, but the movement direction instead. Something like:
Make sure that your joint is dynamically enabled, the motor is enabled, and the control loop is enabled too (and you are in position control).
Cheers
I would put that inside of a joint callback function, inside of a child script attached to that joint. And don't check the torque applied to it, but the movement direction instead. Something like:
Code: Select all
function sysCall_init()
jointHandle=sim.getObjectHandle('joint')
lastPos=sim.getJointPosition(jointHandle)
end
function sysCall_jointCallback(inData)
dx=inData.currentPos-lastPos
dx=math.atan2(math.sin(dx),math.cos(dx))
lastPos=inData.currentPos
local outData={}
outData.velocity=0
if dx<0 then
outData.force=0
else
outData.force=10
end
return outData
end
Cheers