## Problems with force sensor

Typically: "How do I... ", "How can I... " questions
jovan_s
Posts: 14
Joined: 01 Dec 2020, 10:19

### Problems with force sensor

Hello Coppelia,

I see that there were some recent posts dealing with tool force control, force sensors, etc. I also have a problem with the results from the force sensor. The results that I get from it are very different depending on the dynamics module that I use. I expected them to differ a bit, but not this much. Also, the results change quite a lot depending on the simulation step time. Can you give me an idea as to why this happens? I also wanted to ask if there are maybe some examples on tool force control, as that is what I'm trying to use the info from the sensors for. I know you can use existing functions for joint force control but I'm very interested in tool force control.

Cheers

coppelia
Posts: 8531
Joined: 14 Dec 2012, 00:25

### Re: Problems with force sensor

Hello,

each engine will do computations in a different way, and results may differ. Not sure how much they differ, when you say they differ a lot?

Additionally, force sensor data is averaged over the number of dynamics sub-steps (i.e. 10 sub-steps by default). If you want to read raw values, use the sim.handleflag_rawvalue flag when calling sim.readForceSensor. Also make sure to read values from a dynamics callback function.

Cheers

jovan_s
Posts: 14
Joined: 01 Dec 2020, 10:19

### Re: Problems with force sensor

Hi,

The difference is quite large. For instance, with one engine forces would be around 4-6N, and with another, it would be around 20-30N. The movement of my robot is in a threaded script, similar to how you did it in the scenes/ik_fk_simple_examples/10-applyingIkToDynamicallyEnabledModels.ttt with the targetMovements threaded script and a non-threaded child script for the robot. I read the Force sensor from that threaded script. Does that have something to do with the strange results?

Cheers

coppelia
Posts: 8531
Joined: 14 Dec 2012, 00:25

### Re: Problems with force sensor

Maybe you can post your scene so that we can have a look at it?
Make sure to make it to a minimal, self-contained scene.

Cheers

jovan_s
Posts: 14
Joined: 01 Dec 2020, 10:19

### Re: Problems with force sensor

Hi

https://www.dropbox.com/s/c0n8dsscm3t6x ... l.ttt?dl=0

I read the sensor in the targetMovements#0 script at line 231

Cheers

coppelia
Posts: 8531
Joined: 14 Dec 2012, 00:25

### Re: Problems with force sensor

Your simulation is quite complex, and you will never reach the exact same situation at the time you want to measure your force. For that reason you can't really compare those measurements across different engines.

e.g. in situation A, the two parts align with a tolerance of 1mm, and in situation B, they align with a tolerance of 3 mm. In case B, the robot arms would have to try harder before being able to insert the two parts into each other.

By the way, which 2 engines are you comparing? Also, with the ODE engine the robot arms go crazy, this points to collisions between individual links of the arms, or between the arms and the upper part of the robot body. Try setting the upper part of the body to non-respondable, or adjust the respondable masks.

Cheers

jovan_s
Posts: 14
Joined: 01 Dec 2020, 10:19

### Re: Problems with force sensor

Hi

Thanks for the advice. When I make the upper part of the body non-respondable, I get a bit better results. I'm very interested to know what method the dynamic engines use to calculate/estimate contact forces? Is that something you could share?

Cheers

coppelia
Posts: 8531
Joined: 14 Dec 2012, 00:25

### Re: Problems with force sensor

Physics engine usually use the penetration depth between colliding bodies to compute reaction forces. Penetration depth calculation is relatively trivial for primitive shapes and convex shapes, but very difficult to compute with non-convex or random meshes.