Regular API function

simReadDistance / sim.readDistance

Description Reads the distance of a registered distance object. This function doesn't perform distance measurement, it merely reads the result from a previous call to sim.handleDistance (sim.handleDistance is called in the default main script). See also sim.resetDistance and sim.checkDistance.
C synopsis simInt simReadDistance(simInt distanceObjectHandle,simFloat* smallestDistance)
C parameters
distanceObjectHandle: handle of the distance object
smallestDistance: smallest distance (valid only if return value is different from -1)
C return value
different from -1 if distance was read, -1 in case of an error.
Lua synopsis number result,number smallestDistance=sim.readDistance(number distanceObjectHandle)
Lua parameters
Similar to the C-function counterpart
Lua return values
result: 1 if distance was read, and 0 if sim.handleDistance was never called, or if sim.resetDistance was previously called.
smallestDistance: the smallest distance. Is nil if result is not 1
Remote API equiv.
B0-based remote API: simxReadDistance
Legacy remote API: simxReadDistance

All regular API functions on one page