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

A tutorial of using VectorEnv for multiple processes, e.g. the shortest path following example? #60

Closed
eric-xw opened this issue Apr 16, 2019 · 4 comments
Labels
good first issue Good for newcomers

Comments

@eric-xw
Copy link
Contributor

eric-xw commented Apr 16, 2019

Hi,

Can you provide an example of using VectorEnv for shortest path following? similar to this one (https://github.com/facebookresearch/habitat-api/blob/master/examples/shortest_path_follower_example.py) but with multiple processes.

Thanks,
Xin

@eric-xw eric-xw changed the title A shortest path following example of using VectorEnv? A tutorial of using VectorEnv for multiple processes, e.g. the shortest path following example? Apr 16, 2019
@mathfac mathfac added the good first issue Good for newcomers label Jun 14, 2019
@mathfac
Copy link
Contributor

mathfac commented Jun 14, 2019

We don't have such tutorial yet.

dhruvbatra pushed a commit that referenced this issue May 10, 2020
@gianscarpe
Copy link

Hi! Is this still of any interests?

@rpartsey
Copy link
Collaborator

rpartsey commented Aug 31, 2022

Hi @eric-xw @gianscarpe

If you are still interested in using the VectorEnv for shortest path following, this should be pretty easy to implement.

You may define a thin wrapper around of the Env class (let's say, SPFEnv) that should have attributes env (Env instance) and spf (ShortestPathFollower instance). SPFEnv will translate SPFEnv.step(any_action) to Env.step(spf.get_next_action()).

from habitat.tasks.nav.shortest_path_follower import ShortestPathFollower

class SPFEnv(Env):
    def __init__(self, config, goal_radius):
        super().__init__(config)
        self.shortest_path_follower = ShortestPathFollower(
            sim=self.sim,
            goal_radius=goal_radius,
            return_one_hot=False
        )

    def step(self, action):
        best_action = self.shortest_path_follower.get_next_action(
            self.current_episode.goals[0].position
        )
        return super().step(best_action)

Then using VectorEnv you could create as many instances of SPFEnv as you need. For more details on how to use VectorEnv you may check PPOTrainer implementation.

@rpartsey
Copy link
Collaborator

Closing due to inactivity. Feel free to re-open the issue, if you still have questions.

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

No branches or pull requests

4 participants