Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
doc:srdl2_tutorial [2014/11/27 16:50] – [Requirements of an action] admindoc:srdl2_tutorial [2014/11/27 17:05] (current) – [Matching requirements to capabilities] admin
Line 28: Line 28:
 $ rosrun rosprolog rosprolog knowrob_srdl $ rosrun rosprolog rosprolog knowrob_srdl
  
-% Load SRDL model of the PR2 robot+% Load SRDL model of the PR2 and Baxter robots
 ?- owl_parse('package://knowrob_srdl/owl/PR2.owl'). ?- owl_parse('package://knowrob_srdl/owl/PR2.owl').
 +?- owl_parse('package://knowrob_srdl/owl/baxter.owl').
  
 % Load an example task description for serving a drink % Load an example task description for serving a drink
 +?- register_ros_package(knowrob_actions).
 ?- owl_parse('package://knowrob_actions/owl/serve_drink.owl'). ?- owl_parse('package://knowrob_actions/owl/serve_drink.owl').
 </code> </code>
Line 97: Line 99:
  
 Capabilities an action depends on: Capabilities an action depends on:
-?- required_cap_for_action('http://www.roboearth.org/kb/serve_drink.owl#ServeADrink', C). + 
-C = srdl2cap:'BaseMotionCapability'+<code prolog> 
-C = srdl2cap:'BaseMotionCapability' ;+?- required_cap_for_action(serve_drink:'ServeADrink', C).
 C = srdl2cap:'BaseMotionCapability' ; C = srdl2cap:'BaseMotionCapability' ;
 C = srdl2cap:'ArmMotionCapability' ; C = srdl2cap:'ArmMotionCapability' ;
 C = srdl2cap:'GraspingCapability' ; C = srdl2cap:'GraspingCapability' ;
-C = srdl2cap:'GripperMotionCapability' ; +C = srdl2cap:'GripperMotionCapability' 
-  ...+[...
 +</code> 
 Components an action depends on (either directly or via required capabilities that depend on these components) Components an action depends on (either directly or via required capabilities that depend on these components)
-  ?- srdl2:required_comp_for_action(tablesetting:'TableSetting', Comp). +<code prolog> 
-  Comp = 'http://ias.cs.tum.edu/kb/srdl2-comp.owl#MobileBase'+?- required_comp_for_action(serve_drink:'ServeADrink', C). 
-  Comp = 'http://ias.cs.tum.edu/kb/srdl2-comp.owl#ArmMotionController'+srdl2comp:'MobileBase'
-  Comp = 'http://ias.cs.tum.edu/kb/srdl2-comp.owl#ArmComponent'+srdl2comp:'ArmMotionController'
-  ...+srdl2comp:'ArmComponent'
 +C = srdl2comp:'ManipulationEntity' 
 +[...
 +</code>
  
 ===== Missing components or capabilities ===== ===== Missing components or capabilities =====
  
-  ?- missing_cap_for_action(tablesetting:'TableSetting', tumrosie:'TUM_Rosie1', Cap). +<code prolog> 
-  Cap = 'http://ias.cs.tum.edu/kb/srdl2-cap.owl#PuttingDownAnObjectCapability'+% No components nor capabilities are missing for the ServeADrink action on the PR2: 
-  Cap = 'http://ias.cs.tum.edu/kb/srdl2-cap.owl#PickingUpAnObjectCapability' ;+?- missing_comp_for_action(serve_drink:'ServeADrink', pr2:'PR2Robot1', C). 
 +false.
  
-  ?- missing_comp_for_action(tablesetting:'TableSetting', tumrosie:'TUM_Rosie1', Comp). +?- missing_cap_for_action(serve_drink:'ServeADrink', pr2:'PR2Robot1', C). 
-  false.+false.
  
- +% The Baxter robot, in contrast, cannot perform the task due to lacking navigation abilities: 
-===== Matching requirements to capabilities =====+?- missing_cap_for_action(serve_drink:'ServeADrink', baxter:baxter_baxter1, C). 
 +srdl2cap:'BaseMotionCapability' 
 +</code> 
 +===== Behind the scenes: Implementation of the matching procedures =====
  
 The matching can effectively reduced to the following statement: The matching can effectively reduced to the following statement:
 +<code prolog>
   missing_cap_for_action(Action, Robot, Cap) :-   missing_cap_for_action(Action, Robot, Cap) :-
      required_cap_for_action(Action, Cap),      required_cap_for_action(Action, Cap),
      \+ cap_available_on_robot(Cap, Robot).      \+ cap_available_on_robot(Cap, Robot).
-A missing capability is thus defined as one that is required by an actionbut not provided by the robot. Required means that either the action itself or any sub-action has a dependency on this capability:+</code> 
 +      
 +A missing capability is thus defined as one that is required by an action but not provided by the robot. "Required" thereby means that either the action itself or any sub-action has a dependency on this capability: 
 +<code prolog>
   required_cap_for_action(Action, Cap) :-   required_cap_for_action(Action, Cap) :-
      class_properties(Action, srdl2cap:'dependsOnCapability', Cap).      class_properties(Action, srdl2cap:'dependsOnCapability', Cap).
Line 134: Line 149:
      plan_subevents_recursive(Action, SubAction),      plan_subevents_recursive(Action, SubAction),
      class_properties(SubAction, srdl2cap:'dependsOnCapability', Cap).      class_properties(SubAction, srdl2cap:'dependsOnCapability', Cap).
 +</code>
  
-There are three possibilities to express that a capability is available on a robot: Either it is asserted to be available for the whole class of robots (e.g. every PR2 has a holonomic base), for a specific robot instance, or it can be concluded that the capability should be available because all specified dependencies on components or other capabilities are fulfilled: 
  
 +There are three possibilities to express that a capability is available on a robot: Either it is asserted to be available for the whole class of robots (e.g. every PR2 has a mobile base), for a specific robot instance, or it can be concluded that the capability should be available because all specified dependencies on components or other capabilities are fulfilled:
 +<code prolog>
   % capability asserted for robot instance   % capability asserted for robot instance
   cap_available_on_robot(Cap, Robot) :-   cap_available_on_robot(Cap, Robot) :-
Line 156: Line 173:
      forall( class_properties(Cap, srdl2cap:'dependsOnCapability', SubCap),      forall( class_properties(Cap, srdl2cap:'dependsOnCapability', SubCap),
              cap_available_on_robot(SubCap, Robot) ).              cap_available_on_robot(SubCap, Robot) ).
 +</code>
  
 The matching procedure is equivalent for components. The matching procedure is equivalent for components.