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

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))
)
)
)

Related

Error when domain and the problem to use durative-actions

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.

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 catch correct resource among disambiguations / interrogate subresources in DBPedia using SPARQL?

I have the title of a Youtube music video and I need to gather additional information from DBPedia like album, artist, release date, etc. I'd also like to get the 'abstract' of all these entities from DBPedia. I already use Musicbrainz to differentiate between song and artist in the title and it works rather well, except a few cases.
However my main problem is: when I pass the song to ask DBPedia (using a query with resource/{song}), sometimes I get no answer because {song} causes disambiguation. Example: resource/It's_My_Life has 11 disambiguates, 6 of which are songs. I need the resource "It's_My_Life_(Bon_Jovi_song)". How can I tell DBPedia that I need a resource of 'MusicalWork' type of a certain artist?
I tried in many ways to do this with SPARQL, but I always get an empty result and I don't know what I'm doing wrong. So far I was able to only get the abstract of every disambiguation, but I cannot get a specific property (like abstract) of a subresource of a disambiguation.
SELECT ?x ?y WHERE {
<http://dbpedia.org/resource/It's_My_Life> dbo:wikiPageDisambiguates ?x .
?x dbo:abstract ?y .
}
I can't seem to go father than this. I tried with:
SELECT ?x ?y WHERE {
<http://dbpedia.org/resource/It's_My_Life> dbo:wikiPageDisambiguates ?x .
?x dbo:MusicalArtist ?y .
{ SELECT ?z WHERE {
?y dbo:abstract ?z}
}
}
and
SELECT ?x ?y WHERE {
<http://dbpedia.org/resource/It's_My_Life> dbo:wikiPageDisambiguates ?x
?x rdfs:type ?y .
}
But results are always empty. How am I supposed to interrogate a subresource of a resource? Can anyone help me?
Solution, pulled from comments by #AKSW --
SELECT ?x ?y
WHERE
{
<http://dbpedia.org/resource/It's_My_Life> dbo:wikiPageDisambiguates ?x .
?x rdf:type dbo:MusicalWork .
?x dbo:abstract ?y .
FILTER ( LANGMATCHES ( LANG (?y), 'en' ) )
}

Extracting hierarchy for dbpedia entity using SPARQL

I am trying to extract the hierarchy of Wikipedia category or Yago classification for DBpedia resources using the SPARQL endpoint. For instance, I would like to find out all the possible categories and classes in hierarchical form of entity, say, http://dbpedia.org/resource/Nokia, like Thing → Organization → Company → … → Nokia.
A simple SPARQL select can retrieve the information that you're interested in, though it won't be arranged hierarchically. You're interested in getting all the types of a resource, as well as the rdfs:subClassOf relations between them. Here's a very simple query for Nokia that can be run on the DBpedia SPARQL endpoint
SELECT * WHERE {
dbpedia:Nokia a ?c1 ; a ?c2 .
?c1 rdfs:subClassOf ?c2 .
}
SPARQL results
If you treat each pair of classes in that result set as a directed edge and perform a topological sort , then you'll see the hierarchy of the classes to which the Nokia resource belongs. In fact, since it is probably convenient to treat this as a graph, you can get it in the form of an RDF graph by using a SPARQL construct query.
CONSTRUCT WHERE {
dbpedia:Nokia a ?c1 ; a ?c2 .
?c1 rdfs:subClassOf ?c2 .
}
SPARQL results
The construct query produces this graph (in N3 format):
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#prefix dbpedia-owl: <http://dbpedia.org/ontology/> .
#prefix owl: <http://www.w3.org/2002/07/owl#> .
#prefix yago: <http://dbpedia.org/class/yago/> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix dbpedia: <http://dbpedia.org/resource/> .
dbpedia-owl:Agent rdfs:subClassOf owl:Thing .
dbpedia-owl:Company rdfs:subClassOf dbpedia-owl:Organisation .
dbpedia-owl:Organisation rdfs:subClassOf dbpedia-owl:Agent .
yago:CompaniesBasedInEspoo rdfs:subClassOf yago:Company108058098 .
dbpedia:Nokia rdf:type yago:CompaniesListedOnTheHelsinkiStockExchange ,
owl:Thing ,
yago:CompaniesBasedInEspoo ,
dbpedia-owl:Agent ,
yago:DisplayTechnologyCompanies ,
yago:ElectronicsCompaniesOfFinland ,
dbpedia-owl:Company ,
dbpedia-owl:Organisation ,
yago:Company108058098 ,
yago:CompaniesEstablishedIn1865 .
yago:CompaniesEstablishedIn1865 rdfs:subClassOf yago:Company108058098 .
yago:CompaniesListedOnTheHelsinkiStockExchange rdfs:subClassOf yago:Company108058098 .
yago:DisplayTechnologyCompanies rdfs:subClassOf yago:Company108058098 .
yago:ElectronicsCompaniesOfFinland rdfs:subClassOf yago:Company108058098 .
Remarks
The queries above retrieve the rdf:type hierarchy for Nokia. In the question, you also mention Wikipedia categories. DBpedia resources are associated with the Wikipedia categories to which their corresponding articles belong by the dcterms:subject property. Those Wikipedia categories are then structured hierarchically by skos:broader. These really are not types for the individuals though. For instance, the data contain:
dbpedia:Nokia dcterms:subject category:Finnish_brands
category:Finnish_brands skos:broader category:Brands_by_country
While it probably makes sense to say that Nokia is a Finnish_brand, it makes much less sense to say that Nokia is a Brand_by_country.