Files

38 lines
2.2 KiB
Python

"""Offline packaging check. No ROS nodes, sockets, CAN buses or motion."""
import ast, ctypes, hashlib, importlib.util, json, pathlib, subprocess, sys
import portable_paths as paths
root=paths.ROOT
for p in root.rglob('*.py'):
if '.venv' not in p.parts and '.git' not in p.parts: ast.parse(p.read_text(),filename=str(p))
for p in root.rglob('*.sh'): subprocess.run(['bash','-n',str(p)],check=True)
for p in [root/'assets/cup_reference/geometry.npz',root/'config/camera_extrinsics_current.json']:
assert p.is_file(),p
sys.path.insert(0,str(root/'dual_tag_cup_servo'))
import bootstrap
bootstrap.activate()
import execute_visual_cup_grasp, refresh_sequence_geometry, cup_sdk_follow
assert pathlib.Path(execute_visual_cup_grasp.__file__).is_relative_to(root)
from online_cup_arm_ik import ArmIK
import numpy as np
pose=ArmIK().fk(np.zeros(7));assert pose.shape==(4,4) and np.isfinite(pose).all()
from g20_left_lookup import LeftLookup
lookup=LeftLookup();assert lookup.sha256
import mujoco
model=mujoco.MjModel.from_xml_path(str(paths.HUG_RUNTIME/'assets/l20_left_mj.urdf'));assert model.nq>0
reference=root/'assets/cup_reference'
seed=refresh_sequence_geometry.observed_hand_search_seed(reference/'perception_geometry.json',pose)
assert np.isfinite(seed['T_camera_hand']).all()
geometry=execute_visual_cup_grasp.VisualGrasp.__new__(execute_visual_cup_grasp.VisualGrasp)
geometry.cap=reference
geometry.load_geometry()
assert np.isfinite(geometry.J).all()
from a7_left.controller_sdk import LIBRARY
ctypes.CDLL(str(LIBRARY))
from a7_left.observation_replay import prepare
plan=prepare();assert plan['executable'] and plan['keyframes']>=2
for name in ['complete_observed_workflow','circle_transport_source','place_open_return','release_and_return','single_lift_core','lift_fault_refresh']:
module=__import__(name);assert pathlib.Path(module.__file__).is_relative_to(root)
subprocess.run(['bash',str(root/'run.sh'),'cup'],check=True)
subprocess.run(['bash',str(root/'run.sh'),'cup','--place-at-circle','--return-after-circle'],check=True)
print(json.dumps({'offline_package_check':'passed','arm_fk':'finite','hand_model_nq':model.nq,'lookup_sha256':lookup.sha256,'observation_keyframes':plan['keyframes'],'robot_connections':0},ensure_ascii=False))