Skip to content

Instantly share code, notes, and snippets.

@rpgoldman
Created November 1, 2023 19:59
Show Gist options
  • Save rpgoldman/e54976a95388467dd7a8dcc72cc42353 to your computer and use it in GitHub Desktop.
Save rpgoldman/e54976a95388467dd7a8dcc72cc42353 to your computer and use it in GitHub Desktop.
Inputs to pandaPIparser for verification
(define (domain satellite)
(:requirements :equality :typing :conditional-effects :negative-preconditions
:universal-preconditions :htn-method-prec)
(:types satellite direction instrument mode)
(:predicates
(on_board ?i - instrument ?s - satellite)
(supports ?i - instrument ?m - mode)
(pointing ?s - satellite ?d - direction)
(power_avail ?s - satellite)
(power_on ?i - instrument)
(calibrated ?i - instrument)
(have_image ?d - direction ?m - mode)
(calibration_target ?i - instrument ?d - direction)
;; translating goals to tasks
(goal_have_image ?d - direction ?m - mode)
(goal_pointing ?s - satellite ?d - direction))
(:task main)
(:task have-image :parameters (?d - direction ?m - mode))
(:task take-image :parameters (?s - satellite ?i - instrument ?d - direction ?m - mode))
(:task prepare-instrument :parameters (?s - satellite ?i - instrument))
(:task turn-on-instrument :parameters (?s - satellite ?i - instrument))
(:task calibrate-instrument :parameters (?s - satellite ?i - instrument))
(:action turn_to
:parameters (?s - satellite ?d_new - direction ?d_prev - direction)
:precondition (and (pointing ?s ?d_prev)
(not (= ?d_new ?d_prev))
)
:effect (and (pointing ?s ?d_new)
(not (pointing ?s ?d_prev))
)
)
(:action switch_on
:parameters (?i - instrument ?s - satellite)
:precondition (and (on_board ?i ?s)
(power_avail ?s)
)
:effect (and (power_on ?i)
(when (calibrated ?i) (not (calibrated ?i)))
(not (power_avail ?s))
)
)
(:action switch_off
:parameters (?i - instrument ?s - satellite)
:precondition (and (on_board ?i ?s)
(power_on ?i)
)
:effect (and (not (power_on ?i))
(power_avail ?s)
)
)
(:action calibrate
:parameters (?s - satellite ?i - instrument ?d - direction)
:precondition (and (on_board ?i ?s)
(calibration_target ?i ?d)
(pointing ?s ?d)
(power_on ?i)
)
:effect (calibrated ?i)
)
(:action take_image
:parameters (?s - satellite ?d - direction ?i - instrument ?m - mode)
:precondition (and (calibrated ?i)
(on_board ?i ?s)
(supports ?i ?m)
(power_on ?i)
(pointing ?s ?d)
(power_on ?i)
)
:effect (when (not (have_image ?d ?m)) (have_image ?d ?m))
)
(:method take-one
:parameters (?d - direction ?m - mode)
:task (main)
:precondition (and
(goal_have_image ?d ?m)
(not (have_image ?d ?m)))
:ordered-subtasks
(and
(have-image ?d ?m)
(main)))
(:method turn-first
:parameters (?s - satellite ?d ?d1 - direction)
:task (main)
:precondition
(and
(goal_pointing ?s ?d)
(pointing ?s ?d1)
(not (= ?d ?d1)))
:ordered-subtasks
(and (turn_to ?s ?d ?d1)
(main)))
(:method all-done
:parameters ()
:task (main)
:precondition
(and (forall (?d - direction ?m - mode)
(imply (goal_have_image ?d ?m)
(have_image ?d ?m)))
(forall (?s - satellite ?d - direction)
(imply
(goal_pointing ?s ?d)
(pointing ?s ?d))))
:ordered-subtasks ())
(:method prepare-then-take
:parameters (?d - direction ?m - mode ?i - instrument ?s - satellite)
:task (have-image ?d ?m)
:precondition
(on_board ?i ?s)
:ordered-subtasks
(and
(prepare-instrument ?s ?i)
(take-image ?s ?i ?d ?m)))
(:method prepare
:parameters (?i - instrument ?s - satellite)
:task (prepare-instrument ?s ?i)
:ordered-subtasks
(and (turn-on-instrument ?s ?i)
(calibrate-instrument ?s ?i)))
(:method already-on
:parameters (?i - instrument ?s - satellite)
:task (turn-on-instrument ?s ?i)
:precondition
(power_on ?i)
:ordered-subtasks
())
(:method turn-on
:parameters (?i - instrument ?s - satellite)
:task (turn-on-instrument ?s ?i)
:precondition
(power_avail ?s)
:ordered-subtasks
(switch_on ?i ?s))
(:method swap-instruments
:parameters (?i ?j - instrument ?s - satellite)
:task (turn-on-instrument ?s ?i)
:precondition (and (power_on ?j)
(not (= ?i ?j)))
:ordered-subtasks
(and (switch_off ?j ?s)
(switch_on ?i ?s)))
(:method no-calibration-needed
:parameters (?i - instrument ?s - satellite)
:task (calibrate-instrument ?s ?i)
:precondition
(and (power_on ?i)
(calibrated ?i))
:ordered-subtasks ())
(:method do-calibrate
:parameters (?i - instrument ?s - satellite ?d - direction)
:task (calibrate-instrument ?s ?i)
:precondition
(and
(power_on ?i)
(pointing ?s ?d)
(calibration_target ?i ?d))
:ordered-subtasks (calibrate ?s ?i ?d))
(:method repoint-then-calibrate
:parameters (?i - instrument ?s - satellite ?d ?d2 - direction)
:task (calibrate-instrument ?s ?i)
:precondition
(and (pointing ?s ?d2)
(calibration_target ?i ?d)
(not (= ?d ?d2)))
:ordered-subtasks (and (turn_to ?s ?d ?d2)
(calibrate ?s ?i ?d)))
(:method simple-take-image
:parameters (?s - satellite ?i - instrument ?d ?d-prev - direction ?m - mode)
:task (take-image ?s ?i ?d ?m)
:precondition
(and
(pointing ?s ?d))
:ordered-subtasks
(and (take_image ?s ?d ?i ?m)))
(:method turn-then-take
:parameters (?s - satellite ?i - instrument ?d ?d-prev - direction ?m - mode)
:task (take-image ?s ?i ?d ?m)
:precondition
(and
(pointing ?s ?d-prev)
(not (pointing ?s ?d)))
:ordered-subtasks
(and (turn_to ?s ?d ?d-prev)
(take_image ?s ?d ?i ?m))))
(define (problem strips-sat-x-1)
(:domain satellite)
(:objects
satellite0 - satellite
instrument0 - instrument
image1 - mode
spectrograph2 - mode
thermograph0 - mode
star0 - direction
groundstation1 - direction
groundstation2 - direction
phenomenon3 - direction
phenomenon4 - direction
star5 - direction
phenomenon6 - direction)
(:init
(supports instrument0 thermograph0)
(calibration_target instrument0 groundstation2)
(on_board instrument0 satellite0)
(power_avail satellite0)
(pointing satellite0 phenomenon6)
(goal_have_image phenomenon4 thermograph0)
(goal_have_image star5 thermograph0)
(goal_have_image phenomenon6 thermograph0))
(:htn :ordered-subtasks (main))
(:goal
(and
(have_image phenomenon4 thermograph0)
(have_image star5 thermograph0)
(have_image phenomenon6 thermograph0))))
==>
8 switch_on instrument0 satellite0
9 turn_to satellite0 groundstation2 phenomenon6
10 calibrate satellite0 instrument0 groundstation2
11 turn_to satellite0 star5 groundstation2
12 take_image_a satellite0 star5 instrument0 thermograph0
19 turn_to satellite0 phenomenon6 star5
20 take_image_a satellite0 phenomenon6 instrument0 thermograph0
27 turn_to satellite0 phenomenon4 phenomenon6
28 take_image_a satellite0 phenomenon4 instrument0 thermograph0
root 1
1 main -> take-one 2 3
2 have_image star5 thermograph0 -> prepare-then-take 4 5
4 prepare-instrument satellite0 instrument0 -> prepare 6 7
6 turn-on-instrument satellite0 instrument0 -> turn-on 8
7 calibrate-instrument satellite0 instrument0 -> repoint-then-calibrate 9 10
5 take-image_t satellite0 instrument0 star5 thermograph0 -> turn-then-take 11 12
3 main -> take-one 13 14
13 have_image phenomenon6 thermograph0 -> prepare-then-take 15 16
15 prepare-instrument satellite0 instrument0 -> prepare 17 18
17 turn-on-instrument satellite0 instrument0 -> already-on
18 calibrate-instrument satellite0 instrument0 -> no-calibration-needed
16 take-image_t satellite0 instrument0 phenomenon6 thermograph0 -> turn-then-take 19 20
14 main -> take-one 21 22
21 have_image phenomenon4 thermograph0 -> prepare-then-take 23 24
23 prepare-instrument satellite0 instrument0 -> prepare 25 26
25 turn-on-instrument satellite0 instrument0 -> already-on
26 calibrate-instrument satellite0 instrument0 -> no-calibration-needed
24 take-image_t satellite0 instrument0 phenomenon4 thermograph0 -> turn-then-take 27 28
22 main -> all-done
<==
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment