ROS Plan Queries Cheatsheet - programmatoroSeduto/ros-plan GitHub Wiki
ROS Plan KB queries -- cheatsheet
- see tutorial 06 KB
- see tutorial 07 KB
- see tutorial 08 KB
- see tutorial 09 KB
Index of Interface Names of the KB
topics:
/rosplan_knowledge_base/pddl_action_parameters
/rosplan_knowledge_base/status/update
services:
## === USEFUL SERVICES === ##
# clear the actual problem instance
/rosplan_knowledge_base/clear
# make more complex queries to the knowledge base
/rosplan_knowledge_base/query_state
# update with a single call
/rosplan_knowledge_base/update
## === DOMAIN SERVICES === ##
/rosplan_knowledge_base/domain/name
/rosplan_knowledge_base/domain/functions
/rosplan_knowledge_base/domain/operator_details
/rosplan_knowledge_base/domain/operators
/rosplan_knowledge_base/domain/predicate_details
/rosplan_knowledge_base/domain/predicates
/rosplan_knowledge_base/domain/types
## === PROBLEM SERVICES === ##
/rosplan_knowledge_base/state/functions
/rosplan_knowledge_base/state/goals
/rosplan_knowledge_base/state/instances
/rosplan_knowledge_base/state/metric
/rosplan_knowledge_base/state/propositions
/rosplan_knowledge_base/state/timed_knowledge
## === KB UPDATE SERVICES === ##
/rosplan_knowledge_base/update
/rosplan_knowledge_base/update_array
/rosplan_knowledge_base/update_constraints_oneof
/rosplan_knowledge_base/update_sensed_predicates
SRV GET -- /rosplan_knowledge_base/domain/name
Name of the domain.
srv type : rosplan_knowledge_msgs/GetDomainNameService
SRV GET -- /rosplan_knowledge_base/domain/types
Types inside the domain.
srv type : rosplan_knowledge_msgs/GetDomainTypeService
response of this kind: the domain contains two types boolobj
and key
, see only the field types
which is an array of all the types. better to not use nested types because they are poorly supported by the framework.
here's an example:
types:
- boolobj
- key
super_types:
- ''
- ''
SRV GET -- /rosplan_knowledge_base/domain/predicates
domain file predicates.
srv type : rosplan_knowledge_msgs/GetDomainAttributeService
here are some informations you can find from this service response:
res.items[i].name
(str): the name of the predicate, one for each cell of the arrayres.items[i].typed_parameters[j].key
is the name of the parameter of the predicateres.items[i].typed_parameters[j].value
is the type of the parameter of the predicate
an example of response: two predicates, the first one has two parameters, the second one has only one parameter.
items:
-
name: robot_at
typed_parameters:
-
key: v
value: robot
-
key: wp
value: waypoint
-
name: visited
typed_parameters:
-
key: wp
value: waypoint
SRV GET -- /rosplan_knowledge_base/domain/predicate_details
it could be helpful when you need infos about the structure of one predicate.
srv type : rosplan_knowledge_msgs/GetDomainPredicateDetailsService
SRV GET -- instances of a type
complete name : /rosplan_knowledge_base/state/instances
srv type : rosplan_knowledge_msgs/GetInstanceService
string type_name
---
string[] instances
it returns only the names of the objects belonging to these instances. There are some limitations to take into account during the design:
- a object can have only one type
- the type of the object can't change in runtime
this service could be applied only for retrieving the objects.
SRV GET -- values of predicated
this service enables to retrieve the values of the predicates.
complete name : /rosplan_knowledge_base/state/propositions
srv type : rosplan_knowledge_msgs/GetAttributeService
here's an example of the response:
attributes:
-
knowledge_type: 1
initial_time:
secs: 1528284422
nsecs: 168676390
is_negative: False
instance_type: ''
instance_name: ''
attribute_name: robot_at
values:
-
key: v
value: kenny
-
key: wp
value: wp0
function_value: 0.0
optimization: ''
expr:
tokens: []
ineq:
comparison_type: 0
LHS:
tokens: []
RHS:
tokens: []
grounded: False
in particular,
res.attributes[]..values[].key
is the name of the parameterres.attributes[]..values[].value
is the object instance, value of the argument
very important to note that this service returns only the predicates with a true value, which means that the false predicates aren't returned.
predicates by shell: if predicate_name: ''
, it returns the entire set of true predicates.
rosservice call /rosplan_knowledge_base/state/propositions "predicate_name: ''"
SRV GET -- values of fluents
complete name : /rosplan_knowledge_base/domain/functions
srv type : rosplan_knowledge_msgs/GetAttributeService
# PDDL problem generation; service(2/3):
# Get all facts (or functions) by predicate name (or function name).
# The results are passed as an array of KnowledgeItems
# The array of initial_time is used for TILs and TIFs not yet active
string predicate_name
---
rosplan_knowledge_msgs/KnowledgeItem[] attributes
In particular,
res.attributes[].knowledge_name
is always 2res.attributes[].attribute_name
is the name of the fluentres.attributes[].function_value
is the value of the fluent
the system returns both zero and non-zero fluents.
SRV GET -- goal
goal predicates:
# get every true knowledge item
rosservice call /rosplan_knowledge_base/state/goals "predicate_name: ''"
SRV SET -- clear
it deletes the problem instance.
complete name : /rosplan_knowledge_base/clear
srv type : empty
SRV SET -- load a new model from file
you should use here the problem_interface
complete name : /rosplan_problem_interface/problem_generation_server_params
srv type : rosplan_dispatch_msgs/ProblemService
# request a problem to be generated in the problem_path
string problem_path
bool problem_string_response
---
bool problem_generated
string problem_string
SRV SET -- update the knowledge base
complete name : /rosplan_knowledge_base/update
srv type : rosplan_knowledge_msgs/KnowledgeUpdateService
🔗 see the code for understanding the effects of the commands here.
🔗 here is the function which removes a knowledge item.
uint8 ADD_KNOWLEDGE=0 # make truue a predicate, add a functional
uint8 REMOVE_KNOWLEDGE=2 # make false one predicate
uint8 ADD_GOAL=1
uint8 REMOVE_GOAL=3
uint8 ADD_METRIC=4
uint8 REMOVE_METRIC=5
uint8 update_type
rosplan_knowledge_msgs/KnowledgeItem knowledge
---
bool success
see the infos about the interface KnowledgeItem for further infos about the type of knowledge you're adding to the system.
knowledge types :
uint8 INSTANCE=0
uint8 FACT=1
uint8 FUNCTION=2
uint8 EXPRESSION=3
uint8 INEQUALITY=4
SRV GET -- queries
recommended to use the queries when interrogating the knowledge base to not overcomplicate the procedures.
complete name : /rosplan_knowledge_base/query_state
srv type : rosplan_knowledge_msgs/KnowledgeQueryService
rosplan_knowledge_msgs/KnowledgeItem[] knowledge
---
bool all_true
bool[] results
rosplan_knowledge_msgs/KnowledgeItem[] false_knowledge
reading predicates : if you're sure that the predicate you're asking for is unique, use the field response.all_true
; or also .response.results[]
showing each truth value.
reading fluents : not working, unfortunately. See this simple test:
root@dbfbde77a543:~/ros_ws# rosservice call /rosplan_knowledge_base/query_state "knowledge:
- knowledge_type: 2
initial_time: {secs: 0, nsecs: 0}
is_negative: false
instance_type: ''
instance_name: ''
attribute_name: 'f-non-zero'
values:
- {key: '', value: ''}
function_value: 0.0
optimization: ''
expr:
tokens:
- expr_type: 0
constant: 0.0
function:
name: ''
typed_parameters:
- {key: '', value: ''}
op: 0
special_type: 0
ineq:
comparison_type: 0
LHS:
tokens:
- expr_type: 0
constant: 0.0
function:
name: ''
typed_parameters:
- {key: '', value: ''}
op: 0
special_type: 0
RHS:
tokens:
- expr_type: 0
constant: 0.0
function:
name: ''
typed_parameters:
- {key: '', value: ''}
op: 0
special_type: 0
grounded: false"
all_true: False
results: [False]
false_knowledge:
-
knowledge_type: 2
initial_time:
secs: 0
nsecs: 0
is_negative: False
instance_type: ''
instance_name: ''
attribute_name: "f-non-zero"
values:
-
key: ''
value: ''
function_value: 0.0
optimization: ''
expr:
tokens:
-
expr_type: 0
constant: 0.0
function:
name: ''
typed_parameters:
-
key: ''
value: ''
op: 0
special_type: 0
ineq:
comparison_type: 0
LHS:
tokens:
-
expr_type: 0
constant: 0.0
function:
name: ''
typed_parameters:
-
key: ''
value: ''
op: 0
special_type: 0
RHS:
tokens:
-
expr_type: 0
constant: 0.0
function:
name: ''
typed_parameters:
-
key: ''
value: ''
op: 0
special_type: 0
grounded: False
root@dbfbde77a543:~/ros_ws# rosservice call /rosplan_knowledge_base/state/functions "predicate_name: 'f-non-zero'"
attributes:
-
knowledge_type: 2
initial_time:
secs: 1657285126
nsecs: 52188800
is_negative: False
instance_type: ''
instance_name: ''
attribute_name: "f-non-zero"
values: []
function_value: 6.0
optimization: ''
expr:
tokens: []
ineq:
comparison_type: 0
LHS:
tokens: []
RHS:
tokens: []
grounded: False
root@dbfbde77a543:~/ros_ws#
Interfaces
- KB Services located at /root/ros_ws/src/ROSPlan/rosplan_knowledge_msgs/srv
- KB messages located at /root/ros_ws/src/ROSPlan/rosplan_knowledge_msgs/msg
SRV -- rosplan_knowledge_msgs/GetDomainNameService
empty request
# Fetching the Domain (0/3):
# Get the domain name.
---
string domain_name
SRV -- rosplan_knowledge_msgs/GetDomainTypeService
empty request
# Fetching the Domain (1/3):
# Get all types in the domain.
---
string[] types
string[] super_types
SRV -- rosplan_knowledge_msgs/GetDomainAttributeService
empty request
---
rosplan_knowledge_msgs/DomainFormula[] items
string name
diagnostic_msgs/KeyValue[] typed_parameters
string key
string value
MSG -- DomainFormula
# A message used to represent an atomic formula from the domain.
# typed_parameters matches label -> type
string name
diagnostic_msgs/KeyValue[] typed_parameters
SRV -- rosplan_knowledge_msgs/GetDomainPredicateDetailsService
string name
---
rosplan_knowledge_msgs/DomainFormula predicate
string name
diagnostic_msgs/KeyValue[] typed_parameters
string key
string value
bool is_sensed
MSG -- KnowledgeItem
see also diagnostic_msgs/KeyValue
# A knowledge item used to represent a piece of the state in ROSPlan
uint8 INSTANCE = 0
uint8 FACT = 1
uint8 FUNCTION = 2
uint8 EXPRESSION = 3
uint8 INEQUALITY = 4
uint8 knowledge_type
# time at which this knowledge becomes true
time initial_time
# knowledge is explicitly false
bool is_negative
#---------
# INSTANCE
#---------
# instance knowledge_type
string instance_type
string instance_name
#----------------------
# PREDICATE OR FUNCTION
#----------------------
# attribute knowledge_type
string attribute_name
diagnostic_msgs/KeyValue[] values
#---------
# FUNCTION
#---------
# function value
float64 function_value
#-----------
# EXPRESSION
#-----------
string optimization
rosplan_knowledge_msgs/ExprComposite expr
#-----------
# INEQUALITY
#-----------
rosplan_knowledge_msgs/DomainInequality ineq
structure of the message, as it appears on the rossrv show
:
uint8 INSTANCE=0
uint8 FACT=1
uint8 FUNCTION=2
uint8 EXPRESSION=3
uint8 INEQUALITY=4
uint8 knowledge_type
time initial_time
bool is_negative
string instance_type
string instance_name
string attribute_name
diagnostic_msgs/KeyValue[] values
string key
string value
float64 function_value
string optimization
rosplan_knowledge_msgs/ExprComposite expr
rosplan_knowledge_msgs/ExprBase[] tokens
uint8 CONSTANT=0
uint8 FUNCTION=1
uint8 OPERATOR=2
uint8 SPECIAL=3
uint8 ADD=0
uint8 SUB=1
uint8 MUL=2
uint8 DIV=3
uint8 UMINUS=4
uint8 HASHT=0
uint8 TOTAL_TIME=1
uint8 DURATION=2
uint8 expr_type
float64 constant
rosplan_knowledge_msgs/DomainFormula function
string name
diagnostic_msgs/KeyValue[] typed_parameters
string key
string value
uint8 op
uint8 special_type
rosplan_knowledge_msgs/DomainInequality ineq
uint8 GREATER=0
uint8 GREATEREQ=1
uint8 LESS=2
uint8 LESSEQ=3
uint8 EQUALS=4
uint8 comparison_type
rosplan_knowledge_msgs/ExprComposite LHS
rosplan_knowledge_msgs/ExprBase[] tokens
uint8 CONSTANT=0
uint8 FUNCTION=1
uint8 OPERATOR=2
uint8 SPECIAL=3
uint8 ADD=0
uint8 SUB=1
uint8 MUL=2
uint8 DIV=3
uint8 UMINUS=4
uint8 HASHT=0
uint8 TOTAL_TIME=1
uint8 DURATION=2
uint8 expr_type
float64 constant
rosplan_knowledge_msgs/DomainFormula function
string name
diagnostic_msgs/KeyValue[] typed_parameters
string key
string value
uint8 op
uint8 special_type
rosplan_knowledge_msgs/ExprComposite RHS
rosplan_knowledge_msgs/ExprBase[] tokens
uint8 CONSTANT=0
uint8 FUNCTION=1
uint8 OPERATOR=2
uint8 SPECIAL=3
uint8 ADD=0
uint8 SUB=1
uint8 MUL=2
uint8 DIV=3
uint8 UMINUS=4
uint8 HASHT=0
uint8 TOTAL_TIME=1
uint8 DURATION=2
uint8 expr_type
float64 constant
rosplan_knowledge_msgs/DomainFormula function
string name
diagnostic_msgs/KeyValue[] typed_parameters
string key
string value
uint8 op
uint8 special_type
bool grounded
rosplan_knowledge_msgs/GetAttributeService
# PDDL problem generation; service(2/3):
# Get all facts (or functions) by predicate name (or function name).
# The results are passed as an array of KnowledgeItems
# The array of initial_time is used for TILs and TIFs not yet active
string predicate_name
---
rosplan_knowledge_msgs/KnowledgeItem[] attributes