Scaffolding for tracking SkillBase uses.
To try out this code, get one or two of the skill implementations
to use our new SkillDescription.SkillBase
form. For example,
in pick_place_implementations.py:
- comment out the
def createDescription
bits - instead, write: class pick(Pick.SkillBase):
- (analogously for
pick_fake
).
If you now run the following:
import ezskiros.gen_skill_classes from skills_sandbox.arm_motion.pick_place_implementations import *
you should get the following output:
SkillBase Implementation "pick" found in skills_sandbox.arm_motion.pick_place_implementations implements SkillDescription: <class 'skills_sandbox.arm_motion.pick_place_descriptions.Pick'> SkillBase Implementation "pick_fake" found in skills_sandbox.arm_motion.pick_place_implementations implements SkillDescription: <class 'skills_sandbox.arm_motion.pick_place_descriptions.Pick'>
This now directly links skills and skill descriptions. It also tracks what the environment (imported definitions etc.) was at the definition site of each skill: check e.g.:
pick._updated_env
This environment can be very useful for running eval()
, since it
captures the classes that the programmer imported in the module
in which they defined the pick
class.
Note that skill.py uses plenty of reflection (veering slightly into black magic territory) to make this work. Check the comments there to understand what is going on and how to make _updated_env include custom definitions (e.g., to replace all SkillDescription classes with custom classes etc.)