|
@@ -4,10 +4,11 @@
|
|
|
"""
|
|
|
Copyright: 2016-2020 ROS小课堂 www.corvin.cn
|
|
|
Description: A Python driver for the Arduino microcontroller.
|
|
|
- Author: corvin
|
|
|
+ Author: corvin, jally
|
|
|
History:
|
|
|
20200329:增加获取电池剩余电量百分比函数.
|
|
|
20200412:增加发布红外测距信息的服务.
|
|
|
+ 20200423:增加获取电流传感器信息
|
|
|
"""
|
|
|
from serial.serialutil import SerialException
|
|
|
import thread, smbus, rospy, time, os
|
|
@@ -404,9 +405,6 @@ class Arduino:
|
|
|
def beep_ring(self, value):
|
|
|
return self.execute_ack('p %d' %value)
|
|
|
|
|
|
- def detect_current(self):
|
|
|
- return self.execute('f')
|
|
|
-
|
|
|
def detect_distance(self): #检测三个红外测距传感器的返回值,一共返回三个值,分别为前,左,右三个测距值
|
|
|
return self.execute_array('h')
|
|
|
|
|
@@ -415,6 +413,11 @@ class Arduino:
|
|
|
#rospy.loginfo("bat percent:" + str(percent))
|
|
|
return percent
|
|
|
|
|
|
+ def getCurrentValue(self): #获取电流值
|
|
|
+ currentvalue = self.execute('f')
|
|
|
+ #rospy.loginfo("get current value:" + str(currentvalue))
|
|
|
+ return currentvalue
|
|
|
+
|
|
|
def light_show(self, value):
|
|
|
return self.execute_ack('l %d' %value)
|
|
|
|