當前位置: 首頁>>代碼示例>>Python>>正文


Python Machine.move_to方法代碼示例

本文整理匯總了Python中machine.Machine.move_to方法的典型用法代碼示例。如果您正苦於以下問題:Python Machine.move_to方法的具體用法?Python Machine.move_to怎麽用?Python Machine.move_to使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在machine.Machine的用法示例。


在下文中一共展示了Machine.move_to方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Printer

# 需要導入模塊: from machine import Machine [as 別名]
# 或者: from machine.Machine import move_to [as 別名]

#.........這裏部分代碼省略.........
                        'home_retract': home_retract,
                        'acceleration': home_acceleration,
                        'homing_right_position': homing_right_position,
                    }
                    if self.axis[home_axis]['bow_step']:
                        homing_config['jerk'] = self.axis[home_axis]['bow_step']
                else:
                    # todo we should check if there is a motor for the left endstop??
                    homing_config = {
                        'motor': self.axis[home_axis]['end-stops']['left']['motor'],
                        'followers': self.axis[home_axis]['motors'],
                        'timeout': 0,
                        'home_speed': home_speed,
                        'home_slow_speed': home_precision_speed,
                        'home_retract': home_retract,
                        'acceleration': home_acceleration,
                        'homing_right_position': homing_right_position,
                    }
                    if self.axis[home_axis]['bow_step']:
                        homing_config['bow'] = self.axis[home_axis]['bow_step']

                # and do the homing
                self.machine.home(homing_config, timeout=self._homing_timeout)
                # better but still not good - we should have a better concept of 'axis'
                self.axis[home_axis]['homed'] = True
                self.axis_position[home_axis] = 0

    def set_position(self, positions):
        if positions:
            positions['type'] = 'set_position'
            # todo and what if there is no movement??
            self._print_queue.add_movement(positions)

    def relative_move_to(self, position):
        movement = {}
        for axis_name, pos in self.axis_position.iteritems():
            new_pos = pos
            if axis_name in position:
                new_pos += position[axis_name]
            movement[axis_name] = new_pos
        self.move_to(movement)

    # tuple with x/y/e coordinates - if left out no change is intended
    def move_to(self, position):
        if self.printing:
            position['type'] = 'move'
            self._print_queue.add_movement(position)
        else:
            self.start_print()
            position['type'] = 'move'
            self._print_queue.add_movement(position)
            self.finish_print()

    def execute_movement(self, movement):
        if movement['type'] == 'move':
            step_pos, step_speed_vector = self._add_movement_calculations(movement)
            x_move_config, y_move_config, z_move_config, e_move_config = self._generate_move_config(movement,
                                                                                                    step_pos,
                                                                                                    step_speed_vector)
            self._move(movement, step_pos, x_move_config, y_move_config, z_move_config, e_move_config)
        elif movement['type'] == 'set_position':
            for axis_name in self.axis:
                set_pos_name = "s%s" % axis_name
                if set_pos_name in movement:
                    position = movement[set_pos_name]
                    axis = self.axis[axis_name]
開發者ID:MbedTinkerer,項目名稱:T-Bone,代碼行數:70,代碼來源:printer.py


注:本文中的machine.Machine.move_to方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。