Skip to content
Snippets Groups Projects
Commit 35124740 authored by Jake Read's avatar Jake Read
Browse files

she done

parent ecd5e0e8
Branches jake-update
No related tags found
No related merge requests found
No preview for this file type
......@@ -106,8 +106,8 @@ class SketchyMachineMotion:
print_point_transmits = False
), self.queue_planner)
print("Machine / Begin: Waiting for Clocks... ")
await asyncio.sleep(3)
# print("Machine / Begin: Waiting for Clocks... ")
# await asyncio.sleep(3)
print("Machine / Begin: Startup MAXL... ")
await self._maxl_core.begin()
print("Machine / Begin: ... done ")
......
No preview for this file type
No preview for this file type
import asyncio
from dataclasses import dataclass
from typing import List, TYPE_CHECKING
from osap.packets.routes import Route, route_build
from ..utils.keys import PacketKeys
from ..utils.time_utils import get_millisecond_timestamp
from ..utils.time_utils import get_millisecond_timestamp, get_microsecond_timestamp
from ..utils.random_gen import random_four_byte_write_new, random_four_byte_check_match
from .netrunner_atomics import LinkGatewayInfoResponse, NetRunnerAtomics, PortInfoResponse, RTInfoResponse
......@@ -178,3 +179,52 @@ class NetRunner:
finally:
self.map_discovery_is_running = False
# end update_map
# properly, this would add a metric for clock stability as well...
async def await_time_settle(self, print_updates = False, await_spread_epsilon_us = 1000):
skew_alpha = 0.95 # fw default is 0.95
p_gain = 0.000001 # fw default is 0.000001, minimum gain is 0.0000003
if self.map_completion_time == 0 or len(self.map.runtimes) == 1:
return
# initialize settings for each device...
for d, device in enumerate(self.map.runtimes):
if device.protocol_build == 'Python':
continue
# basically get everyone on-time and with 1.0 skew to start even keeled,
now = get_microsecond_timestamp()
await self.atomics.set_time_config(device.route, now, 1.0, skew_alpha, p_gain, True)
ok_cycle_count = 0
ok_cycle_pass = 3
# now run a loop where we poll each, get a grouping... and post it ?
while True:
clock_errors = []
rtts = []
for d, device in enumerate(self.map.runtimes):
if device.protocol_build == 'Python':
continue
our_time = get_microsecond_timestamp()
time_stats = await self.atomics.get_time_config(device.route)
device_time = time_stats.system_time - time_stats.rtt / 2
clock_errors.append(our_time - device_time)
rtts.append(time_stats.rtt)
print(F"ERRS: {[int(err) for err in clock_errors]}, \tRTT: {[int(rtt) for rtt in rtts]}")
if all(abs(err) < await_spread_epsilon_us for err in clock_errors):
ok_cycle_count += 1
else:
ok_cycle_count = 0
if ok_cycle_count >= ok_cycle_pass:
print("CLOCKS OK...")
return
else:
await asyncio.sleep(0.25)
\ No newline at end of file
......@@ -47,9 +47,14 @@ async def main():
# ... clip 21500, seems like where the fuckups start...
# parser = GCodeParser("test_files/3DBenchy_Top.gcode")
print("---------------------------------- collect system ...")
system_map = await osap.netrunner.update_map()
system_map.print()
print("---------------------------------- wait for clocks to settle ...")
await osap.netrunner.await_time_settle(print_updates=True)
print("---------------------------------- machine setup ...")
machine = SketchyMachineMotion(osap, system_interpolation_interval, system_twin_to_real_ms, extents = machine_extents)
await machine.begin()
......
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment