From 8c5329ce9f777395b45c2daac135377e629ec148 Mon Sep 17 00:00:00 2001
From: Erik Wijmans <ewijmans2@gmail.com>
Date: Mon, 22 Apr 2019 21:45:34 -0400
Subject: [PATCH] Properly set agent position (#68)

Clean old sensors absolute coordinates when agent's state change.
---
 habitat/sims/habitat_simulator.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/habitat/sims/habitat_simulator.py b/habitat/sims/habitat_simulator.py
index 30c4ca5a4..0a70cee0a 100644
--- a/habitat/sims/habitat_simulator.py
+++ b/habitat/sims/habitat_simulator.py
@@ -420,6 +420,13 @@ class HabitatSim(habitat.Simulator):
         state = self.get_agent_state(agent_id)
         state.position = position
         state.rotation = rotation
+
+        # NB: The agent state also contains the sensor states in _absolute_ coordinates.
+        # In order to set the agent's body to a specific location and have the sensors follow,
+        # we must not provide any state for the sensors.
+        # This will cause them to follow the agent's body
+        state.sensor_states = dict()
+
         agent.set_state(state, reset_sensors)
 
         self._check_agent_position(position, agent_id)
-- 
GitLab