Regular API function

simReadDistance / sim.readDistance (remote API equivalent: simxReadDistance)

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
Same as C-function
Lua return values
result: 1 if distance was read, -1 in case of an error, 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

All regular API functions on one page