Contact Force is ZERO

Typically: "How do I... ", "How can I... " questions
Post Reply
nadeenelhadad
Posts: 13
Joined: 28 Feb 2025, 06:37

Contact Force is ZERO

Post by nadeenelhadad »

Hello!

I set up this catalyst-rl tutorial that uses CoppeliaSim4.1 to perform reinforcement learning on a simple peg-in-hole task. https://github.com/arrival-ltd/catalyst-rl-tutorial
I'm reversing the work of this tutorial to simulate disassembly instead and I'm facing a problem. I understand that the implemented CoppeliaSim environment they used can detect collision correctly. But for some reason, the contact forces are always 0 when I try to print them. I tried using getContactInfo and I tried using a contact force inside the hole to detect the magnitude of collision force but it does not happen (prints 0).
I also tried printing the force/torque at the joints of the robot arm but this did not work as well (printing blank, not 0).
Furthermore, their initial code would terminate episode when a collision (detected correctly) between the peg and the hole take place. But I don't want to use the collision force instead. So, now that the episode is not terminating, there's penetration between the peg and the hole which is also something I do not want.
I'm using the Newton physics engine for this.
Unfortunately, I can't update to a newer CopSim version without facing a lot of discrepancies with the inner imported libraries.
Is 4.1 incapable of performing/understanding the physics interactions between parts? Can the force be too much of an "impulse" that this is the reason it's not calculating it well?
What can be the reason for these issues and is there hope to perform this on 4.1 or do I have to update? If updating to a higher CopSim version is the solution, how can I do this with minimal compatibility/discrepancy issues? Because it seems that even the most fundamental libraries have changed (e.g. libcoppeliaSim.so.1 --> libcoppeliaSim.so).

I'm new to CoppeliaSim so this might be a very basic problem, sorry.
coppelia
Site Admin
Posts: 10747
Joined: 14 Dec 2012, 00:25

Re: Contact Force is ZERO

Post by coppelia »

Hello,

CoppeliaSim V4.1 is indeed old. But you should first make sure that your peg and hole are able to generate collision responses (which is different from collision detection).

Try visualizing all contact forces via the contact display add-on (that add-on also uses sim.getContactInfo). Also, during simulation, click the Visualize and verify dynamic content toolbar button to make sure that both, the peg and the hole are dynamically simulated (and that at least one of them is not static).

Also if possible, post the scene file that is problematic.

Cheers
coppelia
Site Admin
Posts: 10747
Joined: 14 Dec 2012, 00:25

Re: Contact Force is ZERO

Post by coppelia »

I had a look at the simulation scene (in the link you provided): the scene apparently uses a static version of the robot (with a static peg). The hole is non-static.

Using CoppeliaSim V4.9, I can manually move the peg into the whole and the hole will move (and generate contct force).

Cheers
nadeenelhadad
Posts: 13
Joined: 28 Feb 2025, 06:37

Re: Contact Force is ZERO

Post by nadeenelhadad »

Hello! Thank you for getting back to me. I've made some changes. Now the robot arm is dynamic and so is the peg. I made the target static because that fits my application more. All three elements should be respondable since I checked that box.
For the contact display, the add-on is not in my drop-down menu, so I modified the script to use sim.addDrawingObject, but I may have used it wrong because it did not work.

I've attached the scene file and a video of the operation of the file under the other (reinforcement learning disassembly) file.
https://drive.google.com/drive/folders/ ... sp=sharing

I really appreciate the help. Thanks!
nadeenelhadad
Posts: 13
Joined: 28 Feb 2025, 06:37

Re: Contact Force is ZERO

Post by nadeenelhadad »

Do one of the colliding parts have to be dynamic inside CoppeliaSim? For instance, I'm using the code itself to move the robot arm (and with it, the peg). Is it enough that both the peg and the hole are respondable without being dynamic (to avoid shape complexity) and still produce the contact forces?

Note: I use Inverse Kinematics here to change the initial pose of the robot arm and the peg to be inside the hole in the beginning of each episode. The idea is that, during a disassembly attempt, the peg will collide with the hole. This collision force is what I need to extract/print/use.
nadeenelhadad
Posts: 13
Joined: 28 Feb 2025, 06:37

Re: Contact Force is ZERO

Post by nadeenelhadad »

If the problem is in the static/dynamic definition and the connection of the peg to the robot arm makes me unable to define the peg as dynamic (which is, from my understanding, needed to define collision/contact force with a static hole part). I made some quick changes to separate the peg and include an RG2 gripper. The grasping is not there yet, but I've noticed that even with a dynamic peg that is being "pushed around", the contact forces are still 0 when there's a collision.
I've attached a video of this below:
https://drive.google.com/file/d/14hIHar ... sp=sharing

Sorry about the spam, I'm just trying to figure it out.

UPDATE: I figured the contact thing out. Thanks.
Post Reply