@@ -229,7 +229,7 @@ class Neosoco(Robot):
229
229
'0' : 0
230
230
}
231
231
232
- _SERVO_MOTOR_PERCENT_CVT = {
232
+ _SERVO_PERCENT_CVT = {
233
233
'100' : 100 ,
234
234
'90' : 90 ,
235
235
'80' : 80 ,
@@ -243,7 +243,7 @@ class Neosoco(Robot):
243
243
'0' : 0
244
244
}
245
245
246
- _SERVO_MOTOR_DEGREE_CVT = {
246
+ _SERVO_DEGREE_CVT = {
247
247
'180' : 180 ,
248
248
'175' : 175 ,
249
249
'170' : 170 ,
@@ -288,18 +288,18 @@ class Neosoco(Robot):
288
288
'backward' : 32
289
289
}
290
290
291
- _SERVO_MOTOR_DIR = {
291
+ _SERVO_DIR = {
292
292
'forward' : 192 ,
293
293
'backward' : 208
294
294
}
295
295
296
- _SERVO_MOTOR_DIR_FOR_DEG = {
296
+ _SERVO_DIR_FOR_DEG = {
297
297
'forward' : 188 ,
298
298
'backward' : 189
299
299
}
300
300
301
- _SERVO_MOTOR_STOP = 254
302
- _SERVO_MOTOR_RESET_DEG = 186
301
+ _SERVO_STOP = 254
302
+ _SERVO_RESET_DEG = 186
303
303
304
304
_robots = {}
305
305
@@ -584,49 +584,49 @@ def _write_to_output_port(self, port, out_val):
584
584
else :
585
585
raise ValueError ('Wrong value of out port' )
586
586
587
- def servo_motor_rotate (self , port = 'out1' , direction = 'forward' , speed = '100' ):
587
+ def servo_rotate (self , port = 'out1' , direction = 'forward' , speed = '100' ):
588
588
if isinstance (port , str ) and isinstance (direction , str ) and isinstance (speed , str ):
589
589
if speed == 'in1' or speed == 'in2' or speed == 'in3' :
590
590
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 ]
593
593
speed = self ._convert_sacle_within_100 (speed , 10 )
594
594
else :
595
595
raise ValueError ('Wrong value of speed' )
596
596
597
597
if direction .lower () == 'forward' :
598
- direction = self ._SERVO_MOTOR_DIR ['forward' ]
598
+ direction = self ._SERVO_DIR ['forward' ]
599
599
elif direction .lower () == 'backward' :
600
- direction = self ._SERVO_MOTOR_DIR ['backward' ]
600
+ direction = self ._SERVO_DIR ['backward' ]
601
601
else :
602
602
raise ValueError ('Wrong value of direction' )
603
603
604
604
out_val = direction + speed
605
605
if out_val == direction : # Speed is 0
606
- out_val = self ._SERVO_MOTOR_STOP
606
+ out_val = self ._SERVO_STOP
607
607
else :
608
608
out_val = out_val - 1
609
609
610
610
self ._write_to_output_port (port , out_val )
611
611
else :
612
612
raise TypeError
613
613
614
- def servo_motor_reset_degree (self , port = 'out1' ):
614
+ def servo_reset_degree (self , port = 'out1' ):
615
615
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 )
617
617
Runner .wait (100 )
618
618
self ._write_to_output_port (port , 1 ) # Set where the motor is to 1 degree
619
619
Runner .wait (100 )
620
620
else :
621
621
raise TypeError
622
622
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' ):
624
624
if isinstance (port , str ) and isinstance (direction , str ) and \
625
625
isinstance (speed , str ) and isinstance (degree , str ):
626
626
if direction .lower () == 'forward' :
627
- direction = self ._SERVO_MOTOR_DIR_FOR_DEG ['forward' ]
627
+ direction = self ._SERVO_DIR_FOR_DEG ['forward' ]
628
628
elif direction .lower () == 'backward' :
629
- direction = self ._SERVO_MOTOR_DIR_FOR_DEG ['backward' ]
629
+ direction = self ._SERVO_DIR_FOR_DEG ['backward' ]
630
630
else :
631
631
raise ValueError ('Wrong value of direction' )
632
632
@@ -636,8 +636,8 @@ def servo_motor_rotate_by_degree(self, port='out1', direction='forward', speed='
636
636
speed = self .read (Neosoco .INPUT_2 )
637
637
elif port .lower () == 'in3' :
638
638
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 ]
641
641
else :
642
642
raise ValueError ('Wrong value of speed' )
643
643
speed = max (speed , 0 )
@@ -650,8 +650,8 @@ def servo_motor_rotate_by_degree(self, port='out1', direction='forward', speed='
650
650
degree = self .read (Neosoco .INPUT_2 )
651
651
elif port .lower () == 'in3' :
652
652
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 ]
655
655
else :
656
656
raise ValueError ('Wrong value of degree' )
657
657
degree = max (degree , 0 )
0 commit comments