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

WIP: Remove harcoded path in TFDPlannerInterface #209

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

oscar-lima
Copy link
Collaborator

This change is needed due to the removal of rosplan_demos and a workaround that the original author had set in the file.

@m312z
Copy link
Contributor

m312z commented Aug 1, 2019

Looks sensible - just going to test on my machine.

@m312z m312z self-requested a review August 1, 2019 08:32
Copy link
Contributor

@m312z m312z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The planner interface is not working very well for me - using a straightforward planner command:
"planners/tfd-src-0.4/downward/plan DOMAIN PROBLEM solution.pddl"
I get a few errors instead of a plan:
"./plan.py: No such file or directory"
The main reason being that the working directory of the planner interface is different from the TFD folder. In order to make this planner straightforward to use I would have to add something to the planner command.

Is there a way that the planner interface can be updated to automatically recognise the path of TFD and to handle this for the user?

@oscar-lima
Copy link
Collaborator Author

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.

@oscar-lima
Copy link
Collaborator Author

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" />

@oscar-lima oscar-lima changed the title Remove harcoded path in TFDPlannerInterface WIP: Remove harcoded path in TFDPlannerInterface Aug 9, 2019
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

Successfully merging this pull request may close these issues.

2 participants