get force/torque sensor values

Typically: "How do I... ", "How can I... " questions
Post Reply
jean taylor
Posts: 6
Joined: 16 Dec 2018, 00:24

get force/torque sensor values

Post 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

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

Re: get force/torque sensor values

Post 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

jean taylor
Posts: 6
Joined: 16 Dec 2018, 00:24

Re: get force/torque sensor values

Post by jean taylor »

My mistake, you are right.
Thank you so much coppelia
Have a nice day :)

Post Reply