DistanceSensor

An electronic device that measures the distance between itself and an object.

getDistance

Provides the distance measured by a distance sensor.

Key points:

  • DistanceUnit: You can specify the desired unit for the distance measurement (CM, INCH, METER, MM).

  • Return Value: The getDistance method returns a double value representing the measured distance.

  • Sensor Type: The specific distance sensor used will influence the measurement range and accuracy. The simulation has consistent distance sensors.