Java 类edu.wpi.first.wpilibj.Servo 实例源码

项目:FRC-2014-robot-project    文件:ShooterControl.java   
ShooterControl(Encoder encoder, SpeedController pullBackSpeedController, double speedControllerMaxRpm,
               DigitalInput limitSwitch, DoubleSolenoid gearControl, Servo latchServo,
               Relay angleControl)
{
    m_latchReleaseServo = latchServo;
    m_currentState = SHOOTER_CONTROL_STATE_WAIT;
    m_encoder = encoder;
    m_pullBackSpeedController = pullBackSpeedController;
    m_angleControl = angleControl;
    m_speedControllerMaxRpm = speedControllerMaxRpm;
    m_limitSwitch = limitSwitch;
    m_pullBackEncoderRpm = new EncoderRPM();
    m_pullBackEncoderRpm.Init(m_pullBackSpeedController, m_encoder, (-1)*m_speedControllerMaxRpm, m_speedControllerMaxRpm, 0.05, 100, m_limitSwitch);
    m_releaseFromMidptEncoderRpm = new EncoderRPM();
    m_releaseFromMidptEncoderRpm.Init(m_pullBackSpeedController, m_encoder,(-1)*m_speedControllerMaxRpm/4,m_speedControllerMaxRpm,0.05, 3);
    m_gearControl = gearControl;
    m_latchReleased = false;
    m_gearReleased = false;
    m_isPulledBack = false;
}
项目:2014_Main_Robot    文件:ServoBallTapper.java   
/**
 * Set the angular position of a servo.
 * 
 * @param angle in degrees (0 - 180) to set the servo to.
 * @param invert clockwise or counterclockwise rotation. Clockwise if false.
 * @param servo the Servo object to set the angle of.
 * @param minAngle the minimum allowable angle for the servo to travel to,
 *   not to be lower than 0.0.
 * @param maxAngle the maximum allowable angle for the servo to travel to,
 *   not to exceed 170.0.
 */
private void setAngle(double angle, boolean invert, Servo servo,
        double minAngle, double maxAngle) {

    //The Servo class has hard coded ranges of travel.
    if(minAngle < 0) {
        minAngle = 0.0;
    }

    if(maxAngle > 170.0){
        maxAngle = 170.0;
    }

    //Get angle in range
    if(angle > maxAngle) {
        angle = maxAngle;
    } else if(angle < minAngle) {
        angle = minAngle;
    }

    if(invert) {
        angle = maxAngle - angle;
    }

    servo.setAngle(angle);
}
项目:Steamworks2017Robot    文件:Stirrer.java   
/**
 * Creates the Stirrer subsystem.
 */
public Stirrer() {
  logger.info("Initialize");

  // HSR-1425CR
  stirrerServo = new Servo(RobotMap.STIRRER_SERVO_CHANNEL);
  // values for the servo we have. http://hitecrcd.com/faqs/servos/general-servos
  stirrerServo.setBounds(2.4, 0, 0, 0, 0.9);
  stirrerServo.setPeriodMultiplier(PeriodMultiplier.k4X);
  setStirrer(RobotMap.STIRRER_SERVO_VALUE_STOP);
}
项目:Steamworks2017Robot    文件:GearManipulator.java   
/**
 * Creates the GearManipulator, and sets servo to closed position.
 */
public GearManipulator() {
  logger.info("Initialize");

  gearServo = new Servo(RobotMap.GEAR_SERVO_CHANNEL);
  gearServo.setBounds(2.4, 0, 0, 0, 0.8);
  gearServo.setPeriodMultiplier(PeriodMultiplier.k4X);

  setPosition(Position.CLOSED);

  lsSpokeDown = new AnalogInput(RobotMap.AI_LS_SPOKE_DOWN);
  lsWedgeDown = new AnalogInput(RobotMap.AI_LS_WEDGE_DOWN);

  pressurePlate = new AnalogInput(RobotMap.AI_PRESSURE_PLATE);
}
项目:Robot_2016    文件:Climber.java   
public static void initialize(){
    climbingWinch = new CANTalon(8); //this value is guessed as of 3/21
    release = new Servo(2); //this value is guessed as of 3/21
    motorLatch = new Servo(3); //this value is guessed as of 3/21
    climbingWinch.changeControlMode(CANTalon.TalonControlMode.PercentVbus);
    climbingWinch.enableBrakeMode(true);
}
项目:snobot-2017    文件:Snobot.java   
/**
 * This function is run when the robot is first started up and should be
 * used for any initialization code.
 */
public void robotInit()
{
    // PWM's
    mTestMotor1 = new Talon(0);
    mTestMotor2 = new Jaguar(1);
    mServo = new Servo(2);

    // Digital IO
    mDigitalOutput = new DigitalOutput(0);
    mRightEncoder = new Encoder(4, 5);
    mLeftEncoder = new Encoder(1, 2);
    mUltrasonic = new Ultrasonic(7, 6);

    // Analog IO
    mAnalogGryo = new AnalogGyro(0);
    mPotentiometer = new AnalogPotentiometer(1);

    // Solenoid
    mSolenoid = new Solenoid(0);

    // Relay
    mRelay = new Relay(0);

    // Joysticks
    mJoystick1 = new Joystick(0);
    mJoystick2 = new XboxController(1);

    // SPI
    mSpiGryo = new ADXRS450_Gyro();

    // Utilities
    mTimer = new Timer();
    mPDP = new PowerDistributionPanel();

    Preferences.getInstance().putDouble("Motor One Speed", .5);
}
项目:Stronghold2016-340    文件:Climber.java   
/**
     * Instantiate latch and sensor
     */
    public Climber() {
        armLatch = new Servo(RobotMap.CLIMBER_LATCH);
        dart = new Talon(4);
//      atBottom = new DigitalInput(RobotMap.ClimberBottomSensor);
        dartLimit = new DigitalInput(RobotMap.CLIMBER_DART_LIMIT);
        winchBanner = new DigitalInput(RobotMap.CLIMBER_BANNER);
    }
项目:Stronghold2016-340    文件:Drive.java   
/**
 * Code for driving robot
 */
public Drive() {
    leftDrive = new Talon(RobotMap.LEFT_DRIVE_TALON);
    rightDrive = new Talon(RobotMap.RIGHT_DRIVE_TALON);
    PTOMotor = new Servo(RobotMap.DRIVE_PTO);
    gyro = new AnalogGyro(0);
}
项目:r2016    文件:CameraSubsystem.java   
public CameraSubsystem(Servo _horizontal, Servo _vertical, Relay _lights) {
    this._horizontal = _horizontal;
    this._vertical = _vertical;
    this._lights = _lights;

    this.setDataKey(CameraSubsystemDataKey.HORIZONTAL_ROTATION_DEGREES, 90.0d);
    this.setDataKey(CameraSubsystemDataKey.VERTICAL_ROTATION_DEGREES, 0.0d);
    this.setDataKey(CameraSubsystemDataKey.LIGHTS, false);
}
项目:turtleshell    文件:TurtlePWMServo.java   
public TurtlePWMServo(int channel, double startingAngle, double degreesPerSec, double maxMovement) {
    servo = new Servo(channel);
    currentAngle = startingAngle;
    degreesPerSecond = degreesPerSec;
    max = maxMovement;
    timer = new Timer();
    servo.setAngle(currentAngle);
    timer.start();
}
项目:FRC-2015-Robot-Java    文件:RobotHardwareWoodbot.java   
public void initialize() 
{
    rearLeftMotor = new Jaguar(0);
    frontLeftMotor = new Jaguar(1);
    liftMotor = new Jaguar(2);
    liftMotor2 = new Jaguar(3);
    liftEncoder = new Encoder(6, 7, false, EncodingType.k4X);

    drivetrain = new RobotDrive(rearLeftMotor, frontLeftMotor); 

    drivetrain.setInvertedMotor(MotorType.kFrontLeft, true);
    drivetrain.setInvertedMotor(MotorType.kFrontRight, true);

    halsensor = new DigitalInput(0);

    horizontalCamera = new Servo(8);
    verticalCamera = new Servo(9);

    solenoid = new DoubleSolenoid(0,1);

    gyro = new Gyro(1);
    accelerometer = new BuiltInAccelerometer();

    liftEncoder.reset();

    RobotHardwareWoodbot hardware = (RobotHardwareWoodbot)Robot.bot;

    LiveWindow.addActuator("Drive Train", "Front Left Motor", (Jaguar)hardware.frontLeftMotor);
    LiveWindow.addActuator("Drive Train", "Back Left Motor", (Jaguar)hardware.rearLeftMotor);
    //LiveWindow.addActuator("Drive Train", "Front Right Motor", (Jaguar)hardware.frontRightMotor);
    //LiveWindow.addActuator("Drive Train", "Back Right Motor", (Jaguar)hardware.rearRightMotor);
}
项目:FRC-2015-Robot-Java    文件:RobotHardwareCompbot.java   
@Override
public void initialize()

{
    //PWM
    liftMotor = new Victor(0); //2);
    leftMotors = new Victor(1);
    rightMotors = new Victor(2); //0);
    armMotors = new Victor(3);
    transmission = new Servo(7);

    //CAN
    armSolenoid = new DoubleSolenoid(4,5);

    //DIO
    liftEncoder = new Encoder(0, 1, false, EncodingType.k4X);
    liftBottomLimit = new DigitalInput(2);
    liftTopLimit = new DigitalInput(3);
    backupLiftBottomLimit = new DigitalInput(5);

    switch1 = new DigitalInput(9);
    switch2 = new DigitalInput(8);

    //ANALOG
    gyro = new Gyro(0);

    //roboRio
    accelerometer = new BuiltInAccelerometer();

    //Stuff
    drivetrain = new RobotDrive(leftMotors, rightMotors);

    liftSpeedRatio = 1; //Half power default
    liftGear = 1;
    driverSpeedRatio = 1;
    debounceComp = 0;

    drivetrain.setInvertedMotor(MotorType.kRearLeft, true);
    drivetrain.setInvertedMotor(MotorType.kRearRight, true);
}
项目:FRC-2015-Robot-Java    文件:RobotHardwarePracticebot.java   
@Override
public void initialize()
{
    //PWM
    liftMotor = new Talon(0); //2);
    leftMotors = new Talon(1);
    rightMotors = new Talon(2); //0);
    armMotors = new Talon(3);
    transmission = new Servo(7);

    //CAN
    armSolenoid = new DoubleSolenoid(4,5);

    //DIO
    /*liftEncoder = new Encoder(0, 1, false, EncodingType.k4X);
    liftBottomLimit = new DigitalInput(2);
    liftTopLimit = new DigitalInput(3);
    backupLiftBottomLimit = new DigitalInput(4);

    switch1 = new DigitalInput(9);
    switch2 = new DigitalInput(8);*/

    //ANALOG
    gyro = new Gyro(0);

    //roboRio
    accelerometer = new BuiltInAccelerometer();

    //Stuff
    drivetrain = new RobotDrive(leftMotors, rightMotors);

    liftSpeedRatio = 1; //Half power default
    liftGear = 1;
    driverSpeedRatio = 1;
    debounceComp = 0;

    drivetrain.setInvertedMotor(MotorType.kRearLeft, true);
    drivetrain.setInvertedMotor(MotorType.kRearRight, true);
}
项目:2014_Main_Robot    文件:Vision.java   
/**
 * Default constructor for vision target. TCP Listens on Port 1111;
 */
private Vision()
{
    cam = new TCPCameraSensor(1111, 200);
    vision_servo = new Servo(RobotMap.visionServo.getInt());
    //initialize data variable
    dataReceived = new String[cam.getMessageLength()];

    for(int i = 0; i < cam.getMessageLength(); i++)
        dataReceived[i] = "0";

    LeftOrRightHot = 0;

    cam.start();
}
项目:2014_Main_Robot    文件:ServoBallTapper.java   
/**
 * A private constructor to prevent multiple instances from being created.
 */
private ServoBallTapper() {
    leftTapper = new Servo(RobotMap.leftTapperServo.getInt());
    rightTapper = new Servo(RobotMap.rightTapperServo.getInt());

    setLeftAngle(0);
    setRightAngle(0);
}
项目:2014_Main_Robot    文件:ServoBallTapper.java   
/**
 * Get the angle of a servo.
 * @param inverted specifies if positive angles should be
 *   clockwise (false) or counterclockwise (true).
 * @param servo The Servo object to get the angle of. 
 * @param maxAngle The maximum angle the servo can travel.
 * @return the angle of the zero (degrees).
 */
private double getAngle(boolean inverted, Servo servo, double maxAngle) {
    double angle = servo.getAngle();

    if(inverted) {
        angle = -angle + maxAngle;
    }

    return angle;
}
项目:2012    文件:CameraUnit.java   
public CameraUnit()
{
    camera = AxisCamera.getInstance(ReboundRumble.CAMERA_IP);
    camera.writeResolution(AxisCamera.ResolutionT.k320x240);
    camera.writeExposurePriority(AxisCamera.ExposurePriorityT.imageQuality);
    camera.writeExposureControl(AxisCamera.ExposureT.hold);
    camera.writeWhiteBalance(AxisCamera.WhiteBalanceT.fixedIndoor);
    cc = new CriteriaCollection();
    cc.addCriteria(MeasurementType.IMAQ_MT_BOUNDING_RECT_WIDTH, 15, 400, false);
    cc.addCriteria(MeasurementType.IMAQ_MT_BOUNDING_RECT_HEIGHT, 15, 400, false);
    cameraPan = new Servo(1, 6);
    cameraTilt = new Servo(1, 7);
}
项目:ultimate-ascent    文件:Climber.java   
public Climber(int leftM, int rightM, int leftSecondaryM, int rightSecondaryM, int leftS, int rightS, int gyro)
{
    this.leftM = new Jaguar(leftM);
    this.rightM = new Jaguar(rightM);
    this.leftSecondaryM = new Victor(leftSecondaryM);
    this.rightSecondaryM = new Victor(rightSecondaryM);
    this.leftS = new Servo(leftS);
    this.rightS = new Servo(rightS);
    this.gyro = new Gyro(gyro);
    this.gyro.setSensitivity(.007);
    System.out.println("Sensitivity set");
    this.gyro.reset();

    Log.v(TAG, "Climber subsystem instantiated.");
}
项目:2013    文件:AimingSystem.java   
public AimingSystem()
{
    camera = AxisCamera.getInstance(Parameters.cameraIP);
    camera.writeResolution(AxisCamera.ResolutionT.k640x480);
    camera.writeExposurePriority(AxisCamera.ExposurePriorityT.imageQuality);
    camera.writeExposureControl(AxisCamera.ExposureT.hold);
    camera.writeWhiteBalance(AxisCamera.WhiteBalanceT.fixedIndoor);
    cc = new CriteriaCollection();
    cc.addCriteria(NIVision.MeasurementType.IMAQ_MT_AREA, 500, 65535, false);
    ultrasonicSensor = new Ultrasonic(Parameters.UltrasonicAnalogChannel);
    servo = new Servo(Parameters.cameraServoPWMChannel);
    setShootPosition();
}
项目:Woodchuck-2013    文件:Drive.java   
public Drive(JoystickControl controller)
{
    leftMotor = new Motor(JAGUAR_LEFT_ID, JAGUAR_LEFT_INVERTED);
    rightMotor = new Motor(JAGUAR_RIGHT_ID, JAGUAR_RIGHT_INVERTED);

    leftEncoderInput = new DigitalInput(ENCODER_DIGITAL_SIDECAR_CHANNEL, ENCODER_LEFT_CHANNEL);
    rightEncoderInput = new DigitalInput(ENCODER_DIGITAL_SIDECAR_CHANNEL, ENCODER_RIGHT_CHANNEL);

    leftEncoder = new Encoder(leftEncoderInput, leftEncoderInput, false, EncodingType.k1X);
    rightEncoder = new Encoder(rightEncoderInput, rightEncoderInput, false, EncodingType.k1X);

    raiseServo = new Servo(5);

    this.controller = controller;
}
项目:R2017    文件:Gear.java   
public Gear() {
    left = new Servo(Constants.GEAR_LEFT);
    right = new Servo(Constants.GEAR_RIGHT);

    isGearOut = false;
}
项目:thirdcoast    文件:ServoMenu.java   
@Override
protected String header() {
  Servo servo = servoSet.getServo();
  String id = servo != null ? String.valueOf(servo.getChannel()) : "";
  return Messages.boldGreen("\nServo: " + id + "\n");
}
项目:thirdcoast    文件:ServoSet.java   
public Servo getServo() {
  return servo;
}
项目:thirdcoast    文件:ServoSet.java   
public void setServo(Servo servo) {
  clearSelected();
  this.servo = servo;
}
项目:thirdcoast    文件:ServoItem.java   
public ServoItem(Servo servo, String description) {
  super(TYPE, description, MEASURES);
  this.servo = servo;
}
项目:thirdcoast    文件:ServoItem.java   
public ServoItem(Servo servo) {
  this(servo, "Servo " + servo.getChannel());
}
项目:FRC-2017    文件:CameraControl.java   
public static void initialize() {
    if (initialized)
        return;

    // reset trigger init time
    initTriggerTime = Utility.getFPGATime();        

    cameraLedRelay = new Relay(HardwareIDs.CAMERA_LED_RELAY_CHANNEL,Relay.Direction.kForward);
    cameraLedRelay.set(Relay.Value.kOff);

    positionServo = new Servo(HardwareIDs.CAMERA_SERVO_PWM_ID);

    gamepad = new Joystick(HardwareIDs.DRIVER_CONTROL_ID);

    ledState = false;

    initialized = true;
}
项目:FRC-2017    文件:CameraControl.java   
public static void initialize() {
    if (initialized)
        return;

    // reset trigger init time
    initTriggerTime = Utility.getFPGATime();        

    cameraLedRelay = new Relay(HardwareIDs.CAMERA_LED_RELAY_CHANNEL,Relay.Direction.kForward);
    cameraLedRelay.set(Relay.Value.kOff);

    positionServo = new Servo(HardwareIDs.CAMERA_SERVO_PWM_ID);

    gamepad = new Joystick(HardwareIDs.DRIVER_CONTROL_ID);

    ledState = false;

    initialized = true;
}
项目:2013_drivebase_proto    文件:WsServo.java   
public WsServo(String name, int channel) {
    this.position = new DoubleSubject(name);
    this.servo = new Servo(channel);
    angleSet = false;
}
项目:Nashoba-Robotics2014    文件:CameraMount.java   
CameraMount() {
    tilt = new Servo(HardwareDefines.DIGITAL_MODULE_PORT, 
                     HardwareDefines.TILT_SERVO_CHANNEL);
    rotate = new Servo(HardwareDefines.DIGITAL_MODULE_PORT,
                       HardwareDefines.ROT_SERVO_CHANNEL);
}
项目:2014_software    文件:WsServo.java   
public WsServo(String name, int channel) {
    this.position = new DoubleSubject(name);
    this.servo = new Servo(channel);
    angleSet = false;
}
项目:FRC623Robot2013-2    文件:Robot.java   
/**
 * This function is run when the robot is first started up and should be
 * used for any initialization code.
 */
public void robotInit() {
    // Initializes the Talon motor controllers for driving
    frontLeftTalon = new Talon(1);
    backLeftTalon = new Talon(2);
    frontRightTalon = new Talon(3);
    backRightTalon = new Talon(4);

    // Initializes the controller for the four driving motors and reverses two of them
    driveControl = new RobotDrive(frontLeftTalon, backLeftTalon, frontRightTalon, backRightTalon);
    driveControl.setInvertedMotor(RobotDrive.MotorType.kFrontRight, true);
    driveControl.setInvertedMotor(RobotDrive.MotorType.kRearRight, true);

    // Initializes the rest of the jaguars and talons for various functions
    frisbeeAcceleratorTalon = new Talon(5);
    frisbeePusherJaguar = new Jaguar(6);
    leftHookTalon = new Talon(7);
    rightHookTalon = new Talon(8);
    shooterTiltTalon = new Talon(9);

    // Initialize joysticks
    driverJoystick = new Joystick(1);
    secondJoystick = new Joystick(2);

    // Initialize the limit switches for the hooks
    hookLimitLeft = new DigitalInput(1);
    hookLimitRight = new DigitalInput(2);

    // Initialize toggle switch for the hooks
    runningHooks = false;

    // Initialize the limit switches for the frisbee pusher
    pusherLimitFront = new DigitalInput(3);
    pusherLimitBack = new DigitalInput(4);

    // Initialize the limit switch on the shooter tilt
    tiltLimitBottom = new DigitalInput(5);
    tiltLimitTop = new DigitalInput(6);

    // Initialize autonomous timer
    frisbeeAutoTimer = new Timer();

    // Initialize encoder
    encoder = new AnalogChannel(3);

    gyro = new Gyro(1);

    camServoX = new Servo(2, 1);
    camServoY = new Servo(2, 2);

    camServoXAngle = 0;
    camServoYAngle = 0;


}
项目:Command-Based-Robot    文件:LeftLock.java   
protected LeftLock() {
    lock = new Servo(Constants.P_LEFT_LOCK_CAR, Constants.P_LEFT_LOCK_CHAN);
}
项目:Command-Based-Robot    文件:RightLock.java   
private RightLock(){
    this.lock = new Servo(Constants.P_RIGHT_LOCK_CAR, Constants.P_RIGHT_LOCK_CHAN);       
}
项目:wpilib-java    文件:RCAssembly.java   
public static Servo getServo(){
    return new SlowServo(1, 1);
}
项目:2013_robot_software    文件:WsServo.java   
public WsServo(String name, int channel) {
    this.position = new DoubleSubject(name);
    this.servo = new Servo(channel);
    angleSet = false;
}