Page 1 of 1

get force/torque sensor values

Posted: 28 Jul 2019, 10:00
by jean taylor
Hi,
I want to display the f/torque sensor value in the status bar message.

Code: Select all

force={-1,-1,-1}
    torque={-1,-1,-1}
    HEX_Force_sensor = sim.getObjectHandle('HEX_Force_sensor')
    Cube = sim.getObjectHandle('Cube')
    --the cube must be non-static shape
    sim.setObjectInt32Parameter(Cube,3003,0)
  while true do
    res,force,torque=sim.readForceSensor(HEX_Force_sensor)
    sim.wait (1)
    sim.addStatusbarMessage(res)
      if res== -1 then
         sim.addStatusbarMessage('force/torque sensor error')
           elseif res == 1 then
             sim.addStatusbarMessage('force sensor is broken')
              else
                sim.addStatusbarMessage('Fx = '..force[1]..'  Fy = '..force[2].. '  Fz = '..force[3]..' Tx = '..torque[1]..' Ty = '..torque[2]..' Tz = '..torque[3]) 
                    end
   end
However, when I run the program, I always get the result value "res" = 1 which means that the sensor is broken ( the breaking settings is not selected)
I verified the conditions mentioned here http://www.coppeliarobotics.com/helpFil ... ations.htm , and I even tried the second solution ( Dummy-dummy link) but res still = 1
Any help would be appreciated.
project link : https://drive.google.com/file/d/175D8E8 ... sp=sharing

Re: get force/torque sensor values

Posted: 29 Jul 2019, 10:18
by coppelia
Hello,

you didn't correctly read the documentation. It sais:

bit 0 set (1): force and torque data is available, otherwise it is not (yet) available (e.g. when not enough values are present for the filter)

if Bit 0 is set, this is 1.

Cheers

Re: get force/torque sensor values

Posted: 29 Jul 2019, 19:47
by jean taylor
My mistake, you are right.
Thank you so much coppelia
Have a nice day :)