@@ -131,8 +131,10 @@ def _mesg(self, genre, *args, **kwargs):
131131 elif genre == ProtocolCode .GET_MOTORS_CURRENT .value :
132132 return self ._decode_int16 (data [4 :6 ])
133133 elif ProtocolCode .GET_BATTERY_INFO .value :
134- byte_1 = bin (data [4 ])
135- return [byte_1 [2 :], self ._int2coord (data [5 ]), self ._int2coord (data [6 ])]
134+ byte_1 = bin (data [4 ])[2 :]
135+ while len (byte_1 ) != 6 :
136+ byte_1 = "0" + byte_1
137+ return [byte_1 , self ._int2coord (data [5 ]), self ._int2coord (data [6 ])]
136138 # print(res)
137139 return None
138140
@@ -193,55 +195,57 @@ def go_ahead(self, go_speed):
193195 """Control the car to move forward
194196
195197 Args:
196- go_speed (int): 129 ~ 255 is forward
198+ go_speed (int): 1 ~ 127 is forward
197199 """
198- calibration_parameters (class_name = self .__class__ .__name__ , go_speed = go_speed )
199- self ._mesg (go_speed , 128 , 128 )
200+ # go_speed (int): 129 ~ 255 is forward
201+ calibration_parameters (class_name = self .__class__ .__name__ , data = go_speed )
202+ self ._mesg (128 + go_speed , 128 , 128 )
200203
201204 def retreat (self , back_speed ):
202205 """Control the car back
203206
204207 Args:
205- back_speed (int): 0 ~ 127 is backward
208+ back_speed (int): 1 ~ 127 is backward
206209 """
207- calibration_parameters (class_name = self .__class__ .__name__ , back_speed = back_speed )
208- self ._mesg (back_speed , 128 , 128 )
210+ calibration_parameters (class_name = self .__class__ .__name__ , data = back_speed )
211+ self ._mesg (128 - back_speed , 128 , 128 )
209212
210213 def pan_left (self , pan_left_speed ):
211214 """Control the car to pan to the left
212215
213216 Args:
214- pan_left_speed (int): 129 ~ 255
217+ pan_left_speed (int): 1 ~ 127
215218 """
216- calibration_parameters (class_name = self .__class__ .__name__ , pan_left_speed = pan_left_speed )
217- self ._mesg (128 , pan_left_speed , 128 )
219+ # pan_left_speed (int): 129 ~ 255
220+ calibration_parameters (class_name = self .__class__ .__name__ , data = pan_left_speed )
221+ self ._mesg (128 , 128 + pan_left_speed , 128 )
218222
219223 def pan_right (self , pan_right_speed ):
220224 """Control the car to pan to the right
221225
222226 Args:
223- pan_right_speed (int): 0 ~ 127
227+ pan_right_speed (int): 1 ~ 127
224228 """
225229 calibration_parameters (class_name = self .__class__ .__name__ , pan_right_speed = pan_right_speed )
226- self ._mesg (128 , pan_right_speed , 128 )
230+ self ._mesg (128 , 128 - pan_right_speed , 128 )
227231
228232 def clockwise_rotation (self , rotate_right_speed ):
229233 """Control the car to rotate clockwise
230234
231235 Args:
232- clockwise_rotation_speed (int): 0 ~ 127
236+ clockwise_rotation_speed (int): 1 ~ 127
233237 """
234238 calibration_parameters (class_name = self .__class__ .__name__ , rotate_right_speed = rotate_right_speed )
235- self ._mesg (128 , 128 , rotate_right_speed )
239+ self ._mesg (128 , 128 , 128 - rotate_right_speed )
236240
237241 def counterclockwise_rotation (self , rotate_left_speed ):
238242 """Control the car to rotate counterclockwise
239243
240244 Args:
241- clockwise_rotation_speed (int): 129 ~ 255
245+ clockwise_rotation_speed (int): 1 ~ 127
242246 """
243247 calibration_parameters (class_name = self .__class__ .__name__ , rotate_left_speed = rotate_left_speed )
244- self ._mesg (128 , 128 , rotate_left_speed )
248+ self ._mesg (128 , 128 , 128 + rotate_left_speed )
245249
246250 def stop (self ):
247251 """stop motion
0 commit comments