devendrachaplot / Neural-SLAM

Pytorch code for ICLR-20 Paper "Learning to Explore using Active Neural SLAM"
http://www.cs.cmu.edu/~dchaplot/projects/neural-slam.html
MIT License
757 stars 142 forks source link

Exploration to PointGoal Transfer #4

Closed rpartsey closed 4 years ago

rpartsey commented 4 years ago

Hi dear @devendrachaplot Thank you for open-sourcing your work! I enjoyed reading your paper "Learning To Explore Using Active Neural SLAM". The experiment setup and usage instructions are concise and easy to follow. I was able to run the code without any issues (except import errors fixed here https://github.com/devendrachaplot/Neural-SLAM/issues/1). The environment exploration visualizations generated by pre-trained models look amazing!

I'm struggling with Exploration to PointGoal Transfer. Basically, I understand the idea that the GlobalPolicy should be fixed to output PointGoal coordinates. But I fail to implement this idea in code.

rpartsey commented 4 years ago

I also wonder how you interpret alpha_beta_gamma angles returned by the as_euler_angles function (I mean angle - axis correspondence, which angle corresponds to which axis rotation?) and what is the intuition behind following if statement https://github.com/devendrachaplot/Neural-SLAM/blob/d5bc7886a4fdccae0287b7d0a26bf3800126b563/env/habitat/exploration_env.py#L375

devendrachaplot commented 4 years ago

Hi,

In order to transfer to the pointgoal task, you need to transform the relative pointgoal directions to map coordinates, pass these coordinates to the planner and add a check for stop action.

You will need to do the following:

I might be missing a few things, let me know if the above does not work as expected.

Regarding the other questions, 'st' stands for spatial transformation. 'get_grid' and 'F.affine_grid' functions are used to get the parameters for the spatial transformation. You can check out the paper on spatial transformer networks (https://arxiv.org/pdf/1506.02025.pdf) and the pytorch tutorial (https://pytorch.org/tutorials/intermediate/spatial_transformer_tutorial.html) to get more details.

The 'get_new_pose_batch' function adds the relative pose change to the previous pose to the get the current pose. It computes current pose for a batch of inputs for efficiency.

The 'get_sim_location' function is converting the quaternion pose in the simulator to a single orientation of the agent in the top-down view.

Hope this helps.

rpartsey commented 4 years ago

Thanks a lot! The agent reaches the PointGoal as expected.

I've also added config_env.TASK.SENSORS.append("POINTGOAL_SENSOR") in Neural-SLAM/env/habitat/__init__.py after line 52. https://github.com/devendrachaplot/Neural-SLAM/blob/e833e8f20c5a8d71552a5d22fb78ad6980cfc80c/env/habitat/__init__.py#L52

The only thing that I'd like to clarify is how to properly handle the case when the agent reaches the goal in less than args.max_episode_length.

Currently, after the STOP action is called _episode_over property is set to True and if the step is less than args.max_episode_length, then the next envs.step(l_action) will be called on the finished episode and this results in AssertionError: Episode over, call reset before calling step. https://github.com/devendrachaplot/Neural-SLAM/blob/e833e8f20c5a8d71552a5d22fb78ad6980cfc80c/main.py#L329

devendrachaplot commented 4 years ago

The hacky/easy way of getting rid of this error is just waiting till the max_episode_length in the step function:

You can add the following at L198 in env/habitat/exploration_env.py:

if self._previous_action == 0:
    if self.timestep >= args.max_episode_length:
          done = True
    else:
          done = False
    null_state = np.zeros((3, self.args.frame_height, self.args.frame_width))
    return null_state, 0., done, self.info

The better way, which will require a lot of code change, is to pass is to set done=True when self._previous_action == 0 in step function and then checking which thread has episode finished in main.py (at L371) and resetting map for a thread when it is finished. You will also need to sync this with local steps (because map get shifted between global steps). This should not change the results, it will only help in reducing the runtime.

Some more notes:

rpartsey commented 4 years ago

@devendrachaplot Thank you!