ROSPlan
ROSPlan copied to clipboard
WIP: Remove harcoded path in TFDPlannerInterface
This change is needed due to the removal of rosplan_demos and a workaround that the original author had set in the file.
Looks sensible - just going to test on my machine.
Hello, I will take a look into it. What I did as a workaround was to modify tfd plan.py to remove the relative paths, here is how it looks like:
#! /usr/bin/env python
import subprocess
import sys
import shutil
# to resolve the path to translate.py, preprocess and search
import rospkg
import os
def main():
def run(*args, **kwargs):
input = kwargs.pop('input', None)
output = kwargs.pop('output', None)
assert not kwargs
redirections = {}
if input:
redirections['stdin'] = open(input)
if output:
redirections['stdout'] = open(output, 'w')
print args, redirections
subprocess.check_call(sum([arg.split('+') for arg in args],[]), **redirections)
config, domain, problem, result_name = sys.argv[1:]
# get an instance of RosPack with the default search paths
rospack = rospkg.RosPack()
# get the path to tfd_example ros pkg
base_path = rospack.get_path('tfd_example') + '/common/tfd-src-0.4/downward/'
# run translator
run(base_path + 'translate/translate.py', domain, problem)
# run preprocessing
sas_path = os.environ['HOME'] + '/.ros/output.sas'
run(base_path + 'preprocess/preprocess', input=sas_path)
# run search
search_path = os.environ['HOME'] + '/.ros/output'
run(base_path + 'search/search', config, 'p', result_name, input=search_path)
if __name__ == '__main__':
main()
This solution was shared in google groups, I will take a look and see if this can be done in a nicer way and without modifying the original script.
I made some changes and need some intermediate feedback, this is to check if I am going in the right direction. If so, I can adapt the other planner interfaces to this strategy. With this changes the tfd planner command would look like this:
<arg name="planner_command" default="timeout 10 $(arg planner_path)/plan DOMAIN PROBLEM plan.pddl" />