Skip to content

Commit

Permalink
add random circle to grbl; fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
misko committed Nov 23, 2024
1 parent 7c0dc0c commit 322d5c9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
20 changes: 20 additions & 0 deletions spf/grbl/grbl_interactive.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import argparse
import logging
import queue
import random
import select
import sys
import threading
Expand Down Expand Up @@ -28,6 +29,7 @@
tx_calibration_point = np.array([550, 450])
circle_center = np.array([2000, 1500])
max_circle_diameter = 1900
min_circle_diameter = 900

run_grbl = True

Expand Down Expand Up @@ -749,6 +751,7 @@ def __init__(self, controller, routine):
self.routines = {
"v1_calibrate": self.v1_calibrate,
"rx_circle": self.rx_circle,
"rx_random_circle": self.rx_random_circle,
"tx_circle": self.tx_circle,
"bounce": self.bounce,
}
Expand Down Expand Up @@ -861,6 +864,23 @@ def rx_circle(self):
),
]

def rx_random_circle(self):
self.planners = [
CirclePlanner(
self.controller.dynamics,
start_point=self.controller.position["xy"][0],
circle_diameter=random.randint(
min_circle_diameter, max_circle_diameter
),
circle_center=circle_center,
),
StationaryPlanner(
self.controller.dynamics,
start_point=self.controller.position["xy"][1],
stationary_point=circle_center,
),
]

def v1_calibrate(self):
self.planners = [
StationaryPlanner(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def run_inference_on_ds(
precompute_cache=precompute_cache,
)

_, val_dataloader = load_dataloaders(
_, val_dataloader, _ = load_dataloaders(
datasets_config=datasets_config,
optim_config=optim_config,
global_config=config["global"],
Expand Down
2 changes: 1 addition & 1 deletion tests/test_new_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def dataloader_inference(
model, global_config, datasets_config, optim_config, model_config
):

_, val_dataloader = load_dataloaders(
_, val_dataloader, _ = load_dataloaders(
datasets_config=datasets_config,
optim_config=optim_config,
global_config=global_config,
Expand Down

0 comments on commit 322d5c9

Please sign in to comment.