Overview | API
See also
ALsonar module retreives ultrasonic sensor value from ALMemory, process it and raises events according to the situation.
In order to save battety power, ultrasonic sensors are not activated by default.
There are 4 different ultrasonic events: SonarLeftDetected, SonarRightDetected, SonarLeftNothingDetected, SonarRightNothingDetected.
Case | Raised event | Description |
---|---|---|
SonarLeftDetected | There is someting in front of NAO (left side) at less than 0.5m. This means that NAO can’t go forward and has to stop and turn right to avoid the obstacle. | |
SonarRightDetected | There is someting in front of NAO (right side) at less than 0.5m. This means that NAO can’t go forward and has to stop and turn left to avoid the obstacle. | |
SonarLeftNothingDetected | There is nothing in front of NAO nor on his left side, this means NAO can go forward or turn left. An obstacle is present on the right side at less than 0.5m but it is not a problem if NAO goes forward. | |
SonarRightNothingDetected | There is nothing in front of NAO nor on his right side, this means NAO can go forward or turn left. An obstacle is present on the left side at less than 0.5m but it is not a problem if NAO goes forward. | |
SonarLeftNothingDetected and SonarRightNothingDetected | There is no obstacle, both SonarLeftNothingDetected and SonarRightNothingDetected are raised at the same time. |
Note
If you want to perform your own detection with sonars you can also retreive ultrasonic sensor values from ALMemory (find corresponding keys in Sonar ALMemory keys). If you are not familiar with this consult getData function of ALMemory API.
The obstacle detection threshold is 0.5m (it is a software threshold). Detected obstacles are seen only if the distance is less than this threshold.
Only one sonar event is raised at the same time. This is because at a given time we use both left and right ultrasonic sensor data, to determine in which situation we are so as to raise the corresponding event.
Starting ultrasonic hardware
Ultrasonic sensor hardware is not started by default. To start it, subscribe to ALSonar module (ALSonarProxy::subscribe). Doing so starts the ultrasonic sensor hardware automatically.
Checking the hardware
To check that your ultrasonic sensor works properly you can start Choregraphe and launch a Sonar box. First ensure that you are connected to your real NAO hardware. Then drag and drop a sonar box in your diagram and run the behavior.
Observing the signal
When a Sonar box is launched, you can watch the signal of the ultrasonic sensor with Monitor.
Stopping ultrasonic hardware
To stop it, unsubscribe from the ALSonar module (ALSonarProxy::unsubscribe). If there are multiple subscribers, the ultrasonic sensor hardware will remain active as long as remains at least one subscriber.
You can use ultrasonic sensor to perform obstacle detection.
How can I start and stop my ultrasonic senors
Please see Getting started section.
When connected to choregraphe, sonar box returns only left or noting
Check that you are connected to your real NAO and not to the local naoqi provided by choregraphe.