mirror of
https://github.com/undera/pylgbst.git
synced 2020-11-18 19:37:26 -08:00
calibrated new hw
This commit is contained in:
parent
4a5880de20
commit
76875d56f7
@ -11,7 +11,7 @@ class Plotter(MoveHub):
|
||||
def __init__(self, connection=None, base_speed=1.0):
|
||||
super(Plotter, self).__init__(connection)
|
||||
self.base_speed = base_speed
|
||||
self.field_width = 2.0 / self.base_speed
|
||||
self.field_width = 3.55 / self.base_speed
|
||||
self.xpos = 0
|
||||
self.ypos = 0
|
||||
self.is_tool_down = False
|
||||
@ -19,6 +19,7 @@ class Plotter(MoveHub):
|
||||
self.caret = self.motor_A
|
||||
self.wheels = self.motor_B
|
||||
self.both = self.motor_AB
|
||||
self.__last_wheel_dir = 1
|
||||
|
||||
def initialize(self):
|
||||
self._reset_caret()
|
||||
@ -45,7 +46,7 @@ class Plotter(MoveHub):
|
||||
self.caret.stop()
|
||||
self.color_distance_sensor.unsubscribe(self._on_distance)
|
||||
|
||||
self.caret.timed(0.925 / 0.4, self.base_speed)
|
||||
self.move(-self.field_width, 0)
|
||||
|
||||
def _on_distance(self, color, distance):
|
||||
self._marker_color = None
|
||||
@ -93,6 +94,8 @@ class Plotter(MoveHub):
|
||||
logging.warning("No movement, ignored")
|
||||
return
|
||||
|
||||
self._correct_wheels(movy)
|
||||
|
||||
self.xpos += movx
|
||||
self.ypos += movy
|
||||
|
||||
@ -102,6 +105,14 @@ class Plotter(MoveHub):
|
||||
|
||||
# time.sleep(0.5)
|
||||
|
||||
def _correct_wheels(self, movy):
|
||||
if not movy:
|
||||
return
|
||||
wheel_dir = movy / abs(movy)
|
||||
if wheel_dir == -self.__last_wheel_dir:
|
||||
self.wheels.angled(270, -wheel_dir)
|
||||
self.__last_wheel_dir = wheel_dir
|
||||
|
||||
@staticmethod
|
||||
def _calc_motor(movx, movy):
|
||||
amovx = float(abs(movx))
|
||||
|
Loading…
x
Reference in New Issue
Block a user