Welcome to Chapter 3: Querying the Knowledge Base System
Today you'll teach your robot to think about what it should do. You'll query a knowledge base to answer questions like "How do I get the milk?" and "What actions do I need to take?"
Goal: By the end of this session, you will write queries to your knowledge base that enable the robot to plan actions—for example, determining that it must open the fridge to get the milk.
- Completed Chapters 1–2
- Basic understanding of "if-then" logic (helpful but not required)
- Import KnowRob client
- Load your knowledge base from Chapter 1
- Connect to the KnowRob server
- Query what objects are in the kitchen
- Find where the milk is located
- List available containers
- Ask what steps are needed to perceive the milk
- Check prerequisites for grasping objects
- Find what actions a robot can perform
- Define new facts about your environment
- Create rules for robot behavior
- Test how new knowledge changes query results
Knowledge Base: A smart database that stores facts about your environment and rules for robot behavior.
Queries: Questions you ask the knowledge base, like "Where is the milk?" or "What must I do before grasping?"
Facts & Rules: Facts are statements like "Milk is in the fridge." Rules are logic like "To grasp something, you must perceive it first."
- Query-driven robot movement - Use queries to find good locations to move to
- Conditional actions - Check if the fridge is open before trying to perceive milk
- Create complete plans - Combine multiple queries to build full action sequences
- How robots use knowledge to make decisions
- How to ask the right questions to plan actions
- How to add new facts and rules to improve robot behavior
Create a complete plan for getting milk from the fridge. What queries do you need? What new facts might help?
By the end of this session, you'll have a robot that can reason about what actions to take, making it much smarter than following pre-programmed steps. object information and information about observed actions that has been acquired from various sources (manually axiomatized, derived from observations, or imported from the web). For more information check out the KnowRob Documentation.
- Query the Knowledge Base: Write simple queries to understand the environment
- Action Planning: Ask questions that require reasoning through facts and rules
- Define New Knowledge: Add your own facts and rules, then test queries
Throughout the exercises, code examples will demonstrate how to perform queries using Python.
For Hands-On Exercises please use the following Virtual Lab: Knowledge Base Queries
By the end of this session, you'll have a robot that can reason about what actions to take, making it much smarter than following pre-programmed steps.

