Пример #1
0
 def __init__(self, start: TrackPosition, end: TrackPosition):
     """Creates a new instance of LineSegment2D."""
     self.start = start.clone()
     self.end   = end.clone()
Пример #2
0
def position_at_cycle_time(
    cycle_time: float,
    before_position: trackway.TrackPosition,
    after_position: trackway.TrackPosition,
    duty_cycle: float,
    settings: dict,
) -> trackway.TrackPosition:
    """
    During the duty cycle time period for the limb, the position will be
    located at the before position. After the duty cycle, the limb position is
    largely unknown because we have no evidence of the position, or even the
    accelerations and advance, during that period. Therefore, the value
    returned if the midpoint between the before and after positions with a
    large uncertainty value that encompasses the region between the before and
    after positions.

    :param cycle_time:
        A time on the range of [0,1] specific to that limb (no limb phase)
        where the limb will be moving during the range [0, 1.0 - duty_cycle]
        and at rest on the next position during the range (1.0 - duty_cycle, 1).
    :param before_position:
        The position of the limb at the start of the limb time
    :param after_position:
        The position of the limb at the end of the limb time
    :param duty_cycle:
        The duty cycle for the limb
    :param settings:
        The dictionary of configuration settings for the specified trial
    :return:
        A TrackPosition instance representing the position of a track at the
        given time.
    """

    move_time = 1.0 - duty_cycle

    if cycle_time >= move_time:
        pos = after_position.clone()
        pos.annotation = FIXED_ANNOTATION
        return pos

    # The coefficient of uncertainty while the foot is moving
    moving_ambiguity = settings["moving_ambiguity"]

    bp = before_position
    ap = after_position
    progress = max(0.0, min(1.0, cycle_time / move_time))

    if progress < 0.01:
        # This handles cases where the progress is so small that
        # the foot is effectively

        pos = before_position.clone()
        pos.annotation = FIXED_ANNOTATION
        return pos

    return trackway.TrackPosition.from_raw_values(
        x=bp.x.raw + progress * (ap.x.raw - bp.x.raw),
        x_uncertainty=max(ap.x.raw_uncertainty, abs(moving_ambiguity * (ap.x.raw - bp.x.raw))),
        y=bp.y.raw + progress * (ap.y.raw - bp.y.raw),
        y_uncertainty=max(ap.y.raw_uncertainty, abs(moving_ambiguity * (ap.y.raw - bp.y.raw))),
        annotation=MOVING_ANNOTATION,
    )