skiros2
skiros2 copied to clipboard
reuse parameter values across skills
In one Skill I update a parameter which I want to use in the "next skill".
This is getspeed that outputs forwardspeed and rotationspeed. It works great when used in the SkillManager, but it gives me always "forward speed: 0.0" (upon self.success) if used in a serialstar (while it is not 0.0, as tested standalone).
How can I get updated parameters from one skill to another?
` class GetSpeed(SkillDescription): def createDescription(self): self.addParam("Distance", 0.0, ParamTypes.Required) self.addParam("Angle", 0.0, ParamTypes.Required) self.addParam("Duration", 1.0, ParamTypes.Required) self.addParam("ForwardSpeed", 1.0, ParamTypes.Inferred) self.addParam("RotationSpeed", 1.0, ParamTypes.Inferred) class getspeed(PrimitiveBase): def createDescription(self): self.setDescription(GetSpeed(), self.class.name)
def execute(self):
t = self.params["Duration"].value
self.params["ForwardSpeed"].value = self.params["Distance"].value / t
self.params["RotationSpeed"].value = self.params["Angle"].value / t
return self.success("forward speed:" + str(self.params["ForwardSpeed"].value))
def onEnd(self):
return True
`
while not working when used in : ` class MoveDistance(SkillDescription): def createDescription(self): self.addParam("Turtle", Element("cora:Robot"), ParamTypes.Required) self.addParam("Distance", 0.0, ParamTypes.Required) self.addParam("Angle", 0.0, ParamTypes.Required) self.addParam("Duration", 1.0, ParamTypes.Required) self.addParam("ForwardSpeed", 0.0, ParamTypes.Optional) self.addParam("RotationSpeed", 0.0, ParamTypes.Optional)
class movedistance(SkillBase): def createDescription(self): self.setDescription(MoveDistance(), self.class.name)
def expand(self, skill):
skill.setProcessor(SerialStar())
uid = id(self)
skill(
self.skill("GetSpeed", "getspeed"),
self.skill("Move2", "move2") <-- this one has ForwardSpeed as inputparameter (!)
}
`
I also defined an Element("sumo:Object") on which I added some custom DatatypeProperties, and added a NamedIndividual to the world model. Than instead of changing the parameters, I changed this element (so basically changed the WM) and used it the same way. Result was the same, when I perform the skill the WM is adjusted, but when I use the skill in SerialStar than the WM is not adjusted. So there is no way to keep a status that I can use between Skills.
Hi @edhage , so for 1st issue, if you want a skill B to see the output of a skill A, executed before, you need to make sure that:
- The Parameter Key match between the two skills (either by definition or using a remap)
- The second skill does not set a default parameter So, in your case in the second skill you need to change: self.addParam("ForwardSpeed", float, ParamTypes.Optional)
For the issue with the Object, I need more details about how you coded your skills.
This issue seems answered and is stale. I am closing it. Feel free to re-open it if there are further questions.