当前位置: 首页>>代码示例>>Python>>正文


Python Motor.move_to方法代码示例

本文整理汇总了Python中motor.Motor.move_to方法的典型用法代码示例。如果您正苦于以下问题:Python Motor.move_to方法的具体用法?Python Motor.move_to怎么用?Python Motor.move_to使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在motor.Motor的用法示例。


在下文中一共展示了Motor.move_to方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle_read

# 需要导入模块: from motor import Motor [as 别名]
# 或者: from motor.Motor import move_to [as 别名]
    def handle_read(self):
       
        data0 = self.recv(160);
        if data0:            
            data = ConstBitStream(bytes=data0, length=160)
            # print "All: %s" % data.bin
 
            msize = data.read('intle:16')
            mtype = data.read('intle:16')
            mtime = data.read('intle:64')
 
            # RA: 
            ant_pos = data.bitpos
            ra = data.read('hex:32')
            data.bitpos = ant_pos
            ra_uint = data.read('uintle:32')
 
            # DEC:
            ant_pos = data.bitpos
            dec = data.read('hex:32')
            data.bitpos = ant_pos
            dec_int = data.read('intle:32')
             
            logging.debug("Size: %d, Type: %d, Time: %d, RA: %d (%s), DEC: %d (%s)" % (msize, mtype, mtime, ra_uint, ra, dec_int, dec))
                       
            (ra, dec, time) = coords.int_2_rads(ra_uint, dec_int, mtime)

            x = transformar_coordenadas(dec, ra)
            az,alt = x.get_azi_alt()

            #instancia o motor de azimute nos pinos 12, 16, 20 e 21 do RPi
            motor_az = Motor([31,33,35,37])
            motor_az.rpm = 5
            motor_az.mode = 2
            motor_az.move_to(az-self.az_anterior)
            self.az_anterior = az

            #instancia o motor de azimute nos pinos 32, 36, 38 e 40 do RPi
            motor_alt = Motor([32,36,38,40])
            motor_alt.rpm = 5
            motor_alt.mode = 2
            motor_alt.move_to(alt-self.alt_anterior)
            self.alt_anterior = alt

            logging.debug("Azimute: %d, Altitude: %d" % (az,alt))
            
            # envia as cordenadas para o Stellarium
            self.act_pos(ra, dec)
开发者ID:israelps,项目名称:telescopioRpi,代码行数:50,代码来源:servidor.py

示例2: __init__

# 需要导入模块: from motor import Motor [as 别名]
# 或者: from motor.Motor import move_to [as 别名]

#.........这里部分代码省略.........
                                           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]
        self.__item_movement_motor.move_to(horizontal_distance_to_move * ITEM_MOVEMENT_CONVEYOR_STEPS_PER_CENTIMETER, True)
        self.__io_manager.output('push_items', IOManager.HIGH)  # Request piston push from PLC
        time.sleep(TRAY_MOVEMENT_CONVEYOR_DELAY_DURING_PUSH)
        self.__io_manager.output('push_items', IOManager.LOW)
        self.__tray_movement_motor.move(vertical_distance_to_move * TRAY_MOVEMENT_CONVEYOR_STEPS_PER_CENTIMETER)
        while not self.__io_manager.input('push_completed'):  # Wait while piston operates
            time.sleep(0.1)
        self.__item_movement_motor.move_to(ITEM_MOVEMENT_CONVEYOR_REST_POSITION, True)
        return

    def __load_new_tray(self):
        self.__tray_movement_motor.loop_back_home()
        self.__io_manager.output('load_new_tray', IOManager.HIGH)  # Request a new tray from the loader
        time.sleep(0.5)
        self.__io_manager.output('load_new_tray', IOManager.LOW)
        while not self.__io_manager.input('load_completed'):  # Wait while the
            time.sleep(0.1)
        self.__tray_movement_motor.move(STEPS_FROM_LOADER_TO_ITEM_CONVEYOR)
        return

    def __calibrate_motors(self):
        self.__item_movement_motor.find_home()
        self.__tray_movement_motor.find_home(True)

    def __log(self, message):
        if self.verbose:
            print(message)
开发者ID:willGuimont,项目名称:Depowdering,代码行数:104,代码来源:depowdering.py

示例3: __init__

# 需要导入模块: from motor import Motor [as 别名]
# 或者: from motor.Motor import move_to [as 别名]

#.........这里部分代码省略.........
        # Motor-Config
        motor_name = settings["Name"]
        motor_config = settings["Config"]
        
        self.motor = Motor(self.motor_serial, motor_name)
        self.motor.load_motor_config(motor_config)
        self.motor.scaling = float(settings["Scaling"])
    
    def init_vna(self):
        # Abkürzung
        settings = self.config["VNA"]
        
        # Serial-Config
        port = settings["Port"]
        baudrate = int(settings["Baudrate"])
        
        self.vna = VNA(port, baudrate)
        
        # VNA-Settings
        points = int(settings["Points"])
        power = int(settings["Power"])
        average = int(settings["Average"])
        
        self.vna.set_points(points)
        self.vna.set_power(power)
        self.vna.set_avg(average)
        
        self.vna.measurecycles()
    
    def measure(self):
        #Abkürzung
        settings = self.config["MEASUREMENT"]
        
        start = float(settings["Start"])
        stop = float(settings["Stop"])
        
        # Checkmode Settings
        checkmode = settings.getboolean("Checkmode")
        cm_reference = float(settings["ReferencePoint"])
        
        if start > stop:
            start, stop = stop, start
        
        # Überprüfung welche Methode der Berechnung der stepsize gewählt wurde.
        # Entweder aus der Anzahl der Schritte oder mit fester angegebener step-
        # size
        if not (("StepSize" in settings) ^ ("Steps" in settings)):
            raise RuntimeError("StepSize and Steps in configuration file are"
                               "mutually exclusive")
        elif "StepSize" in settings:
            stepsize = float(settings["StepSize"])
        else:
            steps = int(settings["Steps"])
            stepsize = (stop - start) / steps
        
        
        with open(self.out_filename, "w") as outf:
            # Tabellenkopf
            print("# Config: {}".format(self.config_filename), file=outf)
            print("# Date: {}".format(asctime()), file=outf)
            print("# Center: {}".format(self.vna.get_center()), file=outf)
            print("# Span: {}".format(self.vna.get_span()), file=outf)
            print("# Points: {}".format(self.vna.get_points()), file=outf)
            
            if checkmode:
                print("# P\tf\tf_ref\tfreq-t_ref", file=outf)
            else:
                print("# P\tf", file=outf)
            
            pos = start
            while stop - pos > -1E-6:
                print("Measuring: d = {} mm".format(pos))
                
                if checkmode:
                    f_ref = self.get_freq_at(cm_reference)
                freq = self.get_freq_at(pos)
                
                if checkmode:
                    print("{0:.3f}\t{1}\t{2}\t{3}".format(pos, freq, f_ref, freq - f_ref),
                          file=outf)
                else:
                    print("{0:.3f}\t{1}".format(pos, freq), file=outf)
                
                pos += stepsize
                outf.flush()
        self.motor.move_to(start)
        
        
    def get_freq_at(self, pos):
        delay = float(self.config["MEASUREMENT"]["Delay"])
        average = int(self.config["VNA"]["Average"])
        
        self.motor.move_to(pos)
        while self.motor.is_moving():
            sleep(0.1)
        sleep(delay)
        self.vna.measurecycles()
        freq, refl = self.vna.mark[1].search_min()
        
        return freq
开发者ID:chrisieh,项目名称:SKM,代码行数:104,代码来源:stoerkoerpermessung.py

示例4: print

# 需要导入模块: from motor import Motor [as 别名]
# 或者: from motor.Motor import move_to [as 别名]
                    if sub_tracker:
                        resized_window = util.resize_selection(tracking_window, 0.8)
                        # print(tracking_window, resized_window)
                        sub_tracker.init(frame, resized_window)

                if dlib_tracker:
                    dlib_tracker.init(frame, tracking_window)
                    tracking_processing_flag = True

            else: # tracking_processing_flag is False:
                centerX = round((tracking_window['x1'] + tracking_window['x2']) / 2)
                centerY = round((tracking_window['y1'] + tracking_window['y2']) / 2)
                center_to_x = centerX - cfg['HALF_WIDTH']
                center_to_y = cfg['HALF_HEIGHT'] - centerY
                # motor.move_to(center_to_x, center_to_y)
                motor.move_to(center_to_x, center_to_y, zoom.current_zoom)

            capture = None
            tracking_window['start'] = False

        elif tracking_processing_flag is True:
            if show_lap_time_flag is True: # 'l' key
                current_time = datetime.datetime.now().time().isoformat()
                toc = time.time()
                print("[INFO] Tracking duration: {:04.0f} ms @{}".format(1000*(toc-tic), current_time))
                tic = toc

            if kcf_tracker:
                if kcf_tracker.force_init_flag is True:
                    print('[KCF] Force init')
                    kcf_tracker.init(frame)
开发者ID:zooliet,项目名称:UWTracking,代码行数:33,代码来源:main.py

示例5: str

# 需要导入模块: from motor import Motor [as 别名]
# 或者: from motor.Motor import move_to [as 别名]
import RPi.GPIO as GPIO
import picamera
from time import sleep
from motor import Motor

GPIO.setmode(GPIO.BCM)

PINS_ON_ULN = [17,18,22,23]
ROTATION_ANGLE = 225
PICTURE_EACH_HOW_MUCH_DEGREES = 1
MILLISECONDS_OF_WORK = 4 * 60 * 60
STEPS = ROTATION_ANGLE / PICTURE_EACH_HOW_MUCH_DEGREES
SLEEP_PER_STEP = MILLISECONDS_OF_WORK / STEPS
SLEEP_PER_PICTURE = 10000

print "Sleep per step: " + str(SLEEP_PER_STEP)
motor = Motor(PINS_ON_ULN)
motor.rpm = 1
with picamera.PiCamera() as camera:
    degree = 0.0
    while degree < ROTATION_ANGLE:
        filename = 'deg'+str(degree)+'.jpg'
        print "Capturing: " + filename
        camera.capture(filename)
	degree += PICTURE_EACH_HOW_MUCH_DEGREES 
	print "move to "+str(degree)
        motor.move_to(degree)
	sleep(SLEEP_PER_STEP)
开发者ID:jonatas,项目名称:motolapse,代码行数:30,代码来源:run.py


注:本文中的motor.Motor.move_to方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。