Regular API function

simReadForceSensor / sim.readForceSensor

Description Reads the force and torque applied to a force sensor (filtered values are read), and its current state ('unbroken' or 'broken'). See also sim.breakForceSensor and sim.getJointForce.
C synopsis simInt simReadForceSensor(simInt objectHandle,simFloat* forceVector,simFloat* torqueVector)
C parameters
objectHandle: handle of the object (must be a force sensor). Can be combined with sim_handleflag_rawvalue (simply add sim_handleflag_rawvalue to objectHandle), if you wish to access the raw values generated by each individual dynamic simulation step (by default, there are 10 dynamic simulation steps for each simulation step). Raw values can only be accessed from inside a callback function triggered by the physics engine.
forceVector: pointer to 3 values (applied forces along the sensor's x, y and z-axes). Can be nullptr
torqueVector: pointer to 3 values (applied torques about the sensor's x, y and z-axes). Can be nullptr
C return value
-1 in case of an error, otherwise bit-coded:
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)
bit 1 set (2): force sensor is broken, otherwise it is still intact ('unbroken')
Lua synopsis int result, table[3] forceVector,table[3] torqueVector=sim.readForceSensor(int objectHandle)
Lua parameters
Similar to the C-function counterpart
Lua return values
result: bit-coded (same as for the C-function return value)
forceVector: table holding 3 values (applied forces along the sensor's x, y and z-axes)
torqueVector: table holding 3 values (applied torques about the sensor's x, y and z-axes)
Remote API equiv.
B0-based remote API: simxReadForceSensor
Legacy remote API: simxReadForceSensor