Skip to content

Commit

Permalink
Wait for scene to load instead of relying on timeout that isn't alway…
Browse files Browse the repository at this point in the history
…s enough
  • Loading branch information
ovidner committed Dec 1, 2023
1 parent 3ba458f commit c0d531a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/autopack/ips_communication/ips_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def create_costfield(ips_instance, harness_setup):


def load_scene(ips_instance, scene_file_path):
return ips_instance.call("Ips.loadScene", scene_file_path)
return ips_instance.call("autopack.loadAndFitScene", scene_file_path)


def route_harness_all_solutions(
Expand Down Expand Up @@ -119,9 +119,6 @@ def check_distance_of_points(ips_instance, harness_setup, coords, max_geometry_d
def ergonomic_evaluation(ips_instance, parts, coords):
ergo_path = pathlib.Path(__file__).parent / "ErgonomicEvaluation.ips"
load_scene(ips_instance, str(ergo_path.resolve()))
import time

time.sleep(1)
return ips_instance.call("autopack.evalErgo", parts, coords)


Expand Down
12 changes: 12 additions & 0 deletions src/autopack/ips_communication/lualib/autopack.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ local function range(from, to)
return arr
end

local function loadAndFitScene(scenePath)
print("Loading scene " .. scenePath)
local loaded = Ips.loadScene(scenePath)
-- Fitting the scene helps with two things:
-- 1. The scene is loaded in the background, and this makes sure it's
-- done before we continue
-- 2. It makes it easier to see what's going on
Ips.fitScene()
return loaded
end

local function createHarnessRouter(harnessSetup)
local cableSim = CableSimulation()
local harnessRouter = HarnessRouter()
Expand Down Expand Up @@ -307,6 +318,7 @@ module.ips3VecToTable = ips3VecToTable
module.ipsNVecToTable = ipsNVecToTable
module.range = range

module.loadAndFitScene = loadAndFitScene
module.getCostField = getCostField
module.setHarnessRouterNodeCosts = setHarnessRouterNodeCosts
module.routeHarnessSolutions = routeHarnessSolutions
Expand Down

0 comments on commit c0d531a

Please sign in to comment.