-
Notifications
You must be signed in to change notification settings - Fork 25
Description
[This is copy of https://github.com/matthias-mayr/skiros2_pyrobosim_lib/issues/2]
Let's assume we have the Drive skill from the examples
class Drive(SkillDescription):
def createDescription(self):
#=======Params=========
self.addParam("StartLocation", Element("skiros:Location"), ParamTypes.Inferred)
self.addParam("TargetLocation", Element("skiros:Location"), ParamTypes.Required)
#=======PreConditions=========
self.addPreCondition(self.getRelationCond("RobotAt", "skiros:at", "Robot", "StartLocation", True))
#=======PostConditions=========
self.addPostCondition(self.getRelationCond("NoRobotAt", "skiros:at", "Robot", "StartLocation", False))
self.addPostCondition(self.getRelationCond("RobotAt", "skiros:at", "Robot", "TargetLocation", True))We can use it without specifying StartLocation since this parameter can be automatically set by autoparameterization. However, this sets the StartLocation parameter on the blackboard.
Now if the robot is currently at Location0 and we use the drive skill twice in a row:
# Robot location in world model: {Location0}
# StartLocation parameter on blackboard: {}
self.skill("Drive", "", remap={"TargetLocation: "Location1"}),
# Robot location in world model: {Location1}
# StartLocation parameter on blackboard: {Location0}
self.skill("Drive", "", remap={"TargetLocation: "Location2"}),the second execution would fail with a precondition error. This is because the first execution of Drive sets the blacboard parameter StartLocation to Location0. The robot would then move and the world model would be updated so that the robot is at Location1. Now the second Drive skill is started,but because the StartLocation parameter is already set on the blackboard, the autoparameterization does not run again. Unfortunately StartLocation contains the location value, so if this precondition is checked against the world model, it would fail.
A workaround is to "unset` the blackboard parameter with a special skill, but that is not very intuitive and makes BTs larger than necessary.
Some smart handling of this is needed. Maybe detect if a parameter is mapped implicitly, autoparameterization should run instead of taking the blackboard parameter.