Department of Informatics Intelligent Autonomous Systems Technische Universität München Contents 1. Control 2. Perception 3. Planning 4. Knowledge Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 51 Department of Informatics Intelligent Autonomous Systems Technische Universität München Outline Control Perception Planning Knowledge Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 52 Department of Informatics Intelligent Autonomous Systems Technische Universität München Exam Prep. Session: Control Frameworks Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 53 Department of Informatics Intelligent Autonomous Systems Technische Universität München Control Frameworks, Example 1 Assume, that we have already designed a controller for positioning our robot arm. But, after that, we bought a hand and equipped the robot with the new hand. How would you account for the disturbances from the added hand in your controller? 1. Which one would you use: feedback or feed-forward control? Give a short explanation for your answer! 2. Assume the task of positioning the arm and hand at a static position: Are these new disturbances mainly configuration-dependent? Choose yes or no, and explain why! Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 54 Department of Informatics Intelligent Autonomous Systems Technische Universität München Control Frameworks, Example 1 1. Which one would you use: feedback or feed-forward control? Give a short explanation for your answer! 2. Assume the task of positioning the arm and hand at a static position: Are these new disturbances mainly configuration-dependent? Choose yes or no, and explain why! Answers: 1. The hand should be incorporated as a feed-forward term, because it is a disturbance that can be modeled fairly accurately. Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 55 Department of Informatics Intelligent Autonomous Systems Technische Universität München Control Frameworks, Example 1 1. Which one would you use: feedback or feed-forward control? Give a short explanation for your answer! 2. Assume the task of positioning the arm and hand at a static position: Are these new disturbances mainly configuration-dependent? Choose yes or no, and explain why! Answers: 1. The hand should be incorporated as a feed-forward term, because it is a disturbance that can be modeled fairly accurately. 2. Yes, the added disturbances are mainly configuration-dependent: In a static setup the main source of disturbance will be the additional effect of gravity caused by the added weight of the hand. Since gravity compensation is usually modelled as just configuration-dependent, the hand weight should be compensated in the same fashion Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 56 Department of Informatics Intelligent Autonomous Systems Technische Universität München Control Frameworks, Example 2 Calculate the Jacobian for this given two-link planar robot! The forward kinematics of this robot is given as follows: x L1 cos q1 + L2 cos(q1 + q2 ) = y L1 sin q1 + L2 sin(q1 + q2 ) Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 57 Department of Informatics Intelligent Autonomous Systems Technische Universität München Control Frameworks, Example 2 Calculate the Jacobian for this given two-link planar robot! The forward kinematics of this robot is given as follows: x L1 cos q1 + L2 cos(q1 + q2 ) = y L1 sin q1 + L2 sin(q1 + q2 ) Solution: J(q) = Control Michael Beetz Summer Term 2012 ∂fx (q) ∂q1 ∂fy (q) ∂q1 ∂fx (q) ∂q2 ∂fy (q) ∂q2 ! = −L1 sin(q1 ) − L2 sin(q1 + q2 ) −L2 sin(q1 + q2 ) L1 cos(q1 ) + L2 cos(q1 + q2 ) L2 cos(q1 + q2 ) Perception Planning Knowledge Technical Cognitive Systems 58 Department of Informatics Intelligent Autonomous Systems Technische Universität München Outline Control Perception Planning Knowledge Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 59 Department of Informatics Intelligent Autonomous Systems Technische Universität München Exam Prep. Session: Perception Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 60 Department of Informatics Intelligent Autonomous Systems Technische Universität München Perception, Example 1 Describe the algorithmic steps of the ICP algorithm! Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 61 Department of Informatics Intelligent Autonomous Systems Technische Universität München Perception, Example 1 Describe the algorithmic steps of the ICP algorithm! 1. [optional] select subsets of points / keypoints. Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 62 Department of Informatics Intelligent Autonomous Systems Technische Universität München Perception, Example 1 Describe the algorithmic steps of the ICP algorithm! 1. [optional] select subsets of points / keypoints. 2. give the initial guess (transformation), and apply. Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 63 Department of Informatics Intelligent Autonomous Systems Technische Universität München Perception, Example 1 Describe the algorithmic steps of the ICP algorithm! 1. [optional] select subsets of points / keypoints. 2. give the initial guess (transformation), and apply. 3. for each point from 1st dataset, find best matching (e.g. closest) point from 2nd dataset Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 64 Department of Informatics Intelligent Autonomous Systems Technische Universität München Perception, Example 1 Describe the algorithmic steps of the ICP algorithm! 1. [optional] select subsets of points / keypoints. 2. give the initial guess (transformation), and apply. 3. for each point from 1st dataset, find best matching (e.g. closest) point from 2nd dataset 4. compute a new transformation that when applied to 1st dataset minimizes the error (e.g. least squares error (SVD) or non-linear optimizers (Levenberg-Marquardt). Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 65 Department of Informatics Intelligent Autonomous Systems Technische Universität München Perception, Example 1 Describe the algorithmic steps of the ICP algorithm! 1. [optional] select subsets of points / keypoints. 2. give the initial guess (transformation), and apply. 3. for each point from 1st dataset, find best matching (e.g. closest) point from 2nd dataset 4. compute a new transformation that when applied to 1st dataset minimizes the error (e.g. least squares error (SVD) or non-linear optimizers (Levenberg-Marquardt). 5. apply transformation and repeat (goto step 3) until convergence! (convergence criteria: for example a small transformation distance, etc..) Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 66 Department of Informatics Intelligent Autonomous Systems Technische Universität München Perception, Example 2 Name common uses for the Iterative Closest Point (ICP) algorithm? Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 67 Department of Informatics Intelligent Autonomous Systems Technische Universität München Perception, Example 2 Name common uses for the Iterative Closest Point (ICP) algorithm? 1. Dataset Registration Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 68 Department of Informatics Intelligent Autonomous Systems Technische Universität München Perception, Example 2 Name common uses for the Iterative Closest Point (ICP) algorithm? 1. Dataset Registration 2. Pointcloud registration Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 69 Department of Informatics Intelligent Autonomous Systems Technische Universität München Perception, Example 2 Name common uses for the Iterative Closest Point (ICP) algorithm? 1. Dataset Registration 2. Pointcloud registration 3. Panorama stitching Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 70 Department of Informatics Intelligent Autonomous Systems Technische Universität München Perception, Example 2 Name common uses for the Iterative Closest Point (ICP) algorithm? 1. Dataset Registration 2. Pointcloud registration 3. Panorama stitching 4. Scan matching in SLAM. Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 71 Department of Informatics Intelligent Autonomous Systems Technische Universität München Outline Control Perception Planning Knowledge Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 72 Department of Informatics Intelligent Autonomous Systems Technische Universität München Exam Prep. Session: Planning/Searcing Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 73 Department of Informatics Intelligent Autonomous Systems Technische Universität München Planning, Example Robby can move across the rooms only the according to the above graph. She can pick the mail only from the mailbox, and drop it only at johns office. Given the world state definitions, restrictions, and the initial state below: Draw a task tree, and solve it by depth first search. Show nodes expanded. Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 74 Department of Informatics Intelligent Autonomous Systems Technische Universität München Planning, Example State of the world: 1. Robot-Location (RG—E—JO—JM) 2. John-has-received-mail (True—False) 3. Mailbox-has-mail (True—False) 4. Robot-has-mail (True—False) Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 75 Department of Informatics Intelligent Autonomous Systems Technische Universität München Planning, Example Actions and restrictions: ACTIONS Move-to-E Move-to-JO Move-to-JM Move-to-RG Put-down-mail Pick-up-mail Control Michael Beetz Summer Term 2012 PRECONDITIONS None Robot-Loc=E Robot-Loc=E Robot-Loc=E AND Robot-has-mail=False Robot-Loc=JO AND Robot-has-mail=TRUE Robot-Loc=JM AND Robot-has-mail=FALSE Perception Planning Knowledge Technical Cognitive Systems 76 Department of Informatics Intelligent Autonomous Systems Technische Universität München Planning, Example Initial State: 1. Robot-Location (RG) 2. John-has-received-mail (False) 3. Mailbox-has-mail (True) 4. Robot-has-mail (False) Goal State: 1. Robot-Location (JO) 2. John-has-received-mail (True) 3. Mailbox-has-mail (False) 4. Robot-has-mail (False) Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 77 Department of Informatics Intelligent Autonomous Systems Technische Universität München Planning, Example Nodes: Name A B C . . GS Location E JO RG . . JO Control Michael Beetz Summer Term 2012 John-has-mail False False False . . True Perception Robot-has-mail False False False . . False Planning Mailbox-has-mail True True True . . False Knowledge Technical Cognitive Systems 78 Department of Informatics Intelligent Autonomous Systems Technische Universität München Planning, Example Graph Solution: Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 79 Department of Informatics Intelligent Autonomous Systems Technische Universität München Final Solution DFS Expands: IS A B|D D F H I GS Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 80 Department of Informatics Intelligent Autonomous Systems Technische Universität München Planning: Resources Online Resources: 1. AI appplets 2. airspace.org 3. artint.info Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 81 Department of Informatics Intelligent Autonomous Systems Technische Universität München Outline Control Perception Planning Knowledge Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 82 Department of Informatics Intelligent Autonomous Systems Technische Universität München A Knowledge Base for Spatial Reasoning You are supposed to implement a logical knowledge base (KB) for a cognitive robot. The robot has a perception system that is able to recognize objects in the world by reference to their position in (x, y , z) ∈ R3 and their dimensions (∆x, ∆y , ∆z) ∈ R3 in cartesian coordinates, where the position coordinates define the centroid of the bounding box of the respective object. Your KB has a Tell-Ask interface, by means of which the perception system is able to assert new facts about objects it has recognized in the environment, using the predicates position(ObjectID, X, Y, Z) dimensions(ObjectID, X, Y, Z) Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 83 Department of Informatics Intelligent Autonomous Systems Technische Universität München We want to implement a Prolog KB that is able to perform spatial reasoning on the facts from the perception system. In particular, the robot should be able to infer • if an object o1 is contained in some other object o2 (e.g. milk in the refrigerator) • or if o1 is located on o2 (e.g. a cup on the table). Implement the respective Prolog predicates in(Object, Containter) and on(Object, SuppObject), using only the predicates position and dimensions (you are allowed to use arithmetic operators, though). Assume that an object is in/on sth. if its bounding box is completely inside/on the other object. Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 84 Department of Informatics Intelligent Autonomous Systems Technische Universität München We define a helper predicate for checking if some interval I1 given by its centroid and dimension is contained in some other interval I2 : contains(CI1,DI1,CI2,DI2) :- Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 85 Department of Informatics Intelligent Autonomous Systems Technische Universität München We define a helper predicate for checking if some interval I1 given by its centroid and dimension is contained in some other interval I2 : contains(CI1,DI1,CI2,DI2) :CI1 + DI1 / 2 =< CI2 + DI2 / 2, Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 86 Department of Informatics Intelligent Autonomous Systems Technische Universität München We define a helper predicate for checking if some interval I1 given by its centroid and dimension is contained in some other interval I2 : contains(CI1,DI1,CI2,DI2) :CI1 + DI1 / 2 =< CI2 + DI2 / 2, CI1 - DI1 / 2 >= CI2 - DI2 / 2. Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 87 Department of Informatics Intelligent Autonomous Systems Technische Universität München contains(CI1,DI1,CI2,DI2) :CI1 + DI1 / 2 =< CI2 + DI2 / 2, CI1 - DI1 / 2 >= CI2 - DI2 / 2. in(O, C):- Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 88 Department of Informatics Intelligent Autonomous Systems Technische Universität München contains(CI1,DI1,CI2,DI2) :CI1 + DI1 / 2 =< CI2 + DI2 / 2, CI1 - DI1 / 2 >= CI2 - DI2 / 2. in(O, C):position(O, XO, YO, ZO), position(C, XC, YC, ZC), Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 89 Department of Informatics Intelligent Autonomous Systems Technische Universität München contains(CI1,DI1,CI2,DI2) :CI1 + DI1 / 2 =< CI2 + DI2 / 2, CI1 - DI1 / 2 >= CI2 - DI2 / 2. in(O, C):position(O, XO, YO, ZO), position(C, XC, YC, ZC), dimensions(O, XDIMO, YDIMO, ZDIMO), Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 90 Department of Informatics Intelligent Autonomous Systems Technische Universität München contains(CI1,DI1,CI2,DI2) :CI1 + DI1 / 2 =< CI2 + DI2 / 2, CI1 - DI1 / 2 >= CI2 - DI2 / 2. in(O, C):position(O, XO, YO, ZO), position(C, XC, YC, ZC), dimensions(O, XDIMO, YDIMO, ZDIMO), dimensions(C,XDIMC, YDIMC, ZDIMC), Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 91 Department of Informatics Intelligent Autonomous Systems Technische Universität München contains(CI1,DI1,CI2,DI2) :CI1 + DI1 / 2 =< CI2 + DI2 / 2, CI1 - DI1 / 2 >= CI2 - DI2 / 2. in(O, C):position(O, XO, YO, ZO), position(C, XC, YC, ZC), dimensions(O, XDIMO, YDIMO, ZDIMO), dimensions(C,XDIMC, YDIMC, ZDIMC), contains(XO, XDIMO, XC, XDIMC), Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 92 Department of Informatics Intelligent Autonomous Systems Technische Universität München contains(CI1,DI1,CI2,DI2) :CI1 + DI1 / 2 =< CI2 + DI2 / 2, CI1 - DI1 / 2 >= CI2 - DI2 / 2. in(O, C):position(O, XO, YO, ZO), position(C, XC, YC, ZC), dimensions(O, XDIMO, YDIMO, ZDIMO), dimensions(C,XDIMC, YDIMC, ZDIMC), contains(XO, XDIMO, XC, XDIMC), contains(YO, YDIMO, YC, YDIMC), Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 93 Department of Informatics Intelligent Autonomous Systems Technische Universität München contains(CI1,DI1,CI2,DI2) :CI1 + DI1 / 2 =< CI2 + DI2 / 2, CI1 - DI1 / 2 >= CI2 - DI2 / 2. in(O, C):position(O, XO, YO, ZO), position(C, XC, YC, ZC), dimensions(O, XDIMO, YDIMO, ZDIMO), dimensions(C,XDIMC, YDIMC, ZDIMC), contains(XO, XDIMO, XC, XDIMC), contains(YO, YDIMO, YC, YDIMC), contains(ZO, ZDIMO, ZC, ZDIMC), Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 94 Department of Informatics Intelligent Autonomous Systems Technische Universität München contains(CI1,DI1,CI2,DI2) :CI1 + DI1 / 2 =< CI2 + DI2 / 2, CI1 - DI1 / 2 >= CI2 - DI2 / 2. in(O, C):position(O, XO, YO, ZO), position(C, XC, YC, ZC), dimensions(O, XDIMO, YDIMO, ZDIMO), dimensions(C,XDIMC, YDIMC, ZDIMC), contains(XO, XDIMO, XC, XDIMC), contains(YO, YDIMO, YC, YDIMC), contains(ZO, ZDIMO, ZC, ZDIMC), C \= O. Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 95 Department of Informatics Intelligent Autonomous Systems Technische Universität München contains(CI1,DI1,CI2,DI2) :CI1 + DI1 / 2 =< CI2 + DI2 / 2, CI1 - DI1 / 2 >= CI2 - DI2 / 2. on(O, S):- Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 96 Department of Informatics Intelligent Autonomous Systems Technische Universität München contains(CI1,DI1,CI2,DI2) :CI1 + DI1 / 2 =< CI2 + DI2 / 2, CI1 - DI1 / 2 >= CI2 - DI2 / 2. on(O, S):position(O, XO, YO, ZO), position(S, XS, YS, ZS), Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 97 Department of Informatics Intelligent Autonomous Systems Technische Universität München contains(CI1,DI1,CI2,DI2) :CI1 + DI1 / 2 =< CI2 + DI2 / 2, CI1 - DI1 / 2 >= CI2 - DI2 / 2. on(O, S):position(O, XO, YO, ZO), position(S, XS, YS, ZS), dimensions(O, XDIMO, YDIMO, ZDIMO), Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 98 Department of Informatics Intelligent Autonomous Systems Technische Universität München contains(CI1,DI1,CI2,DI2) :CI1 + DI1 / 2 =< CI2 + DI2 / 2, CI1 - DI1 / 2 >= CI2 - DI2 / 2. on(O, S):position(O, XO, YO, ZO), position(S, XS, YS, ZS), dimensions(O, XDIMO, YDIMO, ZDIMO), dimensions(S,XDIMS, YDIMS, ZDIMS), Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 99 Department of Informatics Intelligent Autonomous Systems Technische Universität München contains(CI1,DI1,CI2,DI2) :CI1 + DI1 / 2 =< CI2 + DI2 / 2, CI1 - DI1 / 2 >= CI2 - DI2 / 2. on(O, S):position(O, XO, YO, ZO), position(S, XS, YS, ZS), dimensions(O, XDIMO, YDIMO, ZDIMO), dimensions(S,XDIMS, YDIMS, ZDIMS), (contains(XO, XDIMO, XO, XDIMO), Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 100 Department of Informatics Intelligent Autonomous Systems Technische Universität München contains(CI1,DI1,CI2,DI2) :CI1 + DI1 / 2 =< CI2 + DI2 / 2, CI1 - DI1 / 2 >= CI2 - DI2 / 2. on(O, S):position(O, XO, YO, ZO), position(S, XS, YS, ZS), dimensions(O, XDIMO, YDIMO, ZDIMO), dimensions(S,XDIMS, YDIMS, ZDIMS), (contains(XO, XDIMO, XO, XDIMO), contains(YO, YDIMO, YS, YDIMS); Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 101 Department of Informatics Intelligent Autonomous Systems Technische Universität München contains(CI1,DI1,CI2,DI2) :CI1 + DI1 / 2 =< CI2 + DI2 / 2, CI1 - DI1 / 2 >= CI2 - DI2 / 2. on(O, S):position(O, XO, YO, ZO), position(S, XS, YS, ZS), dimensions(O, XDIMO, YDIMO, ZDIMO), dimensions(S,XDIMS, YDIMS, ZDIMS), (contains(XO, XDIMO, XO, XDIMO), contains(YO, YDIMO, YS, YDIMS); Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 102 Department of Informatics Intelligent Autonomous Systems Technische Universität München contains(CI1,DI1,CI2,DI2) :CI1 + DI1 / 2 =< CI2 + DI2 / 2, CI1 - DI1 / 2 >= CI2 - DI2 / 2. on(O, S):position(O, XO, YO, ZO), position(S, XS, YS, ZS), dimensions(O, XDIMO, YDIMO, ZDIMO), dimensions(S,XDIMS, YDIMS, ZDIMS), (contains(XO, XDIMO, XO, XDIMO), contains(YO, YDIMO, YS, YDIMS); contains(XS, XDIMS, XO, XDIMO), Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 103 Department of Informatics Intelligent Autonomous Systems Technische Universität München contains(CI1,DI1,CI2,DI2) :CI1 + DI1 / 2 =< CI2 + DI2 / 2, CI1 - DI1 / 2 >= CI2 - DI2 / 2. on(O, S):position(O, XO, YO, ZO), position(S, XS, YS, ZS), dimensions(O, XDIMO, YDIMO, ZDIMO), dimensions(S,XDIMS, YDIMS, ZDIMS), (contains(XO, XDIMO, XO, XDIMO), contains(YO, YDIMO, YS, YDIMS); contains(XS, XDIMS, XO, XDIMO), contains(YS, YDIMS, YO, YDIMO)), Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 104 Department of Informatics Intelligent Autonomous Systems Technische Universität München contains(CI1,DI1,CI2,DI2) :CI1 + DI1 / 2 =< CI2 + DI2 / 2, CI1 - DI1 / 2 >= CI2 - DI2 / 2. on(O, S):position(O, XO, YO, ZO), position(S, XS, YS, ZS), dimensions(O, XDIMO, YDIMO, ZDIMO), dimensions(S,XDIMS, YDIMS, ZDIMS), (contains(XO, XDIMO, XO, XDIMO), contains(YO, YDIMO, YS, YDIMS); contains(XS, XDIMS, XO, XDIMO), contains(YS, YDIMS, YO, YDIMO)), ZS + ZDIMS / 2 =:= ZO - ZDIMO / 2. Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 105 Department of Informatics Intelligent Autonomous Systems Technische Universität München A Knowledge Base for Spatial Reasoning (ctd) The relations in and on both are transitive, so our knowledge base should take this into account. So we add (1) in(X,Z) :- in(X,Y), in(Y,Z). to our knowledge base. Would this work? Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 106 Department of Informatics Intelligent Autonomous Systems Technische Universität München A Knowledge Base for Spatial Reasoning (ctd) The relations in and on both are transitive, so our knowledge base should take this into account. So we add (1) in(X,Z) :- in(X,Y), in(Y,Z). to our knowledge base. Would this work? No, since we end up in infinite recursion! (2) isIn(X,Z) :- in(X,Z). isIn(X,Z) :- in(X,Y), isIn(Y,Z). fixes it. Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 107 Department of Informatics Intelligent Autonomous Systems Technische Universität München Infinite Recursion We consider the seed-apple-box problem from the exercise. We have the following Prolog program: in(seed,apple). in(apple,box). in(X,Z) :- in(X,Y), in(Y,Z). We want to compute the transitive closure of seed. Tracing the query yields: ?- trace,in(seed,Z). Call: (7) in(seed, G259) ? creep Exit: (7) in(seed, apple) ? creep Z = apple ; Redo: (7) in(seed, G259) ? creep Call: (8) in(seed, G376) ? creep Exit: (8) in(seed, apple) ? creep Call: (8) in(apple, G259) ? creep Exit: (8) in(apple, box) ? creep Exit: (7) in(seed, box) ? creep Z = box ; Redo: (8) in(apple, G259) ? creep Call: (9) in(apple, G376) ? creep Exit: (9) in(apple, box) ? creep Call: (9) in(box, G259) ? creep Call: (10) in(box, G376) ? creep Call: (11) in(box, G376) ? creep Call: (12) in(box, G376) ? creep Call: (13) in(box, G376) ? creep Call: (14) in(box, G376) ? creep Call: (15) in(box, G376) ? creep Call: (16) in(box, G376) ? creep Call: (17) in(box, G376) ? creep Control Call: (18) in(box,Perception G376) ? Michael Beetz Summer Term 2012 Planning Knowledge Technical Cognitive Systems 108 Department of Informatics Intelligent Autonomous Systems Technische Universität München DFS-Tree Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 109 Department of Informatics Intelligent Autonomous Systems Technische Universität München Recursion As long as we find valid unifications, everything is fine. If we try to prove something that cannot be proven, we run into infinite recursion with formula (1), since the recursive formula is the only one, which potentially could prove it. Formula (2) fixes this problem, since the ground/abort condition occurs before the recursion takes place. But we need to be careful with the ordering here, as well. Why? in(seed,apple). in(apple,box). isIn(X,Z) :- in(X,Z). isIn(X,Z) :- in(X,Y), isIn(Y,Z). Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 110 Department of Informatics Intelligent Autonomous Systems Technische Universität München Trace yields: ?- trace,isIn(seed,Z). Call: (7) isIn(seed, G259) ? creep Call: (8) in(seed, G259) ? creep Exit: (8) in(seed, apple) ? creep Exit: (7) isIn(seed, apple) ? creep Z = apple ; Redo: (7) isIn(seed, G259) ? creep Call: (8) in(seed, G376) ? creep Exit: (8) in(seed, apple) ? creep Call: (8) isIn(apple, G259) ? creep Call: (9) in(apple, G259) ? creep Exit: (9) in(apple, box) ? creep Exit: (8) isIn(apple, box) ? creep Exit: (7) isIn(seed, box) ? creep Z = box ; Redo: (8) isIn(apple, G259) ? creep Call: (9) in(apple, G376) ? creep Exit: (9) in(apple, box) ? creep Call: (9) isIn(box, G259) ? creep Call: (10) in(box, G259) ? creep Fail: (10) in(box, G259) ? creep Redo: (9) isIn(box, G259) ? creep Call: (10) in(box, G376) ? creep Fail: (10) in(box, G376) ? creep Fail: (9) isIn(box, G259) ? creep Fail: (8) isIn(apple, G259) ? creep Fail: (7) isIn(seed, G259) ? creep false. Control Michael Beetz Summer Term 2012 Perception Planning Knowledge Technical Cognitive Systems 111
© Copyright 2026 Paperzz