- Home /
How do I grab an object without going through it?
I have a robotic arm and I am trying to pick up this cylinder, move it around then drop it back down:
I have a trigger collider between the two graspers and a collider on each grasper. I have kinematic rigidbodies on the graspers and a default rigidbody on the cylinder.
How I am currently trying to grab the cylinder:
If: cylinder is inside trigger (OnTriggerStay) AND cylinder is touching left (OnCollisionEnter) AND cylinder is touching right (OnCollisionEnter), then:
make the cylinder the child of the arm, and turn off its gravity
If: cylinder is not touching left OR not touching right, detach cylinder from parent and turn gravity back on (drop).
My problem is that when I grab the cylinder, it vibrates around and eventually jumps out of the grasp. I suspect this is because the graspers "go through" the cylinders - because I am moving the graspers by changing transform.localEulerAngles. The user moves the graspers by changing the grasper angle, which is why I opted to use transform.localEulerAngles instead of applying a torque or something else. In fact, the entire position of the robot is also moved kinematically (without using forces).
I have tried to open/close the graspers by attaching a hingejoint to each one, and applying a torque, however, when I move the robot arm into position, the graspers swing about, and when I apply a torque, the graspers also bounce on each other... which I do not want to happen.
I want to be able to do it kinematically, with no forces applied because my entire robot is moved kinematically. Any ideas on how I can properly grab this object? Thanks!
Have you tried setting the cylinder as kinematic while parenting to the arm? On the other hand, you can try to add fixed joint while collision is detected
Like in the other comment, you can do this via inverse kinematics. You can read more about this here. It is the exact scenario you are having.