Error when domain and the problem to use durative-actions - pddl

I'm taking the yb_drill_TBM2 example and converting it for use with a time planner (POPF).
I am not able to identify the error can you help me?
DOMAIN:
; Specification in PDDL1 of the rockin TBM2 drill test domain
; author : Oscar Lima, olima_84#yahoo.com
(define (domain idmind_agent)
(:requirements :strips :typing :fluents :negative-preconditions :disjunctive-preconditions :durative-actions )
(:types
location ; locations in the arena, points of interest
robot ; your amazing yet powerful robot
object ; objects to be manipulated by the robot
gripper ; robot gripper
robot_platform ; platform slots for the robot to store objects
)
(:predicates
; robot ?r is at location ?l
(at ?r - robot ?l - location)
; object ?o is on location ?l
(on ?o - object ?l - location)
; object ?o is stored on robot platform ?rp
(stored ?o - object ?rp - robot_platform)
; robot platform ?rp is occupied, yb has 3 free places to store objects
(occupied ?rp - robot_platform)
; gripper ?g is holding object ?o
(holding ?g - gripper ?o - object)
; gripper ?g is free (does not contain object)
(gripper_is_free ?g - gripper)
)
; moves a robot ?r from ?source - location to a ?destination - location
; NOTE : the situation in which the robot arm is in any position before moving
; is not handled at the planning level, hence we advise to always move the arm
; to a folded position, then navigate
(:durative-action move_base
:parameters (?source ?destination - location ?r - robot ?g - gripper)
:duration (= ?duration 1)
:condition (and (at start (at ?r ?source))
(over all (gripper_is_free ?g))
)
:effect (and
(at start (not (at ?r ?source)))
(at end (at ?r ?destination))
)
)
; pick an object ?o which is inside a location ?l with a free gripper ?g
; with robot ?r that is at location ?l
(:durative-action pick
:parameters (?o - object ?l - location ?r - robot ?g - gripper)
:duration (= ?duration 1)
:condition (and (at start (on ?o ?l))
(over all (at ?r ?l))
(at start (gripper_is_free ?g))
)
:effect (and (at end (holding ?g ?o))
(at start (not (on ?o ?l)))
(at start (not (gripper_is_free ?g)))
)
)
; stage an object ?o in a robot platform ?rp which is not occupied with a gripper ?g
; which is holding the object ?o
(:durative-action stage
:parameters (?o - object ?rp - robot_platform ?g - gripper)
:duration (= ?duration 1)
:condition (and (at start (holding ?g ?o))
(at start (not (occupied ?rp)))
(at start (not (gripper_is_free ?g)))
)
:effect (and (at start (not (holding ?g ?o)))
(at start (gripper_is_free ?g))
(at start (stored ?o ?rp))
(at start (occupied ?rp))
)
)
; unstage an object ?o stored on a robot platform ?rp with a free gripper ?g
(:durative-action unstage
:parameters (?o - object ?rp - robot_platform ?g - gripper)
:duration (= ?duration 1)
:condition (and (at start (gripper_is_free ?g))
(at start (stored ?o ?rp))
(at start (not (holding ?g ?o)))
)
:effect (and (at start (not (gripper_is_free ?g)))
(at start (not (stored ?o ?rp)))
(at start (not (occupied ?rp)))
(at start(holding ?g ?o))
)
)
; places and object ?o with a gripper ?g which is holding the object ?o
; with a robot ?r at a location ?l on robot_platform ?rp
(:durative-action drop_on_platform
:parameters (?o - object ?l - location ?g - gripper ?r - robot ?rp - robot_platform)
:duration (= ?duration 1)
:condition (and (over all (at ?r ?l))
(at start (holding ?g ?o))
(at start (not (stored ?o ?rp)))
)
:effect (and (at end (gripper_is_free ?g)) ; the gripper is free
(at end (on ?o ?l)) ; object is now on location l
(at start (not (holding ?g ?o))) ; the gripper is no longer holding the object
)
)
)
Problem:
(define (problem problem_1)
(:domain idmind_agent)
(:objects
dock S1 S2 S3 S4 S5 - location
platform_middle platform_left platform_right - robot_platform
idmind - robot
o1 o2 - object
robotiq - gripper
)
(:init
(at idmind dock)
(on o1 S2)
(on o2 S2)
(not (occupied platform_middle))
(not (occupied platform_left))
(not (occupied platform_right))
(gripper_is_free robotiq)
)
(:goal
(and
(on o1 S1)
(on o2 S4)
)
)
)
But I'm getting this error that I'm not being able to understand. I wonder if you can help me with what I'm missing.
rosrun rosplan_planning_system popf new.domain.pddl new_problem.pddl
Critical Errors Encountered in Domain/Problem File
--------------------------------------------------
Due to critical errors in the supplied domain/problem file, the planner
has to terminate. The errors encountered are as follows:
Errors: 1, warnings: 9
new_problem.pddl: line: 11: Warning: Undeclared requirement :typing
new_problem.pddl: line: 11: Warning: Undeclared requirement :typing
new_problem.pddl: line: 11: Warning: Undeclared requirement :typing
new_problem.pddl: line: 11: Warning: Undeclared requirement :typing
new_problem.pddl: line: 11: Warning: Undeclared requirement :typing
new_problem.pddl: line: 14: Warning: Undeclared symbol: at
new_problem.pddl: line: 15: Warning: Undeclared symbol: on
new_problem.pddl: line: 17: Warning: Undeclared symbol: occupied
new_problem.pddl: line: 20: Warning: Undeclared symbol: gripper_is_free
new_problem.pddl: line: 30: Error: Syntax error in problem file - types used, but no :types section in domain file.
Thank you very much in advance for your help.

Related

PDDL is not compiling. Log files gave me a bunch of errors

I am very new to PDDL and I got an assignment due soon. For some reason, it is not compiling and keeps giving me errors but the log file is so messy and I can not find where I went wrong. Some help would really be appreciated.
The task is to write a PDDL domain that can solve a planning problem for floor
cleaning robots. A set of robots has the task to clean floor tiles. The robots can move
around the floor tiles in four directions (up, down, left, and right). Robots have a brush
mounted at the front and at the back, so they can clean in front and behind them (up
and down, respectively), but they cannot turn around. The robots, however, cannot
drive on wet surfaces, so they must never drive onto tiles they have already cleaned
(and are therefore wet). Besides, a robot cannot clean the tile where another robot is
occupied. The task is to write a planning domain, which can solve this task for general
environments.
This is the problem:
(define (problem prob001)
(:domain floor-tile1)
(:objects tile_0-1 tile_0-2
tile_1-1 tile_1-2
tile_2-1 tile_2-2
robot1
)
(:init
(robot-at robot1 tile_1-1)
(clear tile_0-1)
(clear tile_0-2)
(clear tile_1-2)
(clear tile_2-1)
(clear tile_2-2)
(up tile_1-1 tile_0-1)
(up tile_1-2 tile_0-2)
(up tile_2-1 tile_1-1)
(up tile_2-2 tile_1-2)
(down tile_0-1 tile_1-1)
(down tile_0-2 tile_1-2)
(down tile_1-1 tile_2-1)
(down tile_1-2 tile_2-2)
(right tile_0-2 tile_0-1)
(right tile_1-2 tile_1-1)
(right tile_2-2 tile_2-1)
(left tile_0-1 tile_0-2)
(left tile_1-1 tile_1-2)
(left tile_2-1 tile_2-2)
)
(:goal (and
(cleaned tile_0-1)
(cleaned tile_0-2)
(cleaned tile_1-1)
(cleaned tile_2-2)
))
)
The domain:
(define (domain floor-tile1)
(:requirements :typing :strips)
(:predicates (robot-at ?r ?x)
(up ?x ?y)
(down ?x ?y)
(right ?x ?y)
(left ?x ?y)
(clear ?x)
(cleaned ?x)
)
(:action clean-up
:parameters (?r ?toclean ?at)
:precondition (and
(up ?toclean ?at)
(down ?at ?toclean)
(clear ?toclean)
(robot-at ?r ?at)
(not (cleaned ?toclean))
)
:effect (cleaned ?toclean)
)
(:action clean-down
:parameters (?r ?toclean ?at)
:precondition (and
(down ?toclean ?at)
(up ?at ?toclean)
(not (cleaned ?toclean))
(clear ?toclean)
(robot-at ?r ?at)
)
:effect (cleaned ?toclean)
)
(:action up
:parameters (?r ?from ?to)
:precondition (and (up ?to ?from)
(down ?from ?to)
(clear ?to)
)
:effect (
(robot-at ?robot ?tt)
(not (clear ?to))
)
)
(:action down
:parameters (?r ?from ?to)
:precondition (and (down ?to ?from)
(up ?from ?to)
(clear ?to)
)
:effect (and
(robot-at ?r ?to)
(not (clear ?to))
)
)
(:action right
:parameters (?r ?from ?to)
:precondition (and (right ?to ?from)
(left ?from ?to)
(clear ?to)
)
:effect (and
(robot-at ?r ?to)
(not (clear ?to))
)
)
(:action left
:parameters (?r ?from ?to)
:precondition (and (left ?to ?from)
(right ?from ?to)
(clear ?to)
)
:effect (and
(robot-at ?r ?to)
(not (clear ?to))
)
)
)

PDDL syntax error, ':DURATIVE-ACTIONS' : domain definition expected

I was modeling a domain file with durative actions. I am using the PDDL plugin for VS Code. The code does not have any syntax error problems. The Planner from HTTP://solver.planning.domains/solve return an error
/tmp/solver_planning_domains_tmp_41rdIKx0z0gCb/domain.pddl: syntax error in line 5, ':DURATIVE-ACTIONS': domain definition expected Failed to parse the problem -- list index out of range
The complete domain file big to post here, so the related part of code is:
I appreciated your help.
(define (domain test)
(:requirements :strips :typing :fluents :durative-actions :duration-inequalities :negative-preconditions :equality )
(:types
getbot - robot
wp0 wp1 charging_station object_location - location
a1 a2 a3 - area
bat1 charger - power
gripper
obj- object
)
(:predicates
;General predicates
(robot-at ?rb - robot ?l - location)
(location-situated ?l - location ?a - area) ;location situated in which area
;Gripper related predicates
(object-found ?o - object)
(object-at ?o - object ?obj_loc - location)
(object-placed ?o - object ?obj_loc - location)
(gripper-empty ?rb - robot ?gr - gripper)
(holding-object ?rb - robot ?o - object)
Thank you in advance
The planner on that server doesn't support durative actions.

PDDL forall with when condition in durative-action

This question builds on a previous question about forall clauses. I would like to limit the forall with a 'when' statement as shown below:
(:durative-action finish
:parameters (?r - robot ?p - part)
:duration ( = ?duration 1)
:condition (and
(at start (robot_free ?r))
(at start (forall (?f - fastener_loc)
when (part_fastener ?p ?f)
(loc_not_fastened ?f)
)
)
)
:effect (and
(at start(not (robot_free ?r)))
(at end (part_free ?p))
(at end (robot_free ?r))
)
)
This works without the 'when' statement. When I include the 'when' statement, I receive several errors:
Error: Syntax error in durative-action declaration.
Error: Unreadable structure
Error: Syntax error in domain
Thanks in advance for any help.
I was able to get this to work with an imply statement.
(:durative-action finish
:parameters (?r - robot ?p - part)
:duration ( = ?duration 1)
:condition (and
(at start (robot_free ?r))
(at start (forall (?f - fastener_loc)
(imply (part_fastener ?p ?f)(loc_not_fastened ?f))
)
)
)
:effect (and
(at start(not (robot_free ?r)))
(at end (part_free ?p))
(at end (robot_free ?r))
)
)
Not sure if this could also work the the when syntax.
The when clause needs to be wrapped in (brackets)
The when keyword is restricted to conditional effects.
You can see the definition in the PDDL3.1 BNF.
Be a bit careful when combining forall with imply, because it could lead to a nasty combinatorial explosion. Keep in mind that imply typically gets flattened (Negation Normal Form) to a disjunction. So in your case it would become:
(or (not (part_fastener ?p ?f)) (loc_not_fastened ?f))
Which planners typically split into two separate actions (to remove disjunctions), one with (not (part_fastener ?p ?f)) as its precondition, and one with (loc_not_fastened ?f).
The forall then explodes this to all pairwise combinations of the disjunction, to ground it to all instances of fastener_loc, combined with all grounded combinations of robot and part action parameters (to generate the grounded actions themselves).
If you only have a few objects of each type I guess you should be OK.

SPARQL: Dividing a BGP into multiple Groups

In a previous question, a comment suggests that
select ?x ?y where {
{?x rdf:type ex:someType}
{?x ex:someProperty ?y}
}
is like (not identical) to:
select ?x ?y where {
?x rdf:type ex:someType.
?x ex:someProperty ?y.
}
Same triple patterns are used. However, the first query contains two BGPs (each one in a group pattern), while the second contains one BGP (no group patterns).
The algebra for the first query is a JOIN between two BGPs while the algebra of the second is only a BGP.
First query algebra (Apache Jena)
(project (?x ?y)
(join
(bgp (triple ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.example.com/someType>))
(bgp (triple ?x <http://www.example.com/someProperty> ?y))))
Second query algebra (Apache Jena):
(project (?x ?y)
(bgp
(triple ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.example.com/someType>)
(triple ?x <http://www.example.com/someProperty> ?y)
))
In the original question, the answer suggest that they are not identical and argues
If the SPARQL entailment is supported, then the separate {} are evaluated for entailment separately.
if you use labels bnodes in queries there restrictions cross {}
if you add FILTERS, then they do not apply outside the {} they are written in.
its a different abstract syntax tree. All minor points but which may come into play later.
Now let's put the blank nodes (2) and the different syntax trees aside (4), and ask the following: Would the two queries, in any case, yield different results because of filter (3) or entailment(1)? I do not see any possibility for that. Well, those who have a different opinion, may you, please show with some example?
Scope of FILTER is affected.
In:
select ?x ?y where {
{?x rdf:type ex:someType FILTER (?y > 0 ) }
{?x ex:someProperty ?y}
}
The FILTER is false always because ?y is unbound so the expression is error and the FILTER is false regardless of the ?x ex:someProperty ?y.
(3) and (4) are related.

How to get the connected graph between 2 resources in RDF Graph [duplicate]

If this is the RDF graph , given the resource A , I need to construct all the triples connected to A till the end . here i have to get the graph include B,C,D,E
After that, suppose I've got this graph and want to go only from the starting point (:A) and get the subgraph produced by following the paths that end with an edge on property :d. For instance, if A1 is given as the starting point, and d as the property, we'd construct:
:A1 :a :B1,
:B1 :b :S1,
:B1 :b :S2,
:S1 :d :D1,
:S2 :d :D2,
The first case
To get the whole connected graph, you need to use a wildcard property path to follow most of the path, and then grab the last link with an actual variable. I usually use the empty relative path in constructing wildcards, so as to use <>|!<> as the wildcard, but since you mentioned that your endpoint doesn't like it, you can use any absolute IRI that you like, too. E.g.,
prefix x: <urn:ex:>
construct { ?s ?p ?o }
where { :A (x:|!x:)* ?s . ?s ?p ?o . }
This works because every property is either x: or not, so x:|!x: matches every property, and then (x:|!x:)* is an arbitrary length path, including paths of length zero, which means that ?s will be bound to everything reachable from :a, including :a itself. Then you're grabbing the triples where ?s is the subject. When you construct the graph of all those triples, you get the subgraph that you're looking for.
Here's an example based on the graph you showed. I used different properties for different edges to show that it works, but this will work if they're all the same, too.
#prefix : <urn:ex:> .
:A :p :B, :C .
:B :q :D .
:C :r :E .
:F :s :G .
:G :t :H .
prefix x: <urn:ex:>
prefix : <urn:ex:>
construct {
?s ?p ?o
}
where {
:A (x:|!x:)* ?s .
?s ?p ?o .
}
Since this is a construct query, the result is a graph, not a "table". It contains the triples we'd expect:
#prefix : <urn:ex:> .
:C :r :E .
:B :q :D .
:A :p :B , :C .
The second case
If you want to ensure that the paths end in a particular kind of edge, you can do that too. If you only want the paths from A1 to those ending with edges on d, you can do:
prefix x: <urn:ex:> #-- arbitrary, used for the property path.
prefix : <...> #-- whatever you need for your data.
construct {
?s1 ?p ?o1 . #-- internal edge in the path
?s2 :d ?o2 . #-- final edge in the path
}
where {
:A (x:|!x:)* ?s1 . #-- start at :A and go any length into the path
?s1 ?p ?o1 . #-- get the triple from within the path, but make
?o1 (x:|!x:)* ?s2 . #-- sure that from ?o1 you can get to to some other
?s2 :d ?o2 . #-- ?s2 that's related to an ?o2 by property :d .
}
The most important part of an RDF graph is the properties. Since your diagram does not define the properties, the question is rather ambiguous, but comes down to a couple of scenarios.
If the property is the same in the graph, then a transitive property path can be used:
CONSTRUCT {:A :prop ?rsc }
WHERE {
:A :prop* ?rsc .
}
If there are multiple types pf properties in the graph, it is more complicated to get the transitive closure. For example the following will get all properties in the example graph:
CONSTRUCT {
:A ?p ?rsc1 .
:A ?p1 ?rsc2 .
}
WHERE {
:A ?p ?rsc1 .
OPTIONAL {?rsc1 ?p1 ?rsc2 .}
}
Note this goes two levels deep. For arbitrary levels, it may be best to call the following query until no new triples are created:
CONSTRUCT {
?rsc ?p ?o .
}
WHERE {
?rsc ?p ?o .
}
...where rsc is bound to :A initially and to the values for ?o for subsequent iterations.
It's not possible to get the whole connected graph with one CONSTRUCT query. You'll need to run multiple queries. Even with multiple queries it gets a bit tricky when Blank Nodes are involved as you will have to gradually expand their context and return this context in every subsequent query.
For an example of some code that does exactly this, see: https://github.com/apache/clerezza-rdf-core/tree/master/impl.sparql/src/main/java/org/apache/clerezza/commons/rdf/impl/sparql.