The InterfaceRealization dependency from ProximitySensor to ISensor is shown using ball (lollipop) notation 从 ProximitySensor 到 ISensor 的接口实现依赖性使用球(棒棒糖)表示法显示(请参阅图 10.8)。
1 2 proximitySensor = sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY); 在继续之前,始终确保Sensor对象不是null 1 2 3 4 if (proximitySensor == null) { Toast.makeText(this, "接近传感器不可用", Toast.LENGTH_LONG).show(); finish onSensorChanged(SensorEvent sensorEvent) { // More code goes here if(sensorEvent.values[0] < proximitySensor.getMaximumRange interval in 注册,指定轮询间隔 // microseconds 微秒 sensorManager.registerListener(proximitySensorListener, proximitySensor onSensorChanged()在上一步中创建的方法中添加以下代码: 1 2 3 4 五 6 7 // More code goes here if(sensorEvent.values[0] < proximitySensor.getMaximumRange
基对象应该始终是机器人或模型名,其他对象应该始终包含基对象名,如:robot (base)、robot_link1、robot_proximitySensor等。
SensorBase.cpp \ LightSensor.cpp \ ProximitySensor.cpp
1300,20000,0,0,6,BMP285pressure,1,Bosch,1100,100000,0,0,65536,BMP285temperature,1,Bosch,85,40000,0,0,8,TMD4903ProximitySensor