-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9bf57e1
commit a8c5d2b
Showing
3 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
Gripper with multi-robot, multi-gripper, multi-rooms configuration. | ||
|
||
usage: gripper.py [-h] [--seed SEED] balls robots grippers rooms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
;; variable number of robots, variable number of grippers per robot | ||
(define (domain gripper-ex-typed) | ||
(:requirements :strips :typing) | ||
(:types room ball gripper robot) | ||
(:predicates (at-robot ?r - robot ?a - room) | ||
(at-ball ?b - ball ?r - room) | ||
(has ?r - robot ?g - gripper) | ||
(free ?g - gripper) | ||
(carry ?b - ball ?g - gripper)) | ||
|
||
(:action move | ||
:parameters (?from - room ?to - room ?robot - robot) | ||
:precondition (at-robot ?robot ?from) | ||
:effect (and (at-robot ?robot ?to) | ||
(not (at-robot ?robot ?from)))) | ||
|
||
|
||
|
||
(:action pick | ||
:parameters (?ball - ball ?room - room ?robot - robot ?gripper - gripper) | ||
:precondition (and (at-ball ?ball ?room) (at-robot ?robot ?room) (has ?robot ?gripper) (free ?gripper)) | ||
:effect (and (carry ?ball ?gripper) | ||
(not (at-ball ?ball ?room)) | ||
(not (free ?gripper)))) | ||
|
||
|
||
(:action drop | ||
:parameters (?ball - ball ?room - room ?robot - robot ?gripper - gripper) | ||
:precondition (and (at-robot ?robot ?room) (has ?robot ?gripper) (carry ?ball ?gripper)) | ||
:effect (and (at-ball ?ball ?room) | ||
(free ?gripper) | ||
(not (carry ?ball ?gripper))))) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env python | ||
|
||
import argparse | ||
import random | ||
import itertools | ||
|
||
parser = argparse.ArgumentParser() | ||
|
||
parser.add_argument("balls", type=int, help="the number of balls") | ||
parser.add_argument("robots", type=int, help="the number of robots") | ||
parser.add_argument("grippers", type=int, help="the number of grippers per robot") | ||
parser.add_argument("rooms", type=int, help="the number of rooms") | ||
parser.add_argument("--seed", "-s", type=int, help="random seed") | ||
|
||
args = parser.parse_args() | ||
|
||
random.seed(args.seed) | ||
|
||
robots = [f"robot{i}" for i in range(args.robots)] | ||
rooms = [f"room{i}" for i in range(args.rooms)] | ||
grippers = [f"gripper-{i}-{j}" for i,j in itertools.product(range(args.robots),range(args.grippers))] | ||
balls = [f"ball{i}" for i in range(args.balls)] | ||
|
||
|
||
|
||
def init(): | ||
facts = [f"(has robot{i} gripper-{i}-{j}) (free gripper-{i}-{j})" | ||
for i,j in itertools.product(range(args.robots),range(args.grippers))] | ||
|
||
for ball in balls: | ||
room = random.choice(rooms) | ||
facts.append(f"(at-ball {ball} {room})") | ||
for robot in robots: | ||
room = random.choice(rooms) | ||
facts.append(f"(at-robot {robot} {room})") | ||
|
||
return " ".join(facts) | ||
|
||
|
||
def goal(): | ||
facts = [] | ||
|
||
for ball in balls: | ||
room = random.choice(rooms) | ||
facts.append(f"(at-ball {ball} {room})") | ||
|
||
return " ".join(facts) | ||
|
||
|
||
print("(define (problem gripper)") | ||
print(" (:domain gripper-ex-typed)") | ||
print(" (:objects " | ||
+ " ".join( | ||
robots + ["-", "robots"] + | ||
rooms + ["-", "rooms"] + | ||
grippers + ["-", "grippers"] + | ||
balls + ["-", "balls"]) | ||
+ ")") | ||
print(" (:init " + init() + ")") | ||
print(" (:goal " + goal() + "))") |