本文整理匯總了Python中motor.Motor.move方法的典型用法代碼示例。如果您正苦於以下問題:Python Motor.move方法的具體用法?Python Motor.move怎麽用?Python Motor.move使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類motor.Motor
的用法示例。
在下文中一共展示了Motor.move方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: from motor import Motor [as 別名]
# 或者: from motor.Motor import move [as 別名]
def main():
log_file = "main_log.log"
create_timed_rotating_log("log/" + log_file)
logger = logging.getLogger("BasicLogger")
logger.info("----- Starting Logging Session -----")
config = configparser.ConfigParser()
config.read('config.ini')
# How to use the config values. REMOVE when done with setup of this!
print(config.sections())
print('scale of this whole thing from config file is: ' + config['grid']['scale'])
# To get the values as integers:
i = int(config['grid']['max_position_z'])
print(i+2)
# subprocess.call("../gcodepull.sh", shell=True)
#opens the file named in the varibles file
length = range(FileOperator.OpenFile()- 3)
Motor.setup()
start = 2
for row in length:
# for the appropiated length each row is worked through
# and the needet steps are sent to the stepper motors
next_row = row + start
delta_step = FileOperator.NextMove(next_row)
corrected_coords = FileOperator.MoveCorrect(delta_step)
Motor.move(corrected_coords)
print('finished')
GPIO.cleanup()
示例2: __init__
# 需要導入模塊: from motor import Motor [as 別名]
# 或者: from motor.Motor import move [as 別名]
class Depowdering:
def __init__(self, verbose=False):
self.verbose = verbose
capture = cv2.VideoCapture(0)
capture.set(cv2.CAP_PROP_FRAME_WIDTH, 960)
capture.set(cv2.CAP_PROP_FRAME_HEIGHT, 500)
capture.set(cv2.CAP_PROP_BUFFERSIZE, 3)
capture.set(cv2.CAP_PROP_FPS, 60)
self.__capture_manager = CaptureManager(capture, 10)
self.__io_manager = IOManager(IO_PINS, verbose)
self.__image_analyzer = ImageAnalyzer(self.__capture_manager.current_frame_color, verbose)
self.__coordinates_translator = CoordinatesTranslator(self.__image_analyzer, CONVEYOR_WIDTH)
self.__packager = Packager(TRAY_SIZE, PADDING, verbose)
self.__item_movement_motor = Motor(MOTOR_PINS['item_movement_control'],
MOTOR_PINS['item_movement_direction'],
ITEM_MOVEMENT_CONVEYOR_STEP_INTERVAL,
ITEM_MOVEMENT_CONVEYOR_STEP_LIMIT,
MOTOR_PINS['item_movement_limit_switch'],
0.15,
10,
0.15,
10,
self.__io_manager,
verbose)
self.__io_manager.protect_pin(MOTOR_PINS['item_movement_control'])
self.__io_manager.protect_pin(MOTOR_PINS['item_movement_direction'])
self.__io_manager.protect_pin(MOTOR_PINS['item_movement_limit_switch'])
self.__tray_movement_motor = Motor(MOTOR_PINS['tray_movement_control'],
MOTOR_PINS['tray_movement_direction'],
TRAY_MOVEMENT_CONVEYOR_STEP_INTERVAL,
None,
MOTOR_PINS['tray_movement_limit_switch'],
0.15,
10,
0.15,
10,
self.__io_manager,
verbose)
self.__io_manager.protect_pin(MOTOR_PINS['tray_movement_control'])
self.__io_manager.protect_pin(MOTOR_PINS['tray_movement_direction'])
self.__io_manager.protect_pin(MOTOR_PINS['tray_movement_limit_switch'])
self.current_loop_done = 1
self.__calibrate_motors()
def main_cycle(self):
self.__wait_for_closed_door()
if not self.current_loop_done:
self.__io_manager.output('lock_door', IOManager.HIGH) # Lock door
item_list = self.__generate_item_list()
if not item_list:
self.__log('No item detected.')
return
translated_item_list = self.__translate_item_list(item_list)
if not self.__packager.next_item_will_fit_row(translated_item_list):
self.__log('Starting new row')
self.__push_item(translated_item_list)
if not self.__packager.next_row_will_fit_tray():
self.__log('Requesting new tray')
self.__load_new_tray()
else:
self.__make_room_for_next_item(translated_item_list)
self.__io_manager.output('lock_door', IOManager.LOW) # Unlock door
self.current_loop_done = 1
def __wait_for_closed_door(self):
while not self.__io_manager.input('door_is_closed'): # Wait while door is open
self.current_loop_done = 0
time.sleep(0.1)
return
def __generate_item_list(self):
new_frame = self.__capture_manager.current_frame
self.__image_analyzer.update(new_frame)
return self.__image_analyzer.analyze_image()
def __translate_item_list(self, item_list):
return [self.__coordinates_translator.translate_values(item) for item in item_list]
def __make_room_for_next_item(self, translated_item_list):
target_position = self.__packager.item_size[0] + PADDING[0]
current_position = translated_item_list[0][0]
horizontal_distance_to_move = target_position - current_position
self.__item_movement_motor.move(horizontal_distance_to_move * ITEM_MOVEMENT_CONVEYOR_STEPS_PER_CENTIMETER, True)
def __push_item(self, translated_item_list):
target_position = BUFFER_WIDTH
current_position = translated_item_list[0][0]
horizontal_distance_to_move = target_position - current_position
vertical_distance_to_move = self.__packager.item_size[1] + PADDING[1]
#.........這裏部分代碼省略.........