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:08] – [Matching requirements to capabilities] admindoc:srdl2_tutorial [2014/11/27 17:05] (current) – [Matching requirements to capabilities] admin
Line 1: Line 1:
 ====== Semantic Robot Description Language ====== ====== Semantic Robot Description Language ======
 ~~NOTOC~~ ~~NOTOC~~
 +
 +\\
 +^ This page describes the 'catkinized' version of KnowRob that uses the [[http://wiki.ros.org/catkin/|catkin buildsystem]] and the pure Java-based [[http://wiki.ros.org/rosjava|rosjava]]. The documentation for the older version, which was based on the rosbuild buildsystem and rosjava_jni, can be found [[/doc/srdl2_tutorial?rev=1417104665|here]].^
 +\\
 +
 +
 {{ :doc:srdl-left-right-arm.png?nolink&400|}} {{ :doc:srdl-left-right-arm.png?nolink&400|}}
 The Semantic Robot Description Language (SRDL) extends KnowRob with representations for robot hardware, robot software and robot capabilities. The hardware models can automatically be [[/doc/create_srdl_model|imported from a URDF description]], and are annotated with additional semantic information. For example, one can annotate semantically meaningful groups of links such as the left arm or the right gripper (see image on the right). SRDL integrates this information into KnowRob, allowing the system to reason about the robot's configuration. In addition, SRDL provides inference mechanisms that operate on the robot model and are able to check which dependencies of [[doc/modeling_tasks_and_actions|action descriptions]] are available on the robot. This allows to identify missing components or capabilities. The Semantic Robot Description Language (SRDL) extends KnowRob with representations for robot hardware, robot software and robot capabilities. The hardware models can automatically be [[/doc/create_srdl_model|imported from a URDF description]], and are annotated with additional semantic information. For example, one can annotate semantically meaningful groups of links such as the left arm or the right gripper (see image on the right). SRDL integrates this information into KnowRob, allowing the system to reason about the robot's configuration. In addition, SRDL provides inference mechanisms that operate on the robot model and are able to check which dependencies of [[doc/modeling_tasks_and_actions|action descriptions]] are available on the robot. This allows to identify missing components or capabilities.
Line 17: Line 23:
   * Task model: Description of the concrete task at hand, using the action classes defined in the srdl-action ontology   * Task model: Description of the concrete task at hand, using the action classes defined in the srdl-action ontology
  
-===== Matching requirements to capabilities =====+===== Startup ===== 
 + 
 +<code prolog> 
 +$ rosrun rosprolog rosprolog knowrob_srdl 
 + 
 +% Load SRDL model of the PR2 and Baxter robots 
 +?- 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 
 +?- register_ros_package(knowrob_actions). 
 +?- owl_parse('package://knowrob_actions/owl/serve_drink.owl'). 
 +</code> 
 + 
 +===== Components and capabilities of a robot ===== 
 +Read all components of a robot. There is no distinction between robots and components any more, robots are just complex components that consist of many parts. 
 +<code prolog> 
 +?- sub_component(pr2:'PR2Robot1', Sub). 
 +Sub = pr2:pr2_base ; 
 +Sub = pr2:pr2_left_arm ; 
 +Sub = pr2:pr2_right_arm 
 +[...] 
 +</code> 
 + 
 +Filter the list of components to only those of a given type, e.g. a //Camera//: 
 + 
 +<code prolog> 
 +?- sub_component(pr2:'PR2Robot1', Sub),  
 +   owl_individual_of(Sub, srdl2comp:'Camera'). 
 +Sub = pr2:pr2_high_def_frame ; 
 +Sub = pr2:pr2_high_def_frame ; 
 +Sub = pr2:pr2_wide_stereo_l_stereo_camera_frame ; 
 +Sub = pr2:pr2_wide_stereo_r_stereo_camera_frame ; 
 +Sub = pr2:pr2_narrow_stereo_l_stereo_camera_frame 
 +[...] 
 +</code> 
 + 
 +Read all properties of a component: 
 + 
 +<code prolog> 
 +?- sub_component(pr2:'PR2Robot1', Sub), owl_has(Sub, P, O). 
 +Sub = pr2:pr2_high_def_frame, 
 +Sub = pr2:pr2_high_def_frame, 
 +P = srdl2comp:update_rate, 
 +O = literal(type('http://qudt.org/vocab/unit#Hertz','20.0')) ; 
 +Sub = pr2:pr2_high_def_frame, 
 +P = srdl2comp:frameName, 
 +O = literal(type(xsd:string,high_def_optical_frame)) ; 
 +Sub = pr2:pr2_high_def_frame, 
 +P = srdl2comp:hfov, 
 +O = literal(type(xsd:string,'0.785398163397')) 
 +[...] 
 +</code> 
 + 
 +Check whether a component of a certain type exists on a robot (or, in general, as part of another component): 
 +<code prolog> 
 +?- comp_type_available(pr2:'PR2Robot1', srdl2comp:'Camera'). 
 +true 
 + 
 +?- comp_type_available(pr2:'PR2Robot1', Sub). 
 +Sub = srdl2comp:'Pr2Base'
 +Sub = srdl2comp:'WheeledBase'
 +Sub = srdl2comp:'MobileBase'
 +[...] 
 +</code> 
 + 
 +Check which capabilities exists on a robot: 
 +<code prolog> 
 +?- cap_available_on_robot(Cap, pr2:'PR2Robot1'). 
 +Cap = srdl2cap:'GraspingCapability'
 +Cap = srdl2cap:'ObjectManipulationCapability'
 +[...] 
 +</code> 
 +===== Requirements of an action ===== 
 + 
 +Capabilities an action depends on: 
 + 
 +<code prolog> 
 +?- required_cap_for_action(serve_drink:'ServeADrink', C). 
 +C = srdl2cap:'BaseMotionCapability'
 +C = srdl2cap:'ArmMotionCapability'
 +C = srdl2cap:'GraspingCapability'
 +C = srdl2cap:'GripperMotionCapability' 
 +[...] 
 +</code> 
 + 
 +Components an action depends on (either directly or via required capabilities that depend on these components) 
 +<code prolog> 
 +?- required_comp_for_action(serve_drink:'ServeADrink', C). 
 +C = srdl2comp:'MobileBase'
 +C = srdl2comp:'ArmMotionController'
 +C = srdl2comp:'ArmComponent'
 +C = srdl2comp:'ManipulationEntity' 
 +[...] 
 +</code> 
 + 
 +===== Missing components or capabilities ===== 
 + 
 +<code prolog> 
 +% No components nor capabilities are missing for the ServeADrink action on the PR2: 
 +?- missing_comp_for_action(serve_drink:'ServeADrink', pr2:'PR2Robot1', C). 
 +false. 
 + 
 +?- missing_cap_for_action(serve_drink:'ServeADrink', pr2:'PR2Robot1', C). 
 +false. 
 + 
 +% The Baxter robot, in contrast, cannot perform the task due to lacking navigation abilities: 
 +?- missing_cap_for_action(serve_drink:'ServeADrink', baxter:baxter_baxter1, C). 
 +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 29: 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 51: 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.
  
  
-===== Example queries ===== 
- 
-==== Components and capabilities of a robot ==== 
-Read all components of a robot. There is no distinction between robots and components any more, robots are just complex components that consist of many parts. 
-  ?- srdl2:sub_component(tumrosie:'TUM_Rosie1', Sub). 
-  Sub = 'http://ias.cs.tum.edu/kb/TUM_Rosie.owl#TUM_Rosie_WheeledOmnidirPlatform1' ; 
-  Sub = 'http://ias.cs.tum.edu/kb/TUM_Rosie.owl#TUM_Rosie_Torso1' . 
- ... 
-Check whether a component of a certain type exists on a robot (or, in general, as part of another component): 
-  ?- srdl2:comp_type_available(tumrosie:'TUM_Rosie1', CompT). 
-  CompT = 'http://ias.cs.tum.edu/kb/srdl2-comp.owl#VectorFieldArmController' ; 
-  CompT = 'http://ias.cs.tum.edu/kb/srdl2-comp.owl#ArmMotionController' ; 
-  CompT = 'http://ias.cs.tum.edu/kb/srdl2-comp.owl#MotionControllerComponent' ; 
-  ... 
-   
-Check which capabilities exists on a robot 
-  ?- srdl2:cap_available_on_robot(Cap, tumrosie:'TUM_Rosie1'). 
-  Cap = 'http://ias.cs.tum.edu/kb/srdl2-cap.owl#ArmMotionCapability' ; 
-  Cap = 'http://ias.cs.tum.edu/kb/srdl2-cap.owl#BaseMotionCapability' ; 
-  Cap = 'http://ias.cs.tum.edu/kb/srdl2-cap.owl#GripperMotionCapability' ; 
-  Cap = 'http://ias.cs.tum.edu/kb/srdl2-cap.owl#HeadMotionCapability' ; 
-  ... 
- 
-==== Action requirements ==== 
-Capabilities an action depends on: 
-  ?- srdl2:required_cap_for_action(tablesetting:'TableSetting', Cap). 
-  Cap = 'http://ias.cs.tum.edu/kb/srdl2-cap.owl#PuttingDownAnObjectCapability' ; 
-  Cap = 'http://ias.cs.tum.edu/kb/srdl2-cap.owl#PickingUpAnObjectCapability' ; 
-  Cap = 'http://ias.cs.tum.edu/kb/srdl2-cap.owl#BaseMotionCapability' ; 
-  Cap = 'http://ias.cs.tum.edu/kb/srdl2-cap.owl#ArmMotionCapability' ; 
-  ... 
-Components an action depends on (either directly or via required capabilities that depend on these components) 
-  ?- srdl2:required_comp_for_action(tablesetting:'TableSetting', Comp). 
-  Comp = 'http://ias.cs.tum.edu/kb/srdl2-comp.owl#MobileBase' ; 
-  Comp = 'http://ias.cs.tum.edu/kb/srdl2-comp.owl#ArmMotionController' ; 
-  Comp = 'http://ias.cs.tum.edu/kb/srdl2-comp.owl#ArmComponent' ; 
-  ... 
- 
-==== Missing components or capabilities ==== 
- 
-  ?- missing_cap_for_action(tablesetting:'TableSetting', tumrosie:'TUM_Rosie1', Cap). 
-  Cap = 'http://ias.cs.tum.edu/kb/srdl2-cap.owl#PuttingDownAnObjectCapability' ; 
-  Cap = 'http://ias.cs.tum.edu/kb/srdl2-cap.owl#PickingUpAnObjectCapability' ; 
- 
-  ?- missing_comp_for_action(tablesetting:'TableSetting', tumrosie:'TUM_Rosie1', Comp). 
-  false.