habitat-lab
habitat-lab copied to clipboard
A tutorial of using VectorEnv for multiple processes, e.g. the shortest path following example?
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
We don't have such tutorial yet.
Hi! Is this still of any interests?
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.
Closing due to inactivity. Feel free to re-open the issue, if you still have questions.