一、sonars硬件资料:
http://doc.aldebaran.com/2-8/family/nao_technical/sonar_naov6.html#naov6-sonar
二、sonar的内存键值及相关使用解释:
http://doc.aldebaran.com/2-8/family/nao_technical/lola/actuator_sensor_names.html#sonars
1.可以通过向US/Actuator/Value写入相应的数值来设置传感器发射和接受的方式,每一位表示不同的功能。通过这种方式可以自己定义超声传感器的使用方式,区别与官方提供的ALSonar API方法。
2.当同时使用左右两个接收器时:
每组超声传感器一次可以存储十个传感数据,可以通过内存键值Device/SubDeviceList/US/Right/Sensor/Value-Device/SubDeviceList/US/Right/Sensor/Value9来读取
3.当只使用单个接收器时:
读取Device/SubDeviceList/US/Sensor/Value的值,表示的是单侧的传感器的数值,大致在设置完10ms后即有接受值被写入。
4.读取的过程如果dis<0 or dis>5,则表示读取出错或没有接受到回波
5.注意可能检测到身体的某些部位以及地面等
6.内存中的超声传感器的值每100ms会被更新一次,所以读取的周期应长于100ms
三、ALSonar API使用方法:
http://doc.aldebaran.com/2-8/naoqi/sensors/alsonar.html
默认使用两侧传感器进行工作
使用示例:
# example for sonar
memory_service = session.service("ALMemory")
sonar_service = session.service("ALSonar")
# Subscribe to sonars, this will launch sonars (at hardware level)
# and start data acquisition.
sonar_service.subscribe("myApplication")
# Now you can retrieve sonar data from ALMemory.
# Get sonar left first echo (distance in meters to the first obstacle).
memory_service.getData("Device/SubDeviceList/US/Left/Sensor/Value")
# Same thing for right.
memory_service.getData("Device/SubDeviceList/US/Right/Sensor/Value")
# Unsubscribe from sonars, this will stop sonars (at hardware level)
sonar_service.unsubscribe("myApplication")
提供有四个响应事件:SonarLeftDetected
, SonarRightDetected
, SonarLeftNothingDetected
, SonarRightNothingDetected
当满足相应条件时,就会触发相应事件。