## Problem with force sensors on mico hand

Typically: "How do I... ", "How can I... " questions
ljklonepiece
Posts: 105
Joined: 10 Oct 2013, 14:51

### Problem with force sensors on mico hand

Hi Developers,

I want to create a flying hand with touch sensor enabled.
However, I encountered some problem to make the touch sensor work.
Specifically, I am trying to obtain the readings from force sensor on the finger of mico arm when it touches something.
i use

Code: Select all

r,force,torque=simReadForceSensor(force_sen_tip_right)

However the 'r' value is always 1 which means the sensor is broken according to the documentation.
but when i am trying to access the value in force vector, say print(force[1]), it reports errors as:

Code: Select all

Lua runtime error: [string "SCRIPT Control_hand"]:39: attempt to index global 'force' (a nil value)
and now 'r' has the value 0

I have attached scene file for reference, I want to hand to stop when it touches the table.

Any help and suggestions are much appreciated!

Yours sincerely,
Juekun

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

### Re: Problem with force sensors on mico hand

Hello Juekun,

you are mixing up bit 0 and bit 1 (I agree this can be a little bit confusing):
• bit0 --> 1
• bit1 --> 2
• bit2 --> 4
• bit3 --> 8
• etc.
so you could have your code like that:

Code: Select all

r,force,torque=simReadForceSensor(forceSensorHandle)
if (simBoolAnd16(r,1)~=0) then
-- ok, the force/torque data is available
print('Force: '..force[1],force[2],force[3])
print('Torque: '..torque[1],torque[2],torque[3])
if (simBoolAnd16(r,2)~=0) then
-- The force sensor is broken
print('Force/torque sensor is broken')
end
end
Cheers

ljklonepiece
Posts: 105
Joined: 10 Oct 2013, 14:51

### Re: Problem with force sensors on mico hand

Hi Marc,

Thanks a lot for your detailed explanations! It works!

Another question regarding the tactile sensor are :
1. what is the effective sensing volume of the each force sensor? is it the white bounding box shown when such sensor is selected?

2. I notice that even there is no contact with the force sensor, the force sensor still reports some small value which i suppose it should be 0 in case of no contact:
eg.

Code: Select all

right_tip: -0.0041960747912526, -0.28841668367386, -0.36253958940506
left_tip: 0.0028423713520169, -0.27158948779106, -0.41862398386002
right_mid: -0.0028867477085441, -0.41841167211533, -0.2413445264101
left_mid: 0.0042679626494646, -0.41926923394203, -0.2585569024086
these are the four sensor readings i got from mico hand when no contact with object is observed.
when contact is observed, some value becomes larger than 1, thus, can i say that the value 1 is the threshold separating no contact and contact state?

Yours sincerely,
Juekun

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

### Re: Problem with force sensors on mico hand

there is no sensing volume for a force/torque sensor. A force/torque sensor will simply register the forces/torques applied to it via attached bodies. In your case:

finger segment --> force sensor --> finger pad

the object finger pad has a mass, and acts on the force sensor also when the pad is not touching anything (that's why you have non-zero forces/masses when the finger is idle, because gravity is pulling the pad down). When the pad collides with an object (e.g. an object to grasp), then the pad will push (or transmitt the force to) the force sensor.

Cheers

ljklonepiece
Posts: 105
Joined: 10 Oct 2013, 14:51

### Re: Problem with force sensors on mico hand

Dear Marc,

I see~~Thanks a lot for your help!!!

Yours sincerely,
Juekun