Пример #1
0
    def get_validation_status(self, world) -> ValidationStatus:
        """Checks if the ball speed is at or above some threshold

        :param world: The world msg to validate
        :returns: FAILING if the ball speed is below some threshold
                  PASSING if the ball speed is at or above some threshold
        """
        if (tbots.createVector(
                world.ball.current_state.global_velocity).length() >=
                self.speed_threshold):
            return ValidationStatus.PASSING

        return ValidationStatus.FAILING

    def get_validation_geometry(self, world) -> ValidationGeometry:
        """override"""
        # TODO (#2556): visualize
        return create_validation_geometry([])

    def __repr__(self):
        return "Check that the ball speed is at or above above " + str(
            self.speed_threshold)


(
    BallSpeedEventuallyAtOrAboveThreshold,
    BallSpeedEventuallyBelowThreshold,
    BallSpeedAlwaysAtOrAboveThreshold,
    BallSpeedAlwaysBelowThreshold,
) = create_validation_types(BallSpeedThreshold)
Пример #2
0
        for robot in world.friendly_team.team_robots:
            if not tbots.Robot(robot).isNearDribbler(ball_position, 0.01):
                # if ball is not near dribbler then de-activate this validation
                self.continous_dribbling_start_point = None
            elif (ball_position - (self.continous_dribbling_start_point
                                   or ball_position)).length() > 1.0:
                return ValidationStatus.FAILING
            elif self.continous_dribbling_start_point is None:
                # ball is in dribbler, but previously wasn't in dribbler, so set continuous dribbling start point
                self.continous_dribbling_start_point = ball_position
        return ValidationStatus.PASSING

    def get_validation_geometry(self, world) -> ValidationGeometry:
        """
        (override) Shows the max allowed dribbling circle
        """
        return create_validation_geometry(
            [tbots.Circle(self.continous_dribbling_start_point, 1.0)] if self.
            continous_dribbling_start_point is not None else [])

    def __repr__(self):
        return "Check that the dribbling robot has not dribbled for more than 1m"


(
    EventuallyStopExcessivelyDribbling,
    EventuallyStartsExcessivelyDribbling,
    NeverExcessivelyDribbles,
    AlwaysExcessivelyDribbles,
) = create_validation_types(ExcessivelyDribbling)
Пример #3
0
        """
        for region in self.regions:
            if geom.contains(
                region, geom.createPoint(world.ball.current_state.global_position)
            ):
                return ValidationStatus.PASSING

        return ValidationStatus.FAILING

    def get_validation_geometry(self, world) -> ValidationGeometry:
        """Returns the underlying geometry this validation is checking

        :param world: The world msg to create v alidation geometry from
        :returns: ValidationGeometry containing geometry to visualize

        """
        return create_validation_geometry(self.regions)

    def __repr__(self):
        return "Checking ball in regions " + ",".join(
            repr(region) for region in self.regions
        )


(
    BallEventuallyEntersRegion,
    BallEventuallyExitsRegion,
    BallStaysInRegion,
    BallNeverEntersRegion,
) = create_validation_types(BallEntersRegion)
Пример #4
0
        :param world: The world msg to validate
        :returns: FAILING if the friendly robots' speed is below some threshold
                  PASSING if the friendly robots' speed is at or above some threshold
        """
        for robot in world.friendly_team.team_robots:
            if (
                tbots.createVector(robot.current_state.global_velocity).length()
                < self.speed_threshold
            ):
                return ValidationStatus.FAILING
        return ValidationStatus.PASSING

    def get_validation_geometry(self, world) -> ValidationGeometry:
        """override"""
        # TODO (#2556): visualize
        return create_validation_geometry([])

    def __repr__(self):
        return "Check that the friendly robots' speed is at or above above " + str(
            self.speed_threshold
        )


(
    RobotSpeedEventuallyAtOrAboveThreshold,
    RobotSpeedEventuallyBelowThreshold,
    RobotSpeedAlwaysAtOrAboveThreshold,
    RobotSpeedAlwaysBelowThreshold,
) = create_validation_types(RobotSpeedThreshold)
Пример #5
0
        :param world: The world msg to validate
        :returns: FAILING when no friendly robot has possession of the ball
                  PASSING when any friendly robot has possession of the ball
        """
        ball_position = tbots.createPoint(
            world.ball.current_state.global_position)
        for robot in world.friendly_team.team_robots:
            if tbots.Robot(robot).isNearDribbler(ball_position, 0.01):
                return ValidationStatus.PASSING
        return ValidationStatus.FAILING

    def get_validation_geometry(self, world) -> ValidationGeometry:
        """
        (override) highlights the dribbler area of the robots
        """
        return create_validation_geometry([
            tbots.Robot(robot).dribblerArea()
            for robot in world.friendly_team.team_robots
        ])

    def __repr__(self):
        return "Check that the friendly team has possession of the ball"


(
    FriendlyEventuallyHasBallPossession,
    FriendlyEventuallyLosesBallPossession,
    FriendlyAlwaysHasBallPossession,
    FriendlyNeverHasBallPossession,
) = create_validation_types(FriendlyHasBallPossession)
        self.last_ball_position = current_ball_position
        return validation_status

    def get_validation_geometry(self, world) -> ValidationGeometry:
        """
        (override) Shows the last ball position line
        """
        return create_validation_geometry([
            tbots.Rectangle(
                tbots.Point(
                    self.last_ball_position.x(),
                    tbots.Field(world.field).fieldBoundary().yMin(),
                ),
                tbots.Point(
                    self.last_ball_position.x() + 0.01,
                    tbots.Field(world.field).fieldBoundary().yMax(),
                ),
            )
        ])

    def __repr__(self):
        return "Check that the ball moves forward"


(
    BallEventuallyMovesForward,
    BallEventuallyStopsMovingForward,
    BallAlwaysMovesForward,
    BallNeverMovesForward,
) = create_validation_types(BallMovesForward)
Пример #7
0
        for region in self.regions:
            for robot in world.friendly_team.team_robots:
                if tbots_geom.contains(
                    region, tbots_geom.createPoint(robot.current_state.global_position)
                ):
                    return ValidationStatus.PASSING

        return ValidationStatus.FAILING

    def get_validation_geometry(self, world) -> ValidationGeometry:
        """Returns the underlying geometry this validation is checking

        :param world: The world msg to create validation geometry from
        :returns: ValidationGeometry containing geometry to visualize

        """
        return create_validation_geometry(self.regions)

    def __repr__(self):
        return "Check for robot in regions " + ",".join(
            repr(region) for region in self.regions
        )


(
    RobotEventuallyEntersRegion,
    RobotEventuallyExitsRegion,
    RobotStaysInRegion,
    RobotNeverEntersRegion,
) = create_validation_types(RobotEntersRegion)