فهرست منبع

修改电压电流检测函数

corvin 5 سال پیش
والد
کامیت
96de6cd442

+ 6 - 6
src/ros_arduino_bridge/ros_arduino_python/src/ros_arduino_python/arduino_driver.py

@@ -175,7 +175,7 @@ class Arduino:
             value = None
 
         self.mutex.release()
-        return int(value)
+        return value
 
     def execute_array(self, cmd):
         ''' Thread safe execution of "cmd" on the Arduino returning an array.
@@ -322,11 +322,11 @@ class Arduino:
     def beep_ring(self, value):
         return self.execute_ack('p %d' %value)
 
-    def detect_voltage(self, value):
-        return self.execute_ack('g %d' %value)        
-    
-    def detect_current(self, value):
-        return self.execute_ack('f %d' %value)
+    def detect_voltage(self):
+        return self.execute('g')
+
+    def detect_current(self):
+        return self.execute('f')
 
     def light_show(self, value):
         return self.execute_ack('l %d' %value)

+ 1 - 0
src/ros_arduino_bridge/ros_arduino_python/src/ros_arduino_python/base_controller.py

@@ -173,6 +173,7 @@ class BaseController:
 
         time_now = rospy.Time.now()
         if time_now > self.t_next:
+            #rospy.logwarn("Voltage: %f, Current: %f", float(vol), float(current))
             vol = self.arduino.detect_voltage()
             current = self.arduino.detect_current()
             rospy.logwarn("Voltage: %f, Current: %f", vol, current)