KCL-Planning / ROSPlan

The ROSPlan framework provides a generic method for task planning in a ROS system.
http://kcl-planning.github.io/ROSPlan
BSD 2-Clause "Simplified" License
359 stars 158 forks source link

Metric-FF fails to find solution #293

Closed rakhmanu closed 3 years ago

rakhmanu commented 3 years ago

Hi,

When I try to use Metric-FF in RosPlan, it always fails to find a solution. When I check the PDDL files by VAL in RospLan, it gives no error. However, I installed the Metric-FF planner from an external source, and it works well.

This s the launch file:

<include file="$(find rosplan_planning_system)/launch/includes/planner_interface_metricff.launch"> 
    <!--<include file="$(find rosplan_planning_system)/launch/includes/rosplan_planner_interfaces.launch"> -->
        <arg name="use_problem_topic"    value="false" />
        <arg name="planner_topic"        value="planner_output" />
        <arg name="domain_path"          value="$(find try)/common/PDDL/domain.pddl" />
        <arg name="problem_path"         value="$(find try)/common/PDDL/problem.pddl" />
        <arg name="data_path"            value="$(find try)/common/PDDL/" />
        <arg name="planner_command"      value="timeout 10 $(find rosplan_planning_system)/common/bin/Metric-FF DOMAIN PROBLEM" />
    </include>

This is planner_interface_metricff.launch

<?xml version="1.0"?>

Am I missing something or something is wrong? Could you please have a look?

Thank you very much, Sincerely Ulzhalgas Rakhman

domain.pddl

(define (domain tetris)
(:requirements :typing :equality :negative-preconditions :action-costs)
  (:types  
    one_square two_straight right_l - pieces
    position    
    )

  (:predicates
    (clear ?xy - position)
    (connected ?x - position ?y - position )
    (at_square ?element - one_square ?xy - position)
    (at_two ?element - two_straight ?xy - position ?xy2 - position)
    (at_right_l ?element - right_l ?xy - position ?xy2 - position ?xy3 - position)

  )
(:functions (total-cost) - number)

;; move a 1 square piece
(:action move_square
  :parameters (?xy_initial - position ?xy_final - position ?element - one_square )
  :precondition (and 
        (clear ?xy_final) 
        (at_square ?element ?xy_initial) 
        (connected ?xy_initial ?xy_final)
        (connected ?xy_final ?xy_initial)  
        )
  :effect (and  
        (clear ?xy_initial)
        (at_square ?element ?xy_final)
        (not (clear ?xy_final))
        (not (at_square ?element ?xy_initial) )
                (increase (total-cost) 1)
        )
)

;; move a straight 2 square piece (this include rotation)
(:action move_two
  :parameters (?xy_initial1 - position ?xy_initial2 - position ?xy_final - position ?element - two_straight )
  :precondition (and 
        (clear ?xy_final) 
        (at_two ?element ?xy_initial1 ?xy_initial2) 
        (connected ?xy_initial2 ?xy_final) 
        )
  :effect (and  
        (clear ?xy_initial1)
        (at_two ?element ?xy_initial2 ?xy_final)
        (not (clear ?xy_final))
        (not (at_two ?element ?xy_initial1 ?xy_initial2) )
                (increase (total-cost) 2)
        )
)

;; moving a piece "L" to the right
(:action move_l_right
  :parameters (?xy_initial1 ?xy_initial2 ?xy_initial3 ?xy_final ?xy_final2 ?xy_between_final - position ?element - right_l )
  :precondition (and 
        (clear ?xy_final)
        (clear ?xy_final2) 
        (at_right_l ?element ?xy_initial1 ?xy_initial2 ?xy_initial3) 
        (connected ?xy_initial1 ?xy_final)
        (connected ?xy_initial3 ?xy_final2) 
        (connected ?xy_initial3 ?xy_final) 
        (connected ?xy_final ?xy_between_final) 
        (connected ?xy_final2 ?xy_between_final) 
        (not (= ?xy_final ?xy_final2))
        (not (= ?xy_between_final ?xy_initial3))
        (not (connected ?xy_initial1 ?xy_final2))
        )
  :effect (and  
        (clear ?xy_initial2)
        (clear ?xy_initial1)
        (at_right_l ?element ?xy_final ?xy_initial3 ?xy_final2) 
        (not (clear ?xy_final))
        (not (clear ?xy_final2))
        (not (at_right_l ?element ?xy_initial1 ?xy_initial2 ?xy_initial3))
                (increase (total-cost) 3)
        )
)

;; moving a piece "L" to the left
(:action move_l_left
  :parameters (?xy_initial1 ?xy_initial2 ?xy_initial3 ?xy_final ?xy_final2 - position ?element - right_l )
  :precondition (and 
        (clear ?xy_final)
        (clear ?xy_final2) 
        (at_right_l ?element ?xy_initial1 ?xy_initial2 ?xy_initial3) 
        (connected ?xy_initial1 ?xy_final)
        (connected ?xy_initial2 ?xy_final2) 
        (connected ?xy_final2 ?xy_final) 
        (not (= ?xy_final ?xy_final2))
        )
  :effect (and  
        (clear ?xy_initial3)
        (clear ?xy_initial1)
        (at_right_l ?element ?xy_final ?xy_final2 ?xy_initial2) 
        (not (clear ?xy_final))
        (not (clear ?xy_final2))
        (not (at_right_l ?element ?xy_initial1 ?xy_initial2 ?xy_initial3))
                (increase (total-cost) 3)
        )
)

;; moving a piece "L" up
(:action move_l_up
  :parameters (?xy_initial1 ?xy_initial2 ?xy_initial3 ?xy_final ?xy_final2 ?xy_between_final - position ?element - right_l )
  :precondition (and 
        (clear ?xy_final)
        (clear ?xy_final2) 
        (at_right_l ?element ?xy_initial1 ?xy_initial2 ?xy_initial3) 
        (connected ?xy_initial1 ?xy_final)
        (connected ?xy_initial3 ?xy_final2) 
        (connected ?xy_initial1 ?xy_final2) 
        (connected ?xy_final ?xy_between_final) 
        (connected ?xy_final2 ?xy_between_final) 
        (not (= ?xy_final ?xy_final2))
        (not (= ?xy_between_final ?xy_initial1))
        (not (connected ?xy_initial3 ?xy_final))
        )
  :effect (and  
        (clear ?xy_initial2)  
        (clear ?xy_initial3)
        (at_right_l ?element ?xy_final ?xy_initial1 ?xy_final2) 
        (not (clear ?xy_final))
        (not (clear ?xy_final2))
        (not (at_right_l ?element ?xy_initial1 ?xy_initial2 ?xy_initial3))
                (increase (total-cost) 3)
        )
)

;; moving a piece "L" down
(:action move_l_down
  :parameters (?xy_initial1 ?xy_initial2 ?xy_initial3 ?xy_final ?xy_final2 - position ?element - right_l )
  :precondition (and 
        (clear ?xy_final)
        (clear ?xy_final2) 
        (at_right_l ?element ?xy_initial1 ?xy_initial2 ?xy_initial3) 
        (connected ?xy_initial2 ?xy_final)
        (connected ?xy_initial3 ?xy_final2) 
        (connected ?xy_final2 ?xy_final) 
        (not (= ?xy_final ?xy_final2))
        )
  :effect (and  
        (clear ?xy_initial3)
        (clear ?xy_initial1)
        (at_right_l ?element ?xy_initial2 ?xy_final ?xy_final2) 
        (not (clear ?xy_final))
        (not (clear ?xy_final2))
        (not (at_right_l ?element ?xy_initial1 ?xy_initial2 ?xy_initial3))
            (increase (total-cost) 3)
        )
)

)

problem.pddl

(define (problem Tetris-10-4-3457188)
(:domain tetris)
(:objects  
f0-0f f0-1f f0-2f f0-3f 
f1-0f f1-1f f1-2f f1-3f 
f2-0f f2-1f f2-2f f2-3f 
f3-0f f3-1f f3-2f f3-3f 
f4-0f f4-1f f4-2f f4-3f 
f5-0f f5-1f f5-2f f5-3f 
f6-0f f6-1f f6-2f f6-3f 
f7-0f f7-1f f7-2f f7-3f 
f8-0f f8-1f f8-2f f8-3f 
f9-0f f9-1f f9-2f f9-3f - position
square0 - one_square
straight0 straight1 straight2 - two_straight
rightl0 - right_l
)
(:init
(connected f0-0f f0-1f)
(connected f0-1f f0-0f)
(connected f0-1f f0-2f)
(connected f0-2f f0-1f)
(connected f0-2f f0-3f)
(connected f0-3f f0-2f)
(connected f1-0f f1-1f)
(connected f1-1f f1-0f)
(connected f1-1f f1-2f)
(connected f1-2f f1-1f)
(connected f1-2f f1-3f)
(connected f1-3f f1-2f)
(connected f2-0f f2-1f)
(connected f2-1f f2-0f)
(connected f2-1f f2-2f)
(connected f2-2f f2-1f)
(connected f2-2f f2-3f)
(connected f2-3f f2-2f)
(connected f3-0f f3-1f)
(connected f3-1f f3-0f)
(connected f3-1f f3-2f)
(connected f3-2f f3-1f)
(connected f3-2f f3-3f)
(connected f3-3f f3-2f)
(connected f4-0f f4-1f)
(connected f4-1f f4-0f)
(connected f4-1f f4-2f)
(connected f4-2f f4-1f)
(connected f4-2f f4-3f)
(connected f4-3f f4-2f)
(connected f5-0f f5-1f)
(connected f5-1f f5-0f)
(connected f5-1f f5-2f)
(connected f5-2f f5-1f)
(connected f5-2f f5-3f)
(connected f5-3f f5-2f)
(connected f6-0f f6-1f)
(connected f6-1f f6-0f)
(connected f6-1f f6-2f)
(connected f6-2f f6-1f)
(connected f6-2f f6-3f)
(connected f6-3f f6-2f)
(connected f7-0f f7-1f)
(connected f7-1f f7-0f)
(connected f7-1f f7-2f)
(connected f7-2f f7-1f)
(connected f7-2f f7-3f)
(connected f7-3f f7-2f)
(connected f8-0f f8-1f)
(connected f8-1f f8-0f)
(connected f8-1f f8-2f)
(connected f8-2f f8-1f)
(connected f8-2f f8-3f)
(connected f8-3f f8-2f)
(connected f9-0f f9-1f)
(connected f9-1f f9-0f)
(connected f9-1f f9-2f)
(connected f9-2f f9-1f)
(connected f9-2f f9-3f)
(connected f9-3f f9-2f)
(connected f0-0f f1-0f)
(connected f1-0f f0-0f)
(connected f0-1f f1-1f)
(connected f1-1f f0-1f)
(connected f0-2f f1-2f)
(connected f1-2f f0-2f)
(connected f0-3f f1-3f)
(connected f1-3f f0-3f)
(connected f1-0f f2-0f)
(connected f2-0f f1-0f)
(connected f1-1f f2-1f)
(connected f2-1f f1-1f)
(connected f1-2f f2-2f)
(connected f2-2f f1-2f)
(connected f1-3f f2-3f)
(connected f2-3f f1-3f)
(connected f2-0f f3-0f)
(connected f3-0f f2-0f)
(connected f2-1f f3-1f)
(connected f3-1f f2-1f)
(connected f2-2f f3-2f)
(connected f3-2f f2-2f)
(connected f2-3f f3-3f)
(connected f3-3f f2-3f)
(connected f3-0f f4-0f)
(connected f4-0f f3-0f)
(connected f3-1f f4-1f)
(connected f4-1f f3-1f)
(connected f3-2f f4-2f)
(connected f4-2f f3-2f)
(connected f3-3f f4-3f)
(connected f4-3f f3-3f)
(connected f4-0f f5-0f)
(connected f5-0f f4-0f)
(connected f4-1f f5-1f)
(connected f5-1f f4-1f)
(connected f4-2f f5-2f)
(connected f5-2f f4-2f)
(connected f4-3f f5-3f)
(connected f5-3f f4-3f)
(connected f5-0f f6-0f)
(connected f6-0f f5-0f)
(connected f5-1f f6-1f)
(connected f6-1f f5-1f)
(connected f5-2f f6-2f)
(connected f6-2f f5-2f)
(connected f5-3f f6-3f)
(connected f6-3f f5-3f)
(connected f6-0f f7-0f)
(connected f7-0f f6-0f)
(connected f6-1f f7-1f)
(connected f7-1f f6-1f)
(connected f6-2f f7-2f)
(connected f7-2f f6-2f)
(connected f6-3f f7-3f)
(connected f7-3f f6-3f)
(connected f7-0f f8-0f)
(connected f8-0f f7-0f)
(connected f7-1f f8-1f)
(connected f8-1f f7-1f)
(connected f7-2f f8-2f)
(connected f8-2f f7-2f)
(connected f7-3f f8-3f)
(connected f8-3f f7-3f)
(connected f8-0f f9-0f)
(connected f9-0f f8-0f)
(connected f8-1f f9-1f)
(connected f9-1f f8-1f)
(connected f8-2f f9-2f)
(connected f9-2f f8-2f)
(connected f8-3f f9-3f)
(connected f9-3f f8-3f)
(clear f0-1f)
(clear f0-3f)
(clear f1-3f)
(clear f2-0f)
(clear f2-3f)
(clear f3-2f)
(clear f3-3f)
(clear f4-0f)
(clear f4-2f)
(clear f4-3f)
(clear f5-0f)
(clear f5-1f)
(clear f5-2f)
(clear f5-3f)
(clear f6-0f)
(clear f6-1f)
(clear f6-2f)
(clear f6-3f)
(clear f7-0f)
(clear f7-1f)
(clear f7-2f)
(clear f7-3f)
(clear f8-0f)
(clear f8-1f)
(clear f8-2f)
(clear f8-3f)
(clear f9-0f)
(clear f9-1f)
(clear f9-2f)
(clear f9-3f)
(at_right_l rightl0 f1-1f f2-1f f2-2f)
(at_two straight0 f0-0f f1-0f)
(at_two straight1 f0-2f f1-2f)
(at_two straight2 f3-1f f4-1f)
(at_square square0 f3-0f)
(= (total-cost) 0)
)
(:goal
(and
(clear f0-0f)
(clear f0-1f)
(clear f0-2f)
(clear f0-3f)
(clear f1-0f)
(clear f1-1f)
(clear f1-2f)
(clear f1-3f)
(clear f2-0f)
(clear f2-1f)
(clear f2-2f)
(clear f2-3f)
(clear f3-0f)
(clear f3-1f)
(clear f3-2f)
(clear f3-3f)
(clear f4-0f)
(clear f4-1f)
(clear f4-2f)
(clear f4-3f)
)
)
(:metric minimize (total-cost))
)
gerardcanal commented 3 years ago

Hi Rakhmanu, Can you please use the Metric-FF included in rosplan_planning_system/common/bin to make sure it works with your files?

If so, can you add the raw output of the plan? It should be in your package named "try" and in the file called plan.pddl. You can get the output with: cat $(rospack find task_plan_verbalization)/plan.pddl. The terminal output for the planning process would also be helpful for this.

If it works with the external one but not with the one shipped with rosplan, you can try to modify the planner_command argument of the launch file to point to the executable that works for you.

Also please format the files you added as code (wrapping them with a single line containing ``` -like you did with the launch file- so it's easier to read the code).

rakhmanu commented 3 years ago

Hi @gerardcanal, Can you please use the Metric-FF included in rosplan_planning_system/common/bin to make sure it works with your files? ---> Yes I am using Metric-FF included in rosplan_planning_system/common/bin

The output of the plan is this:

usage of ff:

OPTIONS   DESCRIPTIONS

-p <str>    Path for operator and fact file
-o <str>    Operator file name
-f <str>    Fact file name

-r <int>    Random seed [used for random restarts; preset: 0]

-s <int>    Search configuration [preset: s=5]; '+H': helpful actions pruning
      0     Standard-FF: EHC+H then BFS (cost minimization: NO)
      1     BFS (cost minimization: NO)
      2     BFS+H (cost minimization: NO)
      3     Weighted A* (cost minimization: YES)
      4     A*epsilon (cost minimization: YES)
      5     EHC+H then A*epsilon (cost minimization: YES)
-w <num>    Set weight w for search configs 3,4,5 [preset: w=5]

-C          Do NOT use cost-minimizing relaxed plans for options 3,4,5

-b <float>  Fixed upper bound on solution cost (prune based on g+hmax); active only with cost minimization

Also please format the files you added as code (wrapping them with a single line containing ``` -like you did with the launch file- so it's easier to read the code) ---> Yp, I did it

If it works with the external one but not with the one shipped with rosplan, you can try to modify the planner_command argument of the launch file to point to the executable that works for you. --> Yes I changed exec file, the same result

Thank you

gerardcanal commented 3 years ago

I think I see the issue now. The planner command is not correct. You need to specify the flags correctly. I believe it should be like this (sorry I can't test it at the moment): timeout 10 $(find rosplan_planning_system)/common/bin/Metric-FF -o DOMAIN -f PROBLEM

The planner command line must be the same you use as in the command line, but instead of writing the domain and problem pat you need to change those for the strings DOMAIN and PROBLEM so that ROSPlan can then replace those flags for the correct paths to the domain and generated problem files.

rakhmanu commented 3 years ago

As you suggested @gerardcanal I changed

<include file="$(find rosplan_planning_system)/launch/includes/planner_interface_metricff.launch"> 
    <arg name="use_problem_topic"    value="false" />
    <arg name="planner_topic"        value="planner_output" />
    <arg name="domain_path"          value="$(find try)/common/PDDL/domain.pddl" />
    <arg name="problem_path"         value="$(find try)/common/PDDL/problem.pddl" />
    <arg name="data_path"            value="$(find try)/common/PDDL/" />
    <arg name="planner_command"      value="timeout 10 $(find rosplan_planning_system)/common/bin/Metric-FF -o DOMAIN -f PROBLEM" />
   </include>

It still says that "Plan was unsolvable". But, plan.pddl file is empty now...

m312z commented 3 years ago

Hello both,

I notice that "timeout 10" is in the command line as well - normally to kill a planner running in anytime mode. When you test from the terminal, do you use a timeout and if not does it take more than 10 seconds to find a solution? Perhaps removing this might solve your issue.

Best regards, Michael

rakhmanu commented 3 years ago

Hi again,

Thank you @m312z, yes that was the solution and it works perfectly. Now I am closing the issue.