Files

45 lines
1.8 KiB
Python

"""Public-interface examples for an already supervised four-skill runtime.
`advance` is the certified owner's one-control-step callback. It owns actor
inference,500Hz safety/evidence, deadlines and cleanup. The central client below
never receives desired support loads or sampled force parameters, and cannot
reset/teleport the robot. Do not construct an unsupervised Kit here.
"""
from SkillFactory.legs.four_skills.api import CentralComposer
def compose(service, advance, *, direction_m=(.024, .010), holds_s=(.5, .3, .4, .5), loops=5):
program = CentralComposer(service, {'direction_m': direction_m, 'holds_s': holds_s, 'loops': loops})
for _ in range(12000):
if program.update():
return {'completed_loops': program.completed_loops, 'safe_stop': program.safely_stopped,
'status': service.query()}
advance()
service.request_stop()
raise TimeoutError('Central command budget exhausted; owner must finish safe cleanup')
def hold_then_switch(service, advance):
"""Illustrate calls individually; all transitions use actual ready feedback."""
def wait():
for _ in range(2000):
status = service.query()
if status['failed']:
raise RuntimeError(str(status['failure_reasons']))
if status['ready'] and status['hold_complete']:
return status
advance()
raise TimeoutError('Skill feedback not ready; no forced transition or state overwrite')
service.hold(.8)
wait()
service.call('retract', hold_seconds=.5)
wait()
service.switch('swing', direction_m=[.020, .024], hold_seconds=1.)
wait()
service.call('plant', hold_seconds=.7)
wait()
service.call('support', hold_seconds=.8)
wait()
service.request_stop()
return service.query()