def get_portal_duration(self, portal_instance, is_mirrored, walkstyle, age,
                         gender, species):
     stub_actor = StubActor(1, species=species)
     arb = Arb()
     portal_posture = postures.create_posture(self.posture_end, stub_actor,
                                              GLOBAL_STUB_CONTAINER)
     source_posture = postures.create_posture(self.posture_start,
                                              stub_actor, None)
     portal_posture.append_transition_to_arb(arb,
                                             source_posture,
                                             locked_params={
                                                 ('age', 'x'): age,
                                                 'is_mirrored': is_mirrored
                                             })
     (_, duration, _) = arb.get_timing()
     return duration
Beispiel #2
0
def holster_object(carry_posture, flush_before_sequence=False, sequence=None):
    carry_object = carry_posture.target

    def _set_holster():
        carry_posture.holstered = True
        return True

    import postures.posture_interactions
    carry_nothing_posture = create_posture(postures.posture_interactions.HoldNothing.CARRY_NOTHING_POSTURE_TYPE, carry_posture.sim, None, track=carry_posture.track)

    def holster(timeline):

        def stop_carry(*_, **__):
            idle_arb = animation.arb.Arb()
            carry_nothing_posture.asm.request(carry_nothing_posture._state_name, idle_arb)
            ArbElement(idle_arb).distribute()

        arb_holster = animation.arb.Arb()
        arb_holster.register_event_handler(stop_carry, handler_id=SCRIPT_EVENT_ID_STOP_CARRY)
        carry_posture.asm.context.register_custom_event_handler(functools.partial(hide_held_props, carry_posture.sim), None, 0, allow_stub_creation=True)
        setup_asm_fn_carry = _get_holstering_setup_asm_func(carry_posture, carry_object)
        setup_asm_fn_carry(carry_posture.asm)
        carry_posture.asm.request(carry_posture._exit_state_name, arb_holster)
        carry_nothing_posture.setup_asm_posture(carry_nothing_posture.asm, carry_nothing_posture.sim, None)
        setup_asm_fn_carry_nothing = _get_holstering_setup_asm_func(carry_nothing_posture, carry_object)
        setup_asm_fn_carry_nothing(carry_nothing_posture.asm)
        carry_nothing_posture.asm.request(carry_nothing_posture._enter_state_name, arb_holster)
        holster_element = create_run_animation(arb_holster)
        if flush_before_sequence:
            holster_element = (holster_element, flush_all_animations)
        yield element_utils.run_child(timeline, holster_element)

    return (lambda _: _set_holster(), build_critical_section(interact_with_carried_object(carry_posture.sim, carry_object, interaction=carry_posture.source_interaction, animation_context=carry_posture.asm.context, must_run=True, sequence=holster), sequence, flush_all_animations))
Beispiel #3
0
 def _get_default_carry_aspect(track):
     if track in carry_posture_overrides:
         return carry_posture_overrides[track]
     return postures.create_posture(
         CarryPostureStaticTuning.POSTURE_CARRY_NOTHING,
         sim,
         None,
         track=track)
def holster_object(carry_posture, flush_before_sequence=False, sequence=None):
    carry_object = carry_posture.target

    def _set_holster():
        carry_posture.holstered = True
        return True

    import postures.posture_interactions
    carry_nothing_posture = create_posture(
        postures.posture_interactions.HoldNothing.CARRY_NOTHING_POSTURE_TYPE,
        carry_posture.sim,
        None,
        track=carry_posture.track)

    def holster(timeline):
        def stop_carry(*_, **__):
            idle_arb = animation.arb.Arb()
            carry_nothing_posture.asm.request(
                carry_nothing_posture._state_name, idle_arb)
            ArbElement(idle_arb).distribute()

        arb_holster = animation.arb.Arb()
        arb_holster.register_event_handler(
            stop_carry, handler_id=SCRIPT_EVENT_ID_STOP_CARRY)
        carry_posture.asm.context.register_custom_event_handler(
            functools.partial(hide_held_props, carry_posture.sim),
            None,
            0,
            allow_stub_creation=True)
        setup_asm_fn_carry = _get_holstering_setup_asm_func(
            carry_posture, carry_object)
        setup_asm_fn_carry(carry_posture.asm)
        carry_posture.asm.request(carry_posture._exit_state_name, arb_holster)
        carry_nothing_posture.setup_asm_posture(carry_nothing_posture.asm,
                                                carry_nothing_posture.sim,
                                                None)
        setup_asm_fn_carry_nothing = _get_holstering_setup_asm_func(
            carry_nothing_posture, carry_object)
        setup_asm_fn_carry_nothing(carry_nothing_posture.asm)
        carry_nothing_posture.asm.request(
            carry_nothing_posture._enter_state_name, arb_holster)
        holster_element = create_run_animation(arb_holster)
        if flush_before_sequence:
            holster_element = (holster_element, flush_all_animations)
        yield element_utils.run_child(timeline, holster_element)

    return (lambda _: _set_holster(),
            build_critical_section(
                interact_with_carried_object(
                    carry_posture.sim,
                    carry_object,
                    interaction=carry_posture.source_interaction,
                    animation_context=carry_posture.asm.context,
                    must_run=True,
                    sequence=holster), sequence, flush_all_animations))
Beispiel #5
0
def holster_object(carry_posture, flush_before_sequence=False, sequence=None):
    carry_object = carry_posture.target

    def _set_holster():
        carry_posture.holster_count += 1
        return True

    carry_nothing_posture = create_posture(
        CarryPostureStaticTuning.POSTURE_CARRY_NOTHING,
        carry_posture.sim,
        None,
        track=carry_posture.track)

    def holster(timeline):
        if carry_object.is_sim:
            return
        if carry_posture.holster_count > 1:
            return

        def stop_carry(*_, **__):
            idle_arb = animation.arb.Arb()
            carry_nothing_posture.asm.request(
                carry_nothing_posture._state_name, idle_arb)
            distribute_arb_element(idle_arb)

        arb_holster = animation.arb.Arb()
        arb_holster.register_event_handler(
            stop_carry, handler_id=SCRIPT_EVENT_ID_STOP_CARRY)
        carry_posture.asm.context.register_custom_event_handler(
            functools.partial(hide_held_props, carry_posture.sim),
            None,
            0,
            allow_stub_creation=True)
        setup_asm_fn_carry = _get_holstering_setup_asm_func(
            carry_posture, carry_object)
        setup_asm_fn_carry(carry_posture.asm)
        carry_posture.asm.request(carry_posture._exit_state_name, arb_holster)
        result = carry_nothing_posture.setup_asm_posture(
            carry_nothing_posture.asm, carry_nothing_posture.sim, None)
        if not result:
            logger.error('Failed to setup asm to holster {}. {} ',
                         carry_object,
                         result,
                         owner='rmccord')
        setup_asm_fn_carry_nothing = _get_holstering_setup_asm_func(
            carry_nothing_posture, carry_object)
        setup_asm_fn_carry_nothing(carry_nothing_posture.asm)
        carry_nothing_posture.asm.request(
            carry_nothing_posture._enter_state_name, arb_holster)
        holster_element = create_run_animation(arb_holster)
        if flush_before_sequence:
            holster_element = (holster_element, flush_all_animations)
        yield from element_utils.run_child(timeline, holster_element)

    return (lambda _: _set_holster(),
            build_critical_section(
                interact_with_carried_object(
                    carry_posture.sim,
                    carry_object,
                    interaction=carry_posture.source_interaction,
                    animation_context=carry_posture.asm.context,
                    must_run=True,
                    sequence=holster), sequence, flush_all_animations))
Beispiel #6
0
    def __init__(self,
                 sim,
                 current_posture_state,
                 posture_spec,
                 var_map,
                 invalid_expected=False,
                 body_state_spec_only=False,
                 carry_posture_overrides=frozendict(),
                 is_throwaway=False):
        def _get_default_carry_aspect(track):
            if track in carry_posture_overrides:
                return carry_posture_overrides[track]
            return postures.create_posture(
                CarryPostureStaticTuning.POSTURE_CARRY_NOTHING,
                sim,
                None,
                track=track)

        self._constraint_intersection = None
        self._constraint_intersection_dirty = True
        self._spec = posture_spec
        self._sim_ref = sim.ref()
        self._linked_posture_state = None
        self._valid = True
        self._constraints = {}
        self._invalid_expected = invalid_expected
        self.body_state_spec_only = body_state_spec_only
        self._posture_constraint = None
        self._posture_constraint_strict = None
        body_index = BODY_INDEX
        body_posture_type_index = BODY_POSTURE_TYPE_INDEX
        body_target_index = BODY_TARGET_INDEX
        spec_body = posture_spec[body_index]
        self.body_target = spec_body[body_target_index]
        if current_posture_state is None or spec_body[
                body_posture_type_index] != current_posture_state.body.posture_type or spec_body[
                    body_target_index] != current_posture_state.body.target:
            animation_context = None
            if current_posture_state is not None:
                if not current_posture_state.body.mobile:
                    if not spec_body[body_posture_type_index].mobile:
                        animation_context = current_posture_state.body.animation_context
            self._aspect_body = postures.create_posture(
                spec_body[body_posture_type_index],
                self.sim,
                self.body_target,
                animation_context=animation_context,
                is_throwaway=is_throwaway)
        else:
            self._aspect_body = current_posture_state.body
        posture_manifest = self._aspect_body.get_provided_postures(
            surface_target=self.surface_target, concrete=True)
        posture_manifest = posture_manifest.get_constraint_version(self.sim)
        posture_state_spec = PostureStateSpec(
            posture_manifest, SlotManifest(), self._aspect_body.target
            or PostureSpecVariable.ANYTHING)
        self.body_posture_state_constraint = Constraint(
            debug_name='PostureStateManifestConstraint',
            posture_state_spec=posture_state_spec)
        if body_state_spec_only:
            self._constraints[None] = self.body_posture_state_constraint
            return
        body_slot_constraint = self._aspect_body.slot_constraint
        if not (body_slot_constraint is not None and
                (self._aspect_body.is_vehicle and current_posture_state
                 is not None) and current_posture_state.body.is_vehicle):
            body_posture_constraint = self.body_posture_state_constraint.intersect(
                body_slot_constraint)
        else:
            body_posture_constraint = self.body_posture_state_constraint
        self._constraints[None] = body_posture_constraint
        if current_posture_state is not None:
            curr_spec_carry_target = current_posture_state.get_posture_spec(
                var_map)[CARRY_INDEX][CARRY_TARGET_INDEX]
        spec_carry = posture_spec[CARRY_INDEX]
        spec_carry_target = spec_carry[CARRY_TARGET_INDEX]
        if current_posture_state is not None and spec_carry_target != curr_spec_carry_target:
            if spec_carry_target is None:
                current_carry_target = var_map.get(curr_spec_carry_target)
                current_carry_track = current_posture_state.get_carry_track(
                    current_carry_target)
                if current_carry_track == PostureTrack.RIGHT:
                    self._aspect_carry_right = _get_default_carry_aspect(
                        PostureTrack.RIGHT)
                    self._aspect_carry_left = current_posture_state.left
                else:
                    self._aspect_carry_left = _get_default_carry_aspect(
                        PostureTrack.LEFT)
                    self._aspect_carry_right = current_posture_state.right
            else:
                spec_carry_posture_type = spec_carry[CARRY_POSTURE_TYPE_INDEX]
                if spec_carry_target not in var_map:
                    raise KeyError(
                        'spec_carry_target {} not in var_map:{}. Sim posture state {} and carry aspects {}, '
                        .format(spec_carry_target, var_map,
                                current_posture_state,
                                current_posture_state.carry_aspects))
                if spec_carry_posture_type not in var_map:
                    carry_target = var_map[spec_carry_target]
                    aop = posture_specs.get_carry_posture_aop(
                        sim, carry_target)
                    if aop is None:
                        raise RuntimeError(
                            'Sim {} failed to find carry posture aop for carry target {}.'
                            .format(sim, carry_target))
                    carry_posture_type = aop.affordance._carry_posture_type
                    if carry_posture_type is None:
                        raise KeyError
                    var_map += {
                        PostureSpecVariable.POSTURE_TYPE_CARRY_OBJECT:
                        carry_posture_type
                    }
                carry_target = var_map[spec_carry_target]
                carry_posture_type = var_map[spec_carry_posture_type]
                if spec_carry[CARRY_HAND_INDEX] in var_map:
                    hand = var_map[spec_carry[CARRY_HAND_INDEX]]
                else:
                    for hand in sim.posture_state.get_free_hands():
                        if hand in carry_target.get_allowed_hands(sim):
                            break
                    else:
                        raise RuntimeError('No allowable free hand was empty.')
                new_carry_aspect = postures.create_posture(
                    carry_posture_type,
                    self.sim,
                    carry_target,
                    track=hand_to_track(hand),
                    is_throwaway=is_throwaway)
                if hand == Hand.LEFT:
                    self._aspect_carry_left = new_carry_aspect
                    if current_posture_state is not None:
                        self._aspect_carry_right = current_posture_state.right
                    else:
                        self._aspect_carry_right = _get_default_carry_aspect(
                            PostureTrack.RIGHT)
                elif hand == Hand.RIGHT:
                    self._aspect_carry_right = new_carry_aspect
                    if current_posture_state is not None:
                        self._aspect_carry_left = current_posture_state.left
                    else:
                        self._aspect_carry_right = _get_default_carry_aspect(
                            PostureTrack.LEFT)
                else:
                    raise RuntimeError(
                        'Invalid value specified for hand: {}'.format(hand))
        elif current_posture_state is not None:
            self._aspect_carry_left = current_posture_state.left
            self._aspect_carry_right = current_posture_state.right
        elif spec_carry_target is not None:
            carry_target = var_map[spec_carry_target]
            spec_carry_posture_type = spec_carry[CARRY_POSTURE_TYPE_INDEX]
            carry_posture_type = var_map.get(spec_carry_posture_type)
            if carry_posture_type is None:
                aop = get_carry_posture_aop(sim, carry_target)
                if aop is None and invalid_expected:
                    return
                carry_posture_type = aop.affordance._carry_posture_type
            if spec_carry[CARRY_HAND_INDEX] in var_map:
                hand = var_map[spec_carry[CARRY_HAND_INDEX]]
            else:
                allowed_hands = carry_target.get_allowed_hands(sim)
                hand = allowed_hands[0]
            new_carry_aspect = postures.create_posture(
                carry_posture_type,
                self.sim,
                carry_target,
                track=hand_to_track(hand),
                is_throwaway=is_throwaway)
            if hand == Hand.LEFT:
                self._aspect_carry_left = new_carry_aspect
                self._aspect_carry_right = _get_default_carry_aspect(
                    PostureTrack.RIGHT)
            else:
                self._aspect_carry_right = new_carry_aspect
                self._aspect_carry_left = _get_default_carry_aspect(
                    PostureTrack.LEFT)
        else:
            self._aspect_carry_left = _get_default_carry_aspect(
                PostureTrack.LEFT)
            self._aspect_carry_right = _get_default_carry_aspect(
                PostureTrack.RIGHT)
    def __call__(self, obj, posture, routing_surface_start,
                 routing_surface_end, species_overrides):
        species_portals = []

        def get_outer_portal_goal(slot_constraint, stub_actor, entry,
                                  routing_surface):
            handles = slot_constraint.get_connectivity_handles(
                stub_actor,
                entry=entry,
                routing_surface_override=routing_surface)
            if not handles:
                slot_constraint.get_connectivity_handles(
                    stub_actor,
                    entry=entry,
                    routing_surface_override=routing_surface,
                    log_none_slots_to_params_as_error=True)
                logger.error(
                    'PosturePortal: Species {} has no entry boundary conditions for portal posture',
                    species)
                return
            species_param = SpeciesExtended.get_animation_species_param(
                stub_actor.species)
            for handle in handles:
                handle_species_param = handle.locked_params.get(
                    ('species', 'x'))
                if handle_species_param is None:
                    break
                if handle_species_param == species_param:
                    break
            else:
                return
            return next(iter(handle.get_goals()), None)

        posture_species = posture.get_animation_species()
        for species in species_overrides:
            if species == SpeciesExtended.INVALID:
                continue
            if SpeciesExtended.get_species(species) not in posture_species:
                continue
            stub_actor = get_global_stub_actor(species)
            portal_posture = postures.create_posture(posture,
                                                     stub_actor,
                                                     obj,
                                                     is_throwaway=True)
            slot_constraint = portal_posture.slot_constraint
            containment_constraint = next(iter(slot_constraint))
            there_start = get_outer_portal_goal(
                slot_constraint,
                stub_actor,
                entry=True,
                routing_surface=routing_surface_start)
            if there_start is None:
                continue
            there_end = containment_constraint.containment_transform
            there_entry = Location(there_start.position,
                                   orientation=there_start.orientation,
                                   routing_surface=routing_surface_start)
            there_exit = Location(there_end.translation,
                                  orientation=there_end.orientation,
                                  routing_surface=routing_surface_end)
            back_entry = None
            back_exit = None
            if self.bidirectional:
                back_start = containment_constraint.containment_transform_exit
                back_end = get_outer_portal_goal(
                    slot_constraint,
                    stub_actor,
                    entry=False,
                    routing_surface=routing_surface_start)
                if back_end is None:
                    continue
                back_entry = Location(back_start.translation,
                                      orientation=back_start.orientation,
                                      routing_surface=routing_surface_end)
                back_exit = Location(back_end.position,
                                     orientation=back_end.orientation,
                                     routing_surface=routing_surface_start)
            species_portals.append(
                (there_entry, there_exit, back_entry, back_exit,
                 SpeciesExtended.get_portal_flag(species)))
        return species_portals
 def __init__(self, sim, current_posture_state, posture_spec, var_map, invalid_expected=False, body_state_spec_only=False):
     self._constraint_intersection = None
     self._constraint_intersection_dirty = True
     self._spec = posture_spec
     self._sim_ref = sim.ref()
     self._linked_posture_state = None
     self._valid = True
     self._constraints = {}
     self._invalid_expected = invalid_expected
     self.body_state_spec_only = body_state_spec_only
     self._posture_constraint = None
     self._posture_constraint_strict = None
     body_index = BODY_INDEX
     body_posture_type_index = BODY_POSTURE_TYPE_INDEX
     body_target_index = BODY_TARGET_INDEX
     spec_body = posture_spec[body_index]
     self.body_target = spec_body[body_target_index]
     if current_posture_state is None or spec_body[body_posture_type_index] != current_posture_state.body.posture_type or spec_body[body_target_index] != current_posture_state.body.target:
         animation_context = None
         if current_posture_state is not None and not current_posture_state.body.mobile and not spec_body[body_posture_type_index].mobile:
             animation_context = current_posture_state.body.animation_context
         self._aspect_body = postures.create_posture(spec_body[body_posture_type_index], self.sim, self.body_target, animation_context=animation_context)
     else:
         self._aspect_body = current_posture_state.body
     posture_manifest = self._aspect_body.get_provided_postures(surface_target=self.surface_target, concrete=True)
     posture_manifest = posture_manifest.get_constraint_version(self.sim)
     posture_state_spec = PostureStateSpec(posture_manifest, SlotManifest(), self._aspect_body.target or PostureSpecVariable.ANYTHING)
     self.body_posture_state_constraint = Constraint(debug_name='PostureStateManifestConstraint', posture_state_spec=posture_state_spec)
     if body_state_spec_only:
         self._constraints[self] = self.body_posture_state_constraint
         return
     body_slot_constraint = self._aspect_body.slot_constraint
     if body_slot_constraint is not None:
         body_posture_constraint = self.body_posture_state_constraint.intersect(body_slot_constraint)
     else:
         body_posture_constraint = self.body_posture_state_constraint
     self._constraints[self] = body_posture_constraint
     if current_posture_state is not None:
         curr_spec_carry_target = current_posture_state.get_posture_spec(var_map)[CARRY_INDEX][CARRY_TARGET_INDEX]
     spec_carry = posture_spec[CARRY_INDEX]
     spec_carry_target = spec_carry[CARRY_TARGET_INDEX]
     if current_posture_state is not None and spec_carry_target != curr_spec_carry_target:
         if spec_carry_target is None:
             current_carry_target = var_map.get(curr_spec_carry_target)
             current_carry_track = current_posture_state.get_carry_track(current_carry_target)
             if current_carry_track == PostureTrack.RIGHT:
                 self._aspect_carry_right = self._get_default_carry_aspect(PostureTrack.RIGHT)
                 self._aspect_carry_left = current_posture_state.left
             else:
                 self._aspect_carry_left = self._get_default_carry_aspect(PostureTrack.LEFT)
                 self._aspect_carry_right = current_posture_state.right
                 spec_carry_posture_type = spec_carry[CARRY_POSTURE_TYPE_INDEX]
                 if spec_carry_target not in var_map:
                     raise KeyError
                 if spec_carry_posture_type not in var_map:
                     aop = posture_specs.get_carry_posture_aop(sim, var_map[spec_carry_target])
                     carry_posture_type = aop.affordance._carry_posture_type
                     if carry_posture_type is None:
                         raise KeyError
                     var_map += {PostureSpecVariable.POSTURE_TYPE_CARRY_OBJECT: carry_posture_type}
                 carry_target = var_map[spec_carry_target]
                 carry_posture_type = var_map[spec_carry_posture_type]
                 if spec_carry[CARRY_HAND_INDEX] in var_map:
                     hand = var_map[spec_carry[CARRY_HAND_INDEX]]
                 else:
                     for hand in sim.posture_state.get_free_hands():
                         while hand in carry_target.allowed_hands:
                             break
                     raise RuntimeError('No allowable free hand was empty.')
                 new_carry_aspect = postures.create_posture(carry_posture_type, self.sim, carry_target, track=self.hand_to_track(hand))
                 if hand == Hand.LEFT:
                     self._aspect_carry_left = new_carry_aspect
                     if current_posture_state is not None:
                         self._aspect_carry_right = current_posture_state.right
                     else:
                         self._aspect_carry_right = self._get_default_carry_aspect(PostureTrack.RIGHT)
                         if hand == Hand.RIGHT:
                             self._aspect_carry_right = new_carry_aspect
                             if current_posture_state is not None:
                                 self._aspect_carry_left = current_posture_state.left
                             else:
                                 self._aspect_carry_right = self._get_default_carry_aspect(PostureTrack.LEFT)
                                 raise RuntimeError('Invalid value specified for hand: {}'.format(hand))
                         else:
                             raise RuntimeError('Invalid value specified for hand: {}'.format(hand))
                 elif hand == Hand.RIGHT:
                     self._aspect_carry_right = new_carry_aspect
                     if current_posture_state is not None:
                         self._aspect_carry_left = current_posture_state.left
                     else:
                         self._aspect_carry_right = self._get_default_carry_aspect(PostureTrack.LEFT)
                         raise RuntimeError('Invalid value specified for hand: {}'.format(hand))
                 else:
                     raise RuntimeError('Invalid value specified for hand: {}'.format(hand))
         else:
             spec_carry_posture_type = spec_carry[CARRY_POSTURE_TYPE_INDEX]
             if spec_carry_target not in var_map:
                 raise KeyError
             if spec_carry_posture_type not in var_map:
                 aop = posture_specs.get_carry_posture_aop(sim, var_map[spec_carry_target])
                 carry_posture_type = aop.affordance._carry_posture_type
                 if carry_posture_type is None:
                     raise KeyError
                 var_map += {PostureSpecVariable.POSTURE_TYPE_CARRY_OBJECT: carry_posture_type}
             carry_target = var_map[spec_carry_target]
             carry_posture_type = var_map[spec_carry_posture_type]
             if spec_carry[CARRY_HAND_INDEX] in var_map:
                 hand = var_map[spec_carry[CARRY_HAND_INDEX]]
             else:
                 for hand in sim.posture_state.get_free_hands():
                     while hand in carry_target.allowed_hands:
                         break
                 raise RuntimeError('No allowable free hand was empty.')
             new_carry_aspect = postures.create_posture(carry_posture_type, self.sim, carry_target, track=self.hand_to_track(hand))
             if hand == Hand.LEFT:
                 self._aspect_carry_left = new_carry_aspect
                 if current_posture_state is not None:
                     self._aspect_carry_right = current_posture_state.right
                 else:
                     self._aspect_carry_right = self._get_default_carry_aspect(PostureTrack.RIGHT)
                     if hand == Hand.RIGHT:
                         self._aspect_carry_right = new_carry_aspect
                         if current_posture_state is not None:
                             self._aspect_carry_left = current_posture_state.left
                         else:
                             self._aspect_carry_right = self._get_default_carry_aspect(PostureTrack.LEFT)
                             raise RuntimeError('Invalid value specified for hand: {}'.format(hand))
                     else:
                         raise RuntimeError('Invalid value specified for hand: {}'.format(hand))
             elif hand == Hand.RIGHT:
                 self._aspect_carry_right = new_carry_aspect
                 if current_posture_state is not None:
                     self._aspect_carry_left = current_posture_state.left
                 else:
                     self._aspect_carry_right = self._get_default_carry_aspect(PostureTrack.LEFT)
                     raise RuntimeError('Invalid value specified for hand: {}'.format(hand))
             else:
                 raise RuntimeError('Invalid value specified for hand: {}'.format(hand))
     elif current_posture_state is not None:
         self._aspect_carry_left = current_posture_state.left
         self._aspect_carry_right = current_posture_state.right
     elif spec_carry_target is not None:
         carry_target = var_map[spec_carry_target]
         spec_carry_posture_type = spec_carry[CARRY_POSTURE_TYPE_INDEX]
         carry_posture_type = var_map.get(spec_carry_posture_type)
         if carry_posture_type is None:
             aop = get_carry_posture_aop(sim, carry_target)
             if aop is None and invalid_expected:
                 return
             carry_posture_type = aop.affordance._carry_posture_type
         if spec_carry[CARRY_HAND_INDEX] in var_map:
             hand = var_map[spec_carry[CARRY_HAND_INDEX]]
         else:
             hand = carry_target.allowed_hands[0]
         new_carry_aspect = postures.create_posture(carry_posture_type, self.sim, carry_target, track=self.hand_to_track(hand))
         if hand == Hand.LEFT:
             self._aspect_carry_left = new_carry_aspect
             self._aspect_carry_right = self._get_default_carry_aspect(PostureTrack.RIGHT)
         else:
             self._aspect_carry_right = new_carry_aspect
             self._aspect_carry_left = self._get_default_carry_aspect(PostureTrack.LEFT)
     else:
         self._aspect_carry_left = self._get_default_carry_aspect(PostureTrack.LEFT)
         self._aspect_carry_right = self._get_default_carry_aspect(PostureTrack.RIGHT)
 def _get_default_carry_aspect(self, track):
     return postures.create_posture(HoldNothing.CARRY_NOTHING_POSTURE_TYPE, self.sim, None, track=track)