Upload
others
View
5
Download
0
Embed Size (px)
Citation preview
Knowledge Representation & Reasoning:
Practical Session
December 10th 2013
Guglielmo Gemignani
Daniele Nardi
@dis.uniroma1.it
Department of Computer, Control and Management Engineering Sapienza, University of Rome
Winter School on Artificial Intelligence and Robotics
Örebro, Sweden
http://dis.uniroma1.it
The Practical
Knowledge Representation & Reasoning: Practical Session
You will be given a “partially working” robot that you have to improve
Able to accomplish such task only if one or none instances of the target type are known The robot does not know what to do if multiple instances of the object are known
Your job: make the robot able to recognize an object by asking the user
1/10
To go in front of different objects previously seen and memorized.
The Goal
Dialogs
Knowledge Representation & Reasoning: Practical Session 2/10
Go to the bed
Three possible cases: No instances of object type known One instance known Multiple instances known
} HandledTo be implemented
Which one?
User able to specify objects by: color property (e.g. the black table) object proximity (e.g. the table near the heater) robot proximity (e.g. the nearest table)
Multiple instances case:
Dialogs Model
Knowledge Representation & Reasoning: Practical Session 3/10
Dialogs modelled through a finite state machine:
Initial State
Multiple
Instances
if multiple instances
if one or none instances
Transitions triggered when command received
Dialogs Model
Knowledge Representation & Reasoning: Practical Session 3/10
Dialogs modelled through a finite state machine:
Initial State
Multiple
Instances
if multiple instances
if multiple instances
if one or none instances
if one or none instances
Transitions triggered when command received
The Code
ROS packages
executable scripts
Packages:
lucia_simulation: Real and simulated robot configurations
PrologInterface: Interface to Prolog
SapienzBotReasoning & semantic_map_extraction: from metric map to Prolog
!
!
simple_FSM: Finite state machine module
Knowledge Representation & Reasoning: Practical Session 4/10
simple_FSM
Knowledge Representation & Reasoning: Practical Session
Module that you will improve. Use the others as black boxes.
Implements a simple finite state machine that models the dialog needed to understand the task
File to be modified
Inside simple_FSM/scripts:
support functions5/10
myStates.py
Knowledge Representation & Reasoning: Practical Session
#… # Including code !class In it ia lState(State) : stateName = "In it ia lState" def performAct ion(self) : #do something def getNextState(self , messageStr ing): #transit ion based on messageStr ing c lass Mult ip leTargets(State) : stateName = "Mult ip leTargets" def performAct ion(self) : #do something def getNextState(self , messageStr ing): #transit ion based on messageStr ing
}}
Given
To be implemented
6/10
The InitialState Class
Knowledge Representation & Reasoning: Practical Session
c lass In it ia lState(State) : stateName = "In it ia lState" def performAct ion(self) : pr int se lf .stateName def getNextState(self , messageStr ing): g lobal targetType targetType = str(messageStr ing).spl i t(" ")[1] .spl i t(“\"")[0] #type of obj ! atomList = getAtomsFromCommand(messageStr ing) #gets atoms of obj type i f len(atomList) == 0: say("I do not know any target of that type”) return In it ia lState() e l i f len(atomList) == 1 : say("I am going to the target") result = prolog_handle ( 'object ' , [atomList[0] ,”X”,"Y","Z"]) #takes str ings x = int(result . r is[0] .atoms[1]) y = int(result . r is[0] .atoms[2]) goInFrontOfTarget(x,y) return In it ia lState() ! e lse: return Mult ip leTargets()
7/10
The InitialState Class
Knowledge Representation & Reasoning: Practical Session
class MultipleTargets(State):
stateName = "MultipleTargets"
def performAction(self):
say("I know multiple targets of that type. Which one do you mean?")
! def getNextState(self, messageString):
print messageString
pose = getRobotPose() #X = pose[0], Y = pose[1]
# IMPLEMENT HERE
What do you need to implement?
8/10
Practical
Knowledge Representation & Reasoning: Practical Session 9/10
Each group will implement at least one of three possible “disambiguation procedure”:
Disambiguation through color property (e.g. the black table)
Disambiguation through robot proximity (e.g. the nearest table)
Disambiguation through object proximity (e.g. the table near the heater)
Prolog predicates given (inside SapienzBotReasoning/pl/myPredicates.pl):
colorObj(Target,TargetColor,TargetAtom). colorObj(table,black,X).
nearest( X,Y,0, TargetType, TargetAtom). nearest(34,56,0,table,X).
To be implemented:
near(Target,TargetNear,TargetAtom,TargetNearAtom). near(table,heater,X,Y).
Test Your Code
Knowledge Representation & Reasoning: Practical Session 10/10
To test your code run ./run-‐lucia-‐simulation.sh
After having tested it you can run it on a Turtlebot using the script ./run-‐lucia-‐robot.sh
PrologInterface & lucia_simulation
Knowledge Representation & Reasoning: Practical Session
PrologInterface:
Interface in ROS for Prolog
Four types of services given:
prolog_query prolog_assert prolog_retract prolog_retractall
lucia_simulation:
Contains the launch files and the maps needed by the simulated and real robot (turtlebot) to perform low level tasks (move_base, amcl, stage, etc.)
3/10
Only one needed
SapienzBotReasoning & semantic_map_extraction
Knowledge Representation & Reasoning: Practical Session
semantic_map_extraction:
Conversion between the metric map and the cell map
Outputs a matricial representation of the cell map passed to the SapienzBotReasoning module
SapienzBotReasoning:
Translates the matricial representation to prolog Predicates
4/10