skiros2 icon indicating copy to clipboard operation
skiros2 copied to clipboard

reuse parameter values across skills

Open edhage opened this issue 3 years ago • 2 comments

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 (!)
   }

`

edhage avatar Oct 28 '21 12:10 edhage

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.

edhage avatar Oct 28 '21 17:10 edhage

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:

  1. The Parameter Key match between the two skills (either by definition or using a remap)
  2. 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.

frvd avatar Nov 01 '21 21:11 frvd

This issue seems answered and is stale. I am closing it. Feel free to re-open it if there are further questions.

matthias-mayr avatar Dec 02 '22 14:12 matthias-mayr