当前位置: 首页>>代码示例>>Java>>正文


Java Alliance.Red方法代码示例

本文整理汇总了Java中edu.wpi.first.wpilibj.DriverStation.Alliance.Red方法的典型用法代码示例。如果您正苦于以下问题:Java Alliance.Red方法的具体用法?Java Alliance.Red怎么用?Java Alliance.Red使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.wpi.first.wpilibj.DriverStation.Alliance的用法示例。


在下文中一共展示了Alliance.Red方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initialize

import edu.wpi.first.wpilibj.DriverStation.Alliance; //导入方法依赖的package包/类
protected void initialize() {
  logger.info("Initialize");

  startAngle = Robot.driveTrain.getYaw();
  
  if (DriverStation.getInstance().getAlliance() == Alliance.Red) {
    targetAngle = DriveTrain.fixDegrees(startAngle + 120);
    clockwise = true;
  } else {
    targetAngle = DriveTrain.fixDegrees(startAngle - 120);
    clockwise = false;
  }
}
 
开发者ID:ligerbots,项目名称:Steamworks2017Robot,代码行数:14,代码来源:FeederBackOutCommand.java

示例2: getAllianceMap

import edu.wpi.first.wpilibj.DriverStation.Alliance; //导入方法依赖的package包/类
/**
 * Gets the current alliance FieldMap.
 * 
 * @return Either red map or blue map
 */
public static FieldMap getAllianceMap() {
  Alliance alliance = DriverStation.getInstance().getAlliance();
  if (alliance == Alliance.Blue) {
    return getBlue();
  } else if (alliance == Alliance.Red) {
    return getRed();
  } else {
    logger.error("Invalid alliance reported by DS!");
    return getBlue();
  }
}
 
开发者ID:ligerbots,项目名称:Steamworks2017Robot,代码行数:17,代码来源:FieldMap.java

示例3: navigateFeederSideLiftToBoiler

import edu.wpi.first.wpilibj.DriverStation.Alliance; //导入方法依赖的package包/类
/**
 * Generates navigation to the boiler from the far side gear lift.
 * @param currentPosition The current robot position
 */
public static DrivePathCommand navigateFeederSideLiftToBoiler(RobotPosition currentPosition) {
  logger.info(String.format("Calculating path, start=%s", currentPosition));
  FieldMap map = getAllianceMap();

  FieldPosition boiler = map.boiler;
  Alliance alliance = DriverStation.getInstance().getAlliance();
  
  
  FieldPosition spline0 = currentPosition.add(alliance == Alliance.Red ? 1 : -1, 0);
  final double clearX = FieldPosition.CLEAR_DIVIDERS_TO_CENTER;
  FieldPosition clearOfDividersPosition =
      new FieldPosition(alliance == Alliance.Red ? -clearX : clearX, currentPosition.y);

  double distanceToBoiler = clearOfDividersPosition.distanceTo(boiler);

  List<FieldPosition> controlPoints = new LinkedList<FieldPosition>();
  controlPoints.add(spline0);
  controlPoints.add(currentPosition);
  controlPoints.add(clearOfDividersPosition);
  
  double ratio = RobotMap.SHOOTING_DISTANCE / distanceToBoiler;
  
  controlPoints.add(clearOfDividersPosition.multiply(1 - ratio).add(boiler.multiply(ratio)));
  
  controlPoints.add(boiler);
  List<FieldPosition> splinePoints = generateCatmullRomSpline(controlPoints);
  DrivePathCommand drivePathCommand = new DrivePathCommand(splinePoints);
  return drivePathCommand;
}
 
开发者ID:ligerbots,项目名称:Steamworks2017Robot,代码行数:34,代码来源:FieldMap.java

示例4: navigateStartToBoiler

import edu.wpi.first.wpilibj.DriverStation.Alliance; //导入方法依赖的package包/类
/**
 * Generates navigation to the boiler from a starting position.
 * @param startingSide The robot starting configuration
 */
public static DrivePathCommand navigateStartToBoiler(FieldSide startingSide) {
  logger.info(String.format("Calculating path, start=%s", startingSide.toString()));
  FieldMap map = getAllianceMap();

  final Alliance alliance = DriverStation.getInstance().getAlliance();
  
  final FieldPosition startingPosition = map.startingPositions[startingSide.id];
  
  List<FieldPosition> controlPoints = new LinkedList<FieldPosition>();
  
  FieldPosition spline0 = startingPosition.add(alliance == Alliance.Red ? -12 : 12, 0);
  controlPoints.add(spline0);
  
  controlPoints.add(startingPosition);
  
  FieldPosition initialForward = startingPosition.add(alliance == Alliance.Red ? 24 : -24, 0);
  controlPoints.add(initialForward);

  if (startingSide != FieldSide.BOILER) {
    FieldPosition closeToAllianceWallPoint =
        new FieldPosition(alliance == Alliance.Red ? -297.545 : 297.545, -66);
    controlPoints.add(closeToAllianceWallPoint);
  }
  
  FieldPosition finalPoint =
      new FieldPosition(alliance == Alliance.Red ? -225.977 : 225.977, -94.018);
  controlPoints.add(finalPoint);
 
  controlPoints.add(new FieldPosition(alliance == Alliance.Red ? -200 : 200, -94.018));
  List<FieldPosition> splinePoints = generateCatmullRomSpline(controlPoints);
  DrivePathCommand drivePathCommand = new DrivePathCommand(splinePoints);
  return drivePathCommand;
}
 
开发者ID:ligerbots,项目名称:Steamworks2017Robot,代码行数:38,代码来源:FieldMap.java

示例5: navigateStartToHopper

import edu.wpi.first.wpilibj.DriverStation.Alliance; //导入方法依赖的package包/类
/**
 * Generates navigation from a starting position to the hopper.
 * @param startingPositionId The starting position ID
 * @return A DriveToPathCommand that drives the generated path
 */
public static DrivePathCommand navigateStartToHopper(int startingPositionId) { 
  FieldMap map = getAllianceMap();
  
  final Alliance alliance = DriverStation.getInstance().getAlliance();

  final FieldPosition hopperPosition =
      alliance == Alliance.Red ? red.hopperBoilerRed : blue.hopperBoilerBlue;

  if (startingPositionId != 0) {
    startingPositionId = 0;
    logger.error("New starting position: " + startingPositionId);
  }
  
  final List<FieldPosition> controlPoints = new LinkedList<FieldPosition>();

  FieldPosition startingPosition = map.startingPositions[startingPositionId];
  logger.debug(String.format("Starting position %s", startingPosition));
  
  // add a point behind us so the C-R spline generates correctly
  controlPoints.add(startingPosition.add(alliance == Alliance.Red ? -12 : 12, 0));

  // drive forward 2 feet
  FieldPosition initialForwardPosition =
      startingPosition.add(alliance == Alliance.Red ? 24 : -24, 0);
  logger.debug(String.format("2ft forward position %s", initialForwardPosition));
  
  controlPoints.add(initialForwardPosition);

  double initialDriveToX;
  double initialDriveToY;
  
  initialDriveToX = alliance == Alliance.Red
      ? hopperPosition.getX() - HOPPER_TRIGGER_WIDTH / 2 - RobotMap.ROBOT_WIDTH / 2 + 2.0
      : hopperPosition.getX() + HOPPER_TRIGGER_WIDTH / 2 + RobotMap.ROBOT_WIDTH / 2 - 2.0;
  initialDriveToY = hopperPosition.getY()
      - (RobotMap.ROBOT_LENGTH - RobotMap.ROBOT_SHOOTER_TO_TURN_CENTER_DIST);
  
  double splinePointX = initialDriveToX;
  double splinePointY = initialDriveToY - 24.0;

  FieldPosition initialDriveToPosition = new FieldPosition(initialDriveToX, initialDriveToY);
  logger.debug(String.format("Drive to position %s", initialDriveToPosition));
  controlPoints.add(initialDriveToPosition);
  
  FieldPosition splinePoint = new FieldPosition(splinePointX, splinePointY);
  logger.debug(String.format("Spline point %s", splinePoint));
  controlPoints.add(splinePoint);
  
  logger.info(controlPoints.toString());
  List<FieldPosition> splinePoints = generateCatmullRomSpline(controlPoints);
  logger.info(splinePoints.toString());
  
  DrivePathCommand drivePathCommand = new DrivePathCommand(splinePoints);
  return drivePathCommand;
}
 
开发者ID:ligerbots,项目名称:Steamworks2017Robot,代码行数:61,代码来源:FieldMap.java


注:本文中的edu.wpi.first.wpilibj.DriverStation.Alliance.Red方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。