-
Notifications
You must be signed in to change notification settings - Fork 505
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
Removing Habitat v1 style actions and move to v2 style #1251
Removing Habitat v1 style actions and move to v2 style #1251
Conversation
task=self, | ||
is_last_action=is_last_action, | ||
) | ||
return task_action.step( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the time, task_action will return None, but for some legacy reason, it will sometimes return the observations. This is because sim.step(action) returns observations. In order to avoid rendering observations twice, we will use the observations computed in task_action when they are available.
observations: Any = None | ||
if isinstance(action_name, tuple): # there are multiple actions | ||
for i, a_name in enumerate(action_name): | ||
self._step_single_action( | ||
observations, | ||
for a_name in action_name: | ||
observations = self._step_single_action( | ||
a_name, | ||
action, | ||
episode, | ||
i == len(action_name) - 1, | ||
) | ||
else: | ||
self._step_single_action( | ||
observations, action_name, action, episode | ||
observations = self._step_single_action( | ||
action_name, action, episode | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this code, if observations is None, then we will need to get the observations from the simulator and lab sensors. If it is not None, this means the environment was stepped by the action, so we DO NOT call sim.step()
@@ -181,23 +181,6 @@ def register_dataset(cls, to_register=None, *, name: Optional[str] = None): | |||
"dataset", to_register, name, assert_type=Dataset | |||
) | |||
|
|||
@classmethod | |||
def register_action_space_configuration( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We deprecate registering new action spaces for sim. If you want to add new actions, you can directly add them to the action space of lab. YOU CAN NO LONGER create new sim actions. The only sim actions we have will be hardcoded. They are move forward
turn left
and turn right
. We use them for pathfinding and other tools.
self.habitat_config.action_space_config | ||
)(self.habitat_config).get() | ||
|
||
agent_config.action_space = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is where the sim action space is hard coded.
@@ -60,19 +60,14 @@ def reset(self, *args, **kwargs): | |||
super().reset(*args, **kwargs) | |||
self.does_want_terminate = False | |||
|
|||
def step(self, task, *args, is_last_action, **kwargs): | |||
def step(self, task, *args, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting rid of is_last_action
for simplicity.
@@ -591,14 +583,6 @@ def test_noise_models_rgbd(): | |||
"RedwoodDepthNoiseModel" | |||
) | |||
|
|||
config.habitat.simulator.action_space_config = "pyrobotnoisy" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deprecating pyrobotnoisy and its test
) | ||
|
||
self._sim.step_physics(1.0 / 60.0) # type:ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this call? Why is this using a fixed 60Hz? This didn't seem to be here before, why add it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The simulator method always steps physics with a dt of 1/60 (see here)
Before, each action was calling sim.step which is INCREDIBLY INEFFICIENT WHEN THERE ARE MORE THAN ONE ACTION, so instead, the actions now just perform the action and so not step the simulator. The stepping of the simulator happens in EmbodiedTask
. Since there is no action to perform and the simulator just the physics needs to be stepped, we do not call sim.step (since this method takes as input an action that does not exist) but instead, we manually step the physics with sim.step_physics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed this step size should be configured somewhere rather than locked at 60Hz.
True this is the default, but better that it is configured than a magic number.
All the HabitatSim action registration code in |
Thanks, I think I just forgot about those. I removed them now. |
) | ||
|
||
def step(self, action: Dict[str, Any], episode: Episode): | ||
action_name = action["action"] | ||
if "action_args" not in action or action["action_args"] is None: | ||
action["action_args"] = {} | ||
observations: Any = {} | ||
observations: Any = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
observations: Any = None | |
observations: Optional = None |
habitat-lab/habitat/tasks/nav/nav.py
Outdated
for sensor_name in sensor_names: | ||
sensor = self._sim.agents[0]._sensors[sensor_name].node # type: ignore | ||
sensor.rotation = sensor.rotation * mn.Quaternion.rotation( | ||
mn.Rad(np.deg2rad(amount)), mn.Vector3.x_axis() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use Magnum degree to rad here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good to me.
) | ||
|
||
self._sim.step_physics(1.0 / 60.0) # type:ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed this step size should be configured somewhere rather than locked at 60Hz.
True this is the default, but better that it is configured than a magic number.
…rch#1251) * no yet working * movement is working * moving camera * wip * oops * removing action code * Updating the new actions of the examples * removing more code and configurations * changes for bug fixes * not testing sim in lab * changing a few more configs * changing config * new approach * this is not going to work beause of pathfinding * CMD-Z * CMD-Z on configs * fixing tests * COMMAND - ZZZZZZ * simplify * simplify * edit README * readding tests * removing _try_register_rearrange_task` * readding code that I deleted in my previous commit because apparently I cannot read. * addressing comments * addressing Alex comment --------- Co-authored-by: vincentpierre <vincentpierre@users.noreply.github.com>
…rch#1251) * no yet working * movement is working * moving camera * wip * oops * removing action code * Updating the new actions of the examples * removing more code and configurations * changes for bug fixes * not testing sim in lab * changing a few more configs * changing config * new approach * this is not going to work beause of pathfinding * CMD-Z * CMD-Z on configs * fixing tests * COMMAND - ZZZZZZ * simplify * simplify * edit README * readding tests * removing _try_register_rearrange_task` * readding code that I deleted in my previous commit because apparently I cannot read. * addressing comments * addressing Alex comment --------- Co-authored-by: vincentpierre <vincentpierre@users.noreply.github.com>
Motivation and Context
Following up on our discussion last Tuesday, I made this PR that moves SOME of our sim actions to lab.
Basically, I changed the logic so that actions no longer return observations (except when they do) and the actions no longer step the simulation physics (except when they do). They do when the action is implemented in sim (only move forward, turn left and turn right) because otherwise we cannot do pathfinding and others.
Overall the code for adding new actions is cleaner (see examples/new_actions.py ) and the stepping is also simpler. Please have a look.
Why not move all the actions to lab ? We need sim actions for navigation to calculate the number of actions needed to solve a navigation task in the episode generator. Hence, we need the sim actions to be used in the task.
Couldn't you just reimplement the actions in lab the same way they are in sim? Yes, but I would need to make sure the action configuration are the same in sim and lab, which can be problematic since it forces the sim config to know about the navigation action configs.
Why are we trying to change the way actions are used? We are moving towards having the lab actions as a default since they are easier to use, they are the only actions habitat2.0 uses.
How Has This Been Tested
Unit tests pass, plus I used a script to make sure the new actions (like tilt camera) do the same thing.
Types of changes
Checklist