Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matching a string plan to a compiled task #618

Open
MFaisalZaki opened this issue Jul 12, 2024 · 0 comments
Open

Matching a string plan to a compiled task #618

MFaisalZaki opened this issue Jul 12, 2024 · 0 comments

Comments

@MFaisalZaki
Copy link

I'm facing a situation where I'm reading plans from files written for a non-grounded task and I have idea how to map them to a grounded task.

Here is an example:
Assume that I have this plan for the rover domain:

plan1 = (navigate rover1 waypoint3 waypoint0)\n(calibrate rover1 camera1 objective0 waypoint0)\n(take_image rover1 waypoint0 objective0 camera1 colour)\n(sample_rock rover1 rover1store waypoint0)\n(drop rover1 rover1store)\n(navigate rover1 waypoint0 waypoint3)\n(communicate_rock_data rover1 general waypoint0 waypoint3 waypoint0)\n(navigate rover1 waypoint3 waypoint2)\n(communicate_image_data rover1 general objective0 colour waypoint2 waypoint0)\n(sample_soil rover1 rover1store waypoint2)\n(communicate_soil_data rover1 general waypoint2 waypoint2 waypoint0)\n; 11 cost (unit)

I use the PDDLReader().parse_plan_string(task, plan) to read it. Also, I have grounded this task; my question here is how to match the plan1 actions to the grounded version.

Here is my code:

plan1 = '(navigate rover1 waypoint3 waypoint0)\n(calibrate rover1 camera1 objective0 waypoint0)\n(take_image rover1 waypoint0 objective0 camera1 colour)\n(sample_rock rover1 rover1store waypoint0)\n(drop rover1 rover1store)\n(navigate rover1 waypoint0 waypoint3)\n(communicate_rock_data rover1 general waypoint0 waypoint3 waypoint0)\n(navigate rover1 waypoint3 waypoint2)\n(communicate_image_data rover1 general objective0 colour waypoint2 waypoint0)\n(sample_soil rover1 rover1store waypoint2)\n(communicate_soil_data rover1 general waypoint2 waypoint2 waypoint0)\n; 11 cost (unit)'

domainfile  = 'domain.pddl'
problemfile = 'p03.pddl'

task = PDDLReader().parse_problem(domainfile, problemfile)

compilationlist = [
    ('up_quantifiers_remover', CompilationKind.QUANTIFIERS_REMOVING), 
    ('up_disjunctive_conditions_remover', CompilationKind.DISJUNCTIVE_CONDITIONS_REMOVING), 
    ('up_grounder', CompilationKind.GROUNDING)
]

names = [name for name, _ in compilationlist]
compilationkinds = [kind for _, kind in compilationlist]
with Compiler(names=names, compilation_kinds=compilationkinds) as compiler:
    compiled_task = compiler.compile(task)

original_plan = PDDLReader().parse_plan_string(task, plan1)
# How to get the grounded version.

The way I do it now using this line of code:

converted_plan = list(map(lambda p: PDDLReader().parse_plan_string(compiled_task.problem,  PDDLWriter(compiled_task.problem).get_plan(PDDLReader().parse_plan_string(task, p)).replace(' ', '_')), set([plan1])))

task.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant