35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
"""Simple CLI for EdgeMind planner demonstration"""
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
|
|
from .planner import Action, EdgeMindPlanner, PlanRequest
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(prog="edge-mind-cli", description="EdgeMind Planner CLI Demo")
|
|
parser.add_argument("goal", help="Goal to plan for (e.g., reach_target)")
|
|
parser.add_argument("budget", type=float, help="Energy budget for the plan")
|
|
args = parser.parse_args()
|
|
|
|
# Simple demo actions
|
|
actions = [
|
|
Action(name="move_forward", energy_cost=1.0, provides={"reach_target"}),
|
|
Action(name="rotate", energy_cost=0.2, provides={"orient"}),
|
|
Action(name="lift_safe", energy_cost=0.3, provides={"lift_target"}),
|
|
]
|
|
planner = EdgeMindPlanner()
|
|
req = PlanRequest(goals=[args.goal], actions=actions, energy_budget=args.budget)
|
|
res = planner.plan(req)
|
|
if res.ok:
|
|
print("Planned actions:")
|
|
for a in res.planned_actions:
|
|
print(f"- {a.name} (cost={a.energy_cost})")
|
|
print(f"Total energy: {res.total_energy}")
|
|
else:
|
|
print(f"Plan failed: {res.message}")
|
|
return 0 if res.ok else 1
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|