コード例 #1
0
 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)
コード例 #2
0
 def __call__(
     self, scene_node: habitat_sim.SceneNode, actuation_spec: SpinSpec
 ):
     # Rotate about the +y (up) axis
     rotation_ax = habitat_sim.geo.LEFT
     scene_node.rotate_local(mn.Deg(actuation_spec.spin_amount), rotation_ax)
     # Calling normalize is needed after rotating to deal with machine precision errors
     scene_node.rotation = scene_node.rotation.normalized()
コード例 #3
0
def _random_tilt_impl(
    scene_node: habitat_sim.SceneNode,
    move_amount: float,
    angle: float,
    noise_amount: float,
):
    scene_node.reset_transformation()
    scene_node.rotate_x_local(scene_node, angle, 0)
コード例 #4
0
ファイル: new_actions.py プロジェクト: przor3n/habitat-sim
    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)
コード例 #5
0
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)
コード例 #6
0
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)
コード例 #7
0
ファイル: new_actions.py プロジェクト: przor3n/habitat-sim
        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()
コード例 #8
0
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()