I am a beginner in PDDL and currently want to build a Project, that allows a rover to autonomously act on mars. Basically, the rover should have a battery.
Eg. rover can increase the amount by charging at a waypoint (+10 per action) and the percentage will be decreased a -> b
(-15).
It should be modeled rather simple so there has to be no decrease over time, I just want to define in the init
sth. like:
when it travels from a to b amount decreased by 10, from b to c by -10 and from a to c -25...
this is my domain file currently:
(define (domain rover)
(:requirements :fluents)
(:types LOCATION - Obj
ROVER - Obj)
(:constants )
(:predicates (path ?r - ROVER ?l1 ?l2 - LOCATION)
(at ?r - ROVER ?l - LOCATION)
)
(:functions
(battery-amount)
;(battery-capacity)
)
(:action move
:parameters (?r - ROVER ?from - LOCATION ?to - LOCATION)
:precondition (and (at ?r ?from) (path ?r ?from ?to) (> (battery-amount) 90))
:effect (and (at ?r ?to) (not (at ?r ?from))
(decrease (battery-amount) 10)
)
)
)
this is the Problem:
(define (problem roverprob1)
(:domain rover)
(:objects
r0 - ROVER
l0 l1 l2 l3 l4 - LOCATION)
(:init (at r0 l1) (= (battery-amount) 100)
(path r0 l3 l0) (path r0 l0 l3) (path r0 l3 l1)
(path r0 l1 l3) (path r0 l1 l2) (path r0 l2 l1)
(path r0 l3 l4) (path r0 l4 l3)
)
(:goal (and (at r0 l4)))
)
My idea was that my battery-amount
should be a function in the domain, Its initial value is set in Problem with 100 and to start with every action move
should decrease the amount by 10.
to verify the results I implemented a precondition to the action move which should check if the amount is greater than 90.
My rover has to move in two steps in order to get to Location l4. so he should not be able to make it to l4.
Interestingly enough the Editor still finds a way to solve the problem. It is the same solution that I would get without the battery amount. It seems to me, that he does not update the value and I have no idea why ^^
thank you in advance for any help or suggestions!
UPDATE
I dug further into the problem and got myself the PDDL
expansion for VSCode
.
You can view the current state here: current state
If I take a look at the visual output that vs code provides I noticed the following:
(:init
(at r0 l1)
(= (fuel-level r0) 90)...)
when the rover has enough energy to drive along the path, the graph for the fuel level shows the following:
but when I change the init value, so the rover should not be able to get to the goal waypoint
(:init
(at r0 l1)
(= (fuel-level r0) 50)...)
the fuel used graph does look very different:
the graph is now a line that seems to be at 0 the whole time. So I am thinking, that the planer knows that the fuel is not enough and therefore treats it as 0 but the precondition does not trigger. I would expect an output like: Goal can be simplified to false or sth. like that.
I need this precondition to be working because eventually, I want the rover to recharge its battery when he determines that he cant make a path with his fuel level...