@@ -229,7 +229,7 @@ class Neosoco(Robot):
229229 '0' : 0
230230 }
231231
232- _SERVO_MOTOR_PERCENT_CVT = {
232+ _SERVO_PERCENT_CVT = {
233233 '100' : 100 ,
234234 '90' : 90 ,
235235 '80' : 80 ,
@@ -243,7 +243,7 @@ class Neosoco(Robot):
243243 '0' : 0
244244 }
245245
246- _SERVO_MOTOR_DEGREE_CVT = {
246+ _SERVO_DEGREE_CVT = {
247247 '180' : 180 ,
248248 '175' : 175 ,
249249 '170' : 170 ,
@@ -288,18 +288,18 @@ class Neosoco(Robot):
288288 'backward' : 32
289289 }
290290
291- _SERVO_MOTOR_DIR = {
291+ _SERVO_DIR = {
292292 'forward' : 192 ,
293293 'backward' : 208
294294 }
295295
296- _SERVO_MOTOR_DIR_FOR_DEG = {
296+ _SERVO_DIR_FOR_DEG = {
297297 'forward' : 188 ,
298298 'backward' : 189
299299 }
300300
301- _SERVO_MOTOR_STOP = 254
302- _SERVO_MOTOR_RESET_DEG = 186
301+ _SERVO_STOP = 254
302+ _SERVO_RESET_DEG = 186
303303
304304 _robots = {}
305305
@@ -584,49 +584,49 @@ def _write_to_output_port(self, port, out_val):
584584 else :
585585 raise ValueError ('Wrong value of out port' )
586586
587- def servo_motor_rotate (self , port = 'out1' , direction = 'forward' , speed = '100' ):
587+ def servo_rotate (self , port = 'out1' , direction = 'forward' , speed = '100' ):
588588 if isinstance (port , str ) and isinstance (direction , str ) and isinstance (speed , str ):
589589 if speed == 'in1' or speed == 'in2' or speed == 'in3' :
590590 speed = self ._convert_scale_from_input_port (speed , 10 )
591- elif speed in self ._SERVO_MOTOR_PERCENT_CVT .keys ():
592- speed = self ._SERVO_MOTOR_PERCENT_CVT [speed ]
591+ elif speed in self ._SERVO_PERCENT_CVT .keys ():
592+ speed = self ._SERVO_PERCENT_CVT [speed ]
593593 speed = self ._convert_sacle_within_100 (speed , 10 )
594594 else :
595595 raise ValueError ('Wrong value of speed' )
596596
597597 if direction .lower () == 'forward' :
598- direction = self ._SERVO_MOTOR_DIR ['forward' ]
598+ direction = self ._SERVO_DIR ['forward' ]
599599 elif direction .lower () == 'backward' :
600- direction = self ._SERVO_MOTOR_DIR ['backward' ]
600+ direction = self ._SERVO_DIR ['backward' ]
601601 else :
602602 raise ValueError ('Wrong value of direction' )
603603
604604 out_val = direction + speed
605605 if out_val == direction : # Speed is 0
606- out_val = self ._SERVO_MOTOR_STOP
606+ out_val = self ._SERVO_STOP
607607 else :
608608 out_val = out_val - 1
609609
610610 self ._write_to_output_port (port , out_val )
611611 else :
612612 raise TypeError
613613
614- def servo_motor_reset_degree (self , port = 'out1' ):
614+ def servo_reset_degree (self , port = 'out1' ):
615615 if isinstance (port , str ):
616- self ._write_to_output_port (port , self ._SERVO_MOTOR_RESET_DEG )
616+ self ._write_to_output_port (port , self ._SERVO_RESET_DEG )
617617 Runner .wait (100 )
618618 self ._write_to_output_port (port , 1 ) # Set where the motor is to 1 degree
619619 Runner .wait (100 )
620620 else :
621621 raise TypeError
622622
623- def servo_motor_rotate_by_degree (self , port = 'out1' , direction = 'forward' , speed = '100' , degree = '90' ):
623+ def servo_rotate_by_degree (self , port = 'out1' , direction = 'forward' , speed = '100' , degree = '90' ):
624624 if isinstance (port , str ) and isinstance (direction , str ) and \
625625 isinstance (speed , str ) and isinstance (degree , str ):
626626 if direction .lower () == 'forward' :
627- direction = self ._SERVO_MOTOR_DIR_FOR_DEG ['forward' ]
627+ direction = self ._SERVO_DIR_FOR_DEG ['forward' ]
628628 elif direction .lower () == 'backward' :
629- direction = self ._SERVO_MOTOR_DIR_FOR_DEG ['backward' ]
629+ direction = self ._SERVO_DIR_FOR_DEG ['backward' ]
630630 else :
631631 raise ValueError ('Wrong value of direction' )
632632
@@ -636,8 +636,8 @@ def servo_motor_rotate_by_degree(self, port='out1', direction='forward', speed='
636636 speed = self .read (Neosoco .INPUT_2 )
637637 elif port .lower () == 'in3' :
638638 speed = self .read (Neosoco .INPUT_3 )
639- elif speed in self ._SERVO_MOTOR_PERCENT_CVT .keys ():
640- speed = self ._SERVO_MOTOR_PERCENT_CVT [speed ]
639+ elif speed in self ._SERVO_PERCENT_CVT .keys ():
640+ speed = self ._SERVO_PERCENT_CVT [speed ]
641641 else :
642642 raise ValueError ('Wrong value of speed' )
643643 speed = max (speed , 0 )
@@ -650,8 +650,8 @@ def servo_motor_rotate_by_degree(self, port='out1', direction='forward', speed='
650650 degree = self .read (Neosoco .INPUT_2 )
651651 elif port .lower () == 'in3' :
652652 degree = self .read (Neosoco .INPUT_3 )
653- elif degree in self ._SERVO_MOTOR_DEGREE_CVT .keys ():
654- degree = self ._SERVO_MOTOR_DEGREE_CVT [degree ]
653+ elif degree in self ._SERVO_DEGREE_CVT .keys ():
654+ degree = self ._SERVO_DEGREE_CVT [degree ]
655655 else :
656656 raise ValueError ('Wrong value of degree' )
657657 degree = max (degree , 0 )
0 commit comments