def __call__( self, scene_node: habitat_sim.SceneNode, actuation_spec: MoveSpec ): up_ax = ( np.array(scene_node.absolute_transformation().rotation_scaling()) @ habitat_sim.geo.UP ) scene_node.translate_local(up_ax * actuation_spec.forward_amount)
def _strafe_impl(scene_node: habitat_sim.SceneNode, forward_amount: float, strafe_angle: float): forward_ax = (scene_node.absolute_transformation()[0:3, 0:3] @ habitat_sim.geo.FRONT) rotation = habitat_sim.utils.quat_from_angle_axis( np.deg2rad(strafe_angle), habitat_sim.geo.UP) move_ax = habitat_sim.utils.quat_rotate_vector(rotation, forward_ax) scene_node.translate_local(move_ax * forward_amount)
def __call__(self, scene_node: habitat_sim.SceneNode, actuation_spec: MoveAndSpinSpec): forward_ax = (scene_node.absolute_transformation()[0:3, 0:3] @ habitat_sim.geo.FRONT) scene_node.translate_local(forward_ax * actuation_spec.forward_amount) # Rotate about the +y (up) axis rotation_ax = habitat_sim.geo.UP scene_node.rotate_local(np.deg2rad(actuation_spec.spin_amount), rotation_ax) # Calling normalize is needed after rotating to deal with machine precision errors scene_node.normalize()
def _custom_action_impl( scene_node: habitat_sim.SceneNode, delta_dist: float, # in metres delta_dist_angle: float, # in degrees delta_angle: float # in degrees ): forward_ax = ( np.array(scene_node.absolute_transformation().rotation_scaling()) @ habitat_sim.geo.FRONT) move_angle = np.deg2rad(delta_dist_angle) rotation = habitat_sim.utils.quat_from_angle_axis(move_angle, habitat_sim.geo.UP) move_ax = habitat_sim.utils.quat_rotate_vector(rotation, forward_ax) scene_node.translate_local(move_ax * delta_dist) scene_node.rotate_local(mn.Deg(delta_angle), habitat_sim.geo.UP)
def _strafe_impl( scene_node: habitat_sim.SceneNode, move_amount: float, strafe_angle: float, noise_amount: float, ): forward_ax = ( scene_node.absolute_transformation()[0:3, 0:3] @ habitat_sim.geo.FRONT) strafe_angle = np.deg2rad(strafe_angle) strafe_angle = np.random.uniform((1 - noise_amount) * strafe_angle, (1 + noise_amount) * strafe_angle) rotation = habitat_sim.utils.quat_from_angle_axis(np.deg2rad(strafe_angle), habitat_sim.geo.UP) move_ax = habitat_sim.utils.quat_rotate_vector(rotation, forward_ax) move_amount = np.random.uniform((1 - noise_amount) * move_amount, (1 + noise_amount) * move_amount) scene_node.translate_local(move_ax * move_amount)
def _noisy_move(scene_node: habitat_sim.SceneNode, forward_amount: float, spin_amount: float, noise: bool): forward_ax = ( np.array(scene_node.absolute_transformation().rotation_scaling()) @ habitat_sim.geo.FRONT) forward_noise = np.random.normal(forward_amount, FORWARD_NOISE) if noise else 0 forward = np.clip(forward_amount + forward_noise, np.maximum(forward_amount - FN_CLIP_RATIO * X, 0), forward_amount + FN_CLIP_RATIO * X) scene_node.translate_local(forward_ax * forward) spin_noise = np.random.normal(0, SPIN_NOISE) * 180 / 3.141592 if noise else 0 spin = np.clip(spin_amount + spin_noise, spin_amount - SN_CLIP_RATIO * THETA, spin_amount + SN_CLIP_RATIO * THETA) #print('forward : {}, spin : {}'.format(forward,spin)) # Rotate about the +y (up) axis rotation_ax = habitat_sim.geo.UP scene_node.rotate_local(mn.Deg(spin), rotation_ax) # Calling normalize is needed after rotating to deal with machine precision errors scene_node.rotation = scene_node.rotation.normalized()