Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Commit

Permalink
Rework motor management for track run
Browse files Browse the repository at this point in the history
  • Loading branch information
taesungh committed Jun 3, 2023
1 parent 429076e commit 28921ef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pod-control/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ def on_startup() -> None:
sio.start_background_task(fsm.run)


app = socketio.ASGIApp(sio, on_startup=on_startup)
fsm = FSM(pod_socket)
app = socketio.ASGIApp(sio, on_startup=on_startup, on_shutdown=fsm.stop_heartbeat)
13 changes: 4 additions & 9 deletions pod-control/src/fsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
# EventHandler = Callable[..., None | Coroutine[None, None, None]]
EventHandler = Callable[..., Union[None, Coroutine[None, None, None]]]

TRACK_FEET = 10
TRACK_FEET = 70
INCH_PER_FEET = 12
WHEEL_DIAMETER = 3 # in
ENCODER_RESOLUTION = 16
STOP_THRESHOLD = TRACK_FEET * INCH_PER_FEET / (WHEEL_DIAMETER * pi) * ENCODER_RESOLUTION
WE_RESOLUTION = 16
STOP_THRESHOLD = TRACK_FEET * INCH_PER_FEET / (WHEEL_DIAMETER * pi) * WE_RESOLUTION

ADDRESS_PT_DOWNSTREAM = 0x40

Expand Down Expand Up @@ -130,15 +130,14 @@ def _enter_service(self) -> None:

def _enter_running(self) -> None:
"""Perform operations once when starting to run the pod."""
pass
self._signal_light.enable()
log.info("Entering running")
self._brakes.disable()
self._motors.drive(8)

def _running_periodic(self) -> State:
"""Perform operations when the pod is running."""
self._running_tick += 1
self._motors.drive(20)

asyncio.create_task(
self.socket.emit_stats(
Expand Down Expand Up @@ -187,7 +186,3 @@ def _register_handlers(self, handlers: Mapping[str, EventHandler]) -> None:

def stop_heartbeat(self) -> None:
self._motors.stop_heartbeat()

def __del__(self) -> None:
self._motors.stop_heartbeat()
# self._hvs.disable()

0 comments on commit 28921ef

Please sign in to comment.