Browse Source

去掉调试iic代码是打印的encoder值

corvin 4 năm trước cách đây
mục cha
commit
4997c4535b

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

@@ -316,7 +316,7 @@ class Arduino:
             raise SerialException
             return None
         else:
-            print values
+            #print values
             return values
 
     def i2c_get_encoder_counts(self):
@@ -332,7 +332,7 @@ class Arduino:
 
             result_array = self.i2c_bus.read_i2c_block_data(self.i2c_slave_addr, 0x08)
             #There are result_flag valid bytes.
-            result_flag = result_array.index(120) 
+            result_flag = result_array.index(120)
             #rospy.loginfo("Valid bytes: "+str(result_flag))
             #extract result_flag bytes as strings
             result_string=''.join([chr(e) for e in self.i2c_bus.read_i2c_block_data(self.i2c_slave_addr, 0x08, result_flag)])
@@ -378,7 +378,7 @@ class Arduino:
                 self.i2c_bus.write_i2c_block_data(self.i2c_slave_addr, ord('z'), [ord(c) for c in cmd])
             except:
                 return None
-        
+
     def gripper_angle(self, angle):
         ''' control gripper angle
         '''
@@ -420,7 +420,7 @@ class Arduino:
         except:
             return None
 
-    def analog_read(self, pin):        
+    def analog_read(self, pin):
         if self.is_use_serial:
             return self.execute('a %d' %pin)
         else:
@@ -435,7 +435,7 @@ class Arduino:
             except:
                 return None
 
-    def analog_write(self, pin, value):      
+    def analog_write(self, pin, value):
         if self.is_use_serial:
             return self.execute_ack('x %d %d' %(pin, value))
         else:
@@ -445,7 +445,7 @@ class Arduino:
             except:
                 return None
 
-    def digital_read(self, pin):        
+    def digital_read(self, pin):
         if self.is_use_serial:
             return self.execute('d %d' %pin)
         else:
@@ -461,7 +461,7 @@ class Arduino:
             except:
                 return None
 
-    def digital_write(self, pin, value):      
+    def digital_write(self, pin, value):
         if self.is_use_serial:
             return self.execute_ack('w %d %d' %(pin, value))
         else:
@@ -471,7 +471,7 @@ class Arduino:
             except:
                 return None
 
-    def pin_mode(self, pin, mode):        
+    def pin_mode(self, pin, mode):
         if self.is_use_serial:
             return self.execute_ack('c %d %d' %(pin, mode))
         else:
@@ -481,7 +481,7 @@ class Arduino:
             except:
                 return None
 
-    def beep_ring(self, value):           
+    def beep_ring(self, value):
 #        if self.is_use_serial:
             return self.execute_ack('p %d' %value)
 #        else:
@@ -494,7 +494,7 @@ class Arduino:
     def detect_distance(self): #检测三个红外测距传感器的返回值,一共返回三个值,分别为前,左,右三个测距值
 #        if self.is_use_serial:
         return self.execute_array('h')
-#        else: 
+#        else:
 #            ch = ''
 #            values = ''
 #            cnt = 0
@@ -509,7 +509,7 @@ class Arduino:
 #                print 222222222
 #                print self.i2c_bus.read_i2c_block_data(self.i2c_slave_addr, 0x08)
 #                #There are result_flag valid bytes.
-#                result_flag = result_array.index(120) 
+#                result_flag = result_array.index(120)
 #                #rospy.loginfo("Valid bytes: "+str(result_flag))
 #                #extract result_flag bytes as strings
 #                result_string=''.join([chr(e) for e in self.i2c_bus.read_i2c_block_data(self.i2c_slave_addr, 0x08, result_flag)])
@@ -522,12 +522,12 @@ class Arduino:
 
 
     def getBatPercent(self): #获取电池的剩余电量百分比
-        
+
         if self.is_use_serial:
             percent = self.execute('g')
             #rospy.loginfo("bat percent:" + str(percent))
             return percent
-        else: 
+        else:
             try:
                 self.i2c_bus.write_byte(self.i2c_slave_addr, ord('g'))
                 self.i2c_bus.write_byte(self.i2c_slave_addr, ord('\r'))
@@ -544,7 +544,7 @@ class Arduino:
             currentvalue = self.execute('f')
             #rospy.loginfo("get current value:" + str(currentvalue))
             return currentvalue
-        else: 
+        else:
             try:
                 self.i2c_bus.write_byte(self.i2c_slave_addr, ord('f'))
                 self.i2c_bus.write_byte(self.i2c_slave_addr, ord('\r'))