本文整理汇总了Python中machine.Machine.set_pos方法的典型用法代码示例。如果您正苦于以下问题:Python Machine.set_pos方法的具体用法?Python Machine.set_pos怎么用?Python Machine.set_pos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类machine.Machine
的用法示例。
在下文中一共展示了Machine.set_pos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Printer
# 需要导入模块: from machine import Machine [as 别名]
# 或者: from machine.Machine import set_pos [as 别名]
#.........这里部分代码省略.........
if self.axis[home_axis]['motor']:
homing_config = {
'motor': self.axis[home_axis]['motor'],
'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['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)