in habitat_baselines/agents/slam_agents.py [0:0]
def act(self, habitat_observation, random_prob=0.1):
# Update internal state
t = time.time()
cc = 0
update_is_ok = self.update_internal_state(habitat_observation)
while not update_is_ok:
update_is_ok = self.update_internal_state(habitat_observation)
cc += 1
if cc > 2:
break
if self.timing:
print(time.time() - t, " s, update internal state")
self.position_history.append(
self.pose6D.detach().cpu().numpy().reshape(1, 4, 4)
)
success = self.is_goal_reached()
if success:
action = HabitatSimActions.STOP
self.action_history.append(action)
return {"action": action}
# Plan action
t = time.time()
self.planned2Dpath, self.planned_waypoints = self.plan_path()
if self.timing:
print(time.time() - t, " s, Planning")
t = time.time()
# Act
if self.waypointPose6D is None:
self.waypointPose6D = self.get_valid_waypoint_pose6d()
if (
self.is_waypoint_reached(self.waypointPose6D)
or not self.tracking_is_OK
):
self.waypointPose6D = self.get_valid_waypoint_pose6d()
self.waypoint_id += 1
action = self.decide_what_to_do()
# May be random?
random_action = random.randint(0, self.num_actions - 1)
what_to_do = np.random.uniform(0, 1, 1)
if what_to_do < random_prob:
action = random_action
if self.timing:
print(time.time() - t, " s, get action")
self.action_history.append(action)
return {"action": action}