brian.sensors.NXT.UltrasonicSensorNXT
UltrasonicSensorNXT class objects
class UltrasonicSensorNXT(Sensor)
Class for interacting with NXT ultrasonic sensor.
Sensor is automatically registered in the constructor of the base class and un-registered in its destructor. It can also be unregistered with the UltrasonicSensorNXT.close_sensor() function.
There can be at most one instance at any given time, of any sensor class per port in the entire program.
__init__
def __init__(port: SensorPort)
Initialize an NXT ultrasonic sensor at the given port.
Arguments:
port
: Sensor port to which the sensor is attached.
distance_cm
def distance_cm() -> int
Continuously measures the distance and returns the value in cm.
Raises:
brian.sensors.SensorIsNotReadyError
: If the sensor is not ready.
Returns:
distance in cm (0-255).