Skip to content

Commit

Permalink
Merge pull request #104 from k-okada/test_103
Browse files Browse the repository at this point in the history
test to cehck #103 (planner_option without &quat;)
  • Loading branch information
k-okada authored Dec 5, 2023
2 parents b6a94a5 + c40d2f5 commit 1344a89
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pddl/pddl_planner/src/pddl.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import signal
import subprocess as sp
import sys
import shlex
import tempfile
import traceback

Expand Down Expand Up @@ -46,7 +47,11 @@ def __init__(self, name):
# resolve rosparam
self._planner_name = rospy.get_param('~pddl_planner', 'downward')
search_option = rospy.get_param('~pddl_search_option', '')
self._search_option = search_option.strip().split()
# https://stackoverflow.com/questions/79968/split-a-string-by-spaces-preserving-quoted-substrings-in-python
# https://github.com/jsk-ros-pkg/jsk_planning/pull/88 changes 'sp.Popen(command' to 'sp.Popen(" ".join(command)', this assumes `planner_option` uses `--search &quat;iterated([lazy_greedy([hff,hlm], preferred=[hff,hlm]), ...)&quat;`
# but some launch file uses `--search iterated([lazy_greedy([hff,hlm],preferred=[hff,hlm]), ...)`, without &quat; and spaces, and jsk_planning 0.1.13 did not work this such eample(https://github.com/jsk-ros-pkg/jsk_demos/blob/ab0360b5580e77ca70006ce505497894fe4ac0d2/jsk_2013_04_pr2_610/test/test-demo-plan.test#L10), https://github.com/jsk-ros-pkg/jsk_demos/issues/1286
# this fix uses shlex.split() to keep quated substrings and uses Popen(command, stead of Popen(" ".join(command), to input quated argument as one word.
self._search_option = shlex.split(search_option.strip())

self._as.start()

Expand Down Expand Up @@ -150,8 +155,8 @@ def parse_pddl_result_downward(self, path_name):
def exec_process(self, command, max_planning_time):
if max_planning_time > 0.0:
command = ["timeout", str(max_planning_time)] + command
rospy.loginfo("Command: %s" % " ".join(command))
proc = sp.Popen(" ".join(command), stdout=sp.PIPE, stderr=sp.PIPE, shell=True)
rospy.loginfo("Command: %s" % command)
proc = sp.Popen(command, stdout=sp.PIPE, stderr=sp.PIPE)
try:
output, error = str(), str()
r = rospy.Rate(10.0)
Expand Down
9 changes: 9 additions & 0 deletions pddl/pddl_planner/test/test-sample-pddl.test
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,13 @@
<test test-name="sample_pddl_downward_client_long_option" pkg="pddl_planner" type="sample-client.py" >
<remap from="pddl_planner" to="downward_planner_long_option/pddl_planner" />
</test>
<!--
Test for both &quat; and non-spaces https://github.com/jsk-ros-pkg/jsk_planning/pull/103
-->
<include file="$(find pddl_planner)/launch/pddl_downward.launch" ns="downward_planner_long_option_non_spaces" >
<arg name="planner_option" value="--heuristic hlm=lmcount(lm_rhw(reasonable_orders=true,lm_cost_type=2,cost_type=2),pref=true) --heuristic hff=ff() --search iterated([lazy_greedy([hff,hlm],preferred=[hff,hlm]),lazy_wastar([hff,hlm],preferred=[hff,hlm],w=5),lazy_wastar([hff,hlm],preferred=[hff,hlm],w=3),lazy_wastar([hff,hlm],preferred=[hff,hlm],w=2)],repeat_last=false)" />
</include>
<test test-name="sample_pddl_downward_client_long_option_non_spaces" pkg="pddl_planner" type="sample-client.py" >
<remap from="pddl_planner" to="downward_planner_long_option_non_spaces/pddl_planner" />
</test>
</launch>

0 comments on commit 1344a89

Please sign in to comment.