本文整理汇总了Java中edu.wpi.first.wpilibj.CANJaguar类的典型用法代码示例。如果您正苦于以下问题:Java CANJaguar类的具体用法?Java CANJaguar怎么用?Java CANJaguar使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CANJaguar类属于edu.wpi.first.wpilibj包,在下文中一共展示了CANJaguar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initalizeCANJaguar
import edu.wpi.first.wpilibj.CANJaguar; //导入依赖的package包/类
private boolean initalizeCANJaguar() {
// if (lastCANRetry != -1 && System.currentTimeMillis() - lastCANRetry < 200) {
// canInitialized = false;
// return false;
// }
// lastCANRetry = System.currentTimeMillis();
// for (int i = 0; i < 3; i++) {
// try {
winch = new CANJaguarSafety(RobotMap.SHOOTER_WINCH_CAN_PORT);
winch.configEncoderCodesPerRev(360);
winch.setPositionReference(CANJaguar.PositionReference.kQuadEncoder);
winch.changeControlMode(CANJaguar.ControlMode.kPercentVbus);
winch.disableControl();
initializeWinch();
if (!winchSafety.isRunning())
winchSafety.start();
canInitialized = true;
return true;
// } catch (CANTimeoutException e){
// BlackBoxProtocol.log("CAN-Jaguar initilization failed: " + e.toString());
// }
// }
// canInitialized = false;
// return false;
}
示例2: configSpeedControl
import edu.wpi.first.wpilibj.CANJaguar; //导入依赖的package包/类
private void configSpeedControl(CANJaguar jag) throws CANTimeoutException {
final int CPR = 360;
final double ENCODER_FINAL_POS = 0;
final double VOLTAGE_RAMP = 40;
// jag.changeControlMode(CANJaguar.ControlMode.kPercentVbus);
// jag.setSpeedReference(CANJaguar.SpeedReference.kNone);
// jag.enableControl();
// jag.configMaxOutputVoltage(10);//ToDo:
// PIDs may be required. Values here:
// http://www.chiefdelphi.com/forums/showthread.php?t=91384
// and here:
// http://www.chiefdelphi.com/forums/showthread.php?t=89721
// neither seem correct.
// jag.setPID(0.4, .005, 0);
jag.setPID(0.3, 0.005, 0);
jag.setSpeedReference(CANJaguar.SpeedReference.kQuadEncoder);
jag.configEncoderCodesPerRev(CPR);
// jag.setVoltageRampRate(VOLTAGE_RAMP);
jag.enableControl();
// System.out.println("Control Mode = " + jag.getControlMode());
}
示例3: RoboDrive
import edu.wpi.first.wpilibj.CANJaguar; //导入依赖的package包/类
public RoboDrive(){
try {
//creates the motors
aLeft = new CANJaguar(RobotMap.LEFT_DRIVE_MOTOR_ALPHA);
bLeft = new CANJaguar(RobotMap.LEFT_DRIVE_MOTOR_BETA);//, CANJaguar.ControlMode.kSpeed);
aRight = new CANJaguar(RobotMap.RIGHT_DRIVE_MOTOR_ALPHA);
bRight = new CANJaguar(RobotMap.RIGHT_DRIVE_MOTOR_BETA);//, CANJaguar.ControlMode.kSpeed);
//creates the drive train
roboDrive = new RobotDrive(aLeft, bLeft, aRight, bRight);
roboDrive.setSafetyEnabled(false);
} catch(CANTimeoutException ex) {
ex.printStackTrace();
}
}
示例4: BTCanJaguar
import edu.wpi.first.wpilibj.CANJaguar; //导入依赖的package包/类
private BTCanJaguar(int port, boolean isVoltage, BTDebugger debug)
{
this.isVoltage = isVoltage;
this.debug = debug;
this.port = port;
setVoltageMode(isVoltage);
try {
motor = new CANJaguar(port);
} catch (CANTimeoutException ex) {
debug.write(Constants.DebugLocation.BTMotor, Constants.Severity.SEVERE, "ERROR: Motor not initiated at port: "+port);
}
catch (Exception e)
{
debug.write(Constants.DebugLocation.BTMotor, Constants.Severity.SEVERE, "ERROR: Motor not initiated at port: "+port+" Exception: "+e.toString());
}
}
示例5: init
import edu.wpi.first.wpilibj.CANJaguar; //导入依赖的package包/类
public void init() {
if(!hasInit) {
left = new Victor(HardwareDefines.RIGHT_LOADER_VICTOR);
try {
right = new CANJaguar(HardwareDefines.LEFT_LOADER_JAG);
}
catch(CANTimeoutException e) {
System.out.println("Could not instantiate left loader jag!");
}
hasInit = true;
}
else {
System.out.println("The loader subsystem has already "
+ "been initialized!");
return;
}
}
示例6: Puncher
import edu.wpi.first.wpilibj.CANJaguar; //导入依赖的package包/类
private Puncher()
{
try
{
winch = new CANJaguar(RobotMap.WINCH_JAG);
winch.configPotentiometerTurns(1);
winch.setPositionReference(CANJaguar.PositionReference.kPotentiometer);
winch.setSafetyEnabled(false);
setWinchLimit(.95f);
}
catch (CANTimeoutException ex)
{
reportCANException(ex);
}
dogEar = new DoubleSolenoid(RobotMap.DOG_EAR_SOLENOID_DEPLOY, RobotMap.DOG_EAR_SOLENOID_UNDEPLOY);
dogEar.set(Value.kReverse);
}
示例7: SlingShot
import edu.wpi.first.wpilibj.CANJaguar; //导入依赖的package包/类
public SlingShot()
{
try
{
shooterPull = new CANJaguar(ReboundRumble.SHOOTER_PULL_CAN_ID);
shooterPull.changeControlMode(CANJaguar.ControlMode.kPercentVbus);
shooterPull.configNeutralMode(CANJaguar.NeutralMode.kBrake);
elevation = new CANJaguar(ReboundRumble.ELEVATION_CAN_ID);
SetElevationPositionControl();
} catch (CANTimeoutException ex)
{
}
trigger = new Relay(ReboundRumble.SHOOTER_TRIGGER_RELAY_CHANNEL);
// loadPosition = new DigitalInput(ReboundRumble.LOAD_POSITON_LIMIT_SWITCH);
// slingMagnet = new Relay(ReboundRumble.SLING_ELECTROMAGNET_RELAY_CHANNEL);
// ballSensor = new DigitalInput(ReboundRumble.SHOOTER_BALL_SENSOR_GPIO_CHANNEL);
settingForce = false;
}
示例8: BTMotor
import edu.wpi.first.wpilibj.CANJaguar; //导入依赖的package包/类
public BTMotor(int port, boolean isCan)
{
isCANBus = isCan;
if (isCANBus)
{
//int maxTries = 0;
//while(CANMotor == null && maxTries < 10)
//{
try{
CANMotor = new CANJaguar(port);
}
catch(Exception CANTimeoutException){
Log.log("Error initialising CANJaguar");
}
//}
//if (maxTries >= 10)
//Log.log("CANJaguar(" + port + ") failed to initialize.");
}
else
{
PWMMotor = new Jaguar(port);
}
}
示例9: instanciate
import edu.wpi.first.wpilibj.CANJaguar; //导入依赖的package包/类
public void instanciate(int port, boolean isCan, boolean isVoltage)
{
isCANBus = isCan;
portNum = port;
voltage = isVoltage;
if (isCANBus) {
try{
CANMotor = new CANJaguar(port);
if (isVoltage)
{
setVoltageControlMode();
}
successJag = true;
}
catch(Exception CANTimeoutException){
System.out.println("Error initialising CANJaguar at port: " +port);
}
}
else
{
PWMMotor = new Jaguar(port);
}
}
示例10: ShooterMotorControl
import edu.wpi.first.wpilibj.CANJaguar; //导入依赖的package包/类
public ShooterMotorControl() {
super("ShooterControl", Kp, Ki, Kd);
Encoder topEncoder = new Encoder(RobotMap.topEncoderChannelA, RobotMap.topEncoderChannelB);
Encoder bottomEncoder = new Encoder(RobotMap.bottomEncoderChannelA, RobotMap.bottomEncoderChannelB);
try {
shooterJagTop = new CANJaguar(RobotMap.shooterJagTopID);
shooterJagBottom = new CANJaguar(RobotMap.shooterJagBottomID);
} catch (CANTimeoutException e) {
e.printStackTrace();
}
// Use these to get going:
// setSetpoint() - Sets where the PID controller should move the system
// to
// enable() - Enables the PID controller.
enable();
}
示例11: configSpeedControl
import edu.wpi.first.wpilibj.CANJaguar; //导入依赖的package包/类
private void configSpeedControl(CANJaguar jag) throws CANTimeoutException {
final int CPR = 360;
final double ENCODER_FINAL_POS = 0;
final double VOLTAGE_RAMP = 40;
jag.changeControlMode(CANJaguar.ControlMode.kPercentVbus);
jag.setSpeedReference(CANJaguar.SpeedReference.kNone);
jag.enableControl();
jag.configMaxOutputVoltage(10);//ToDo:
// PIDs may be required. Values here:
// http://www.chiefdelphi.com/forums/showthread.php?t=91384
// and here:
// http://www.chiefdelphi.com/forums/showthread.php?t=89721
// neither seem correct.
// jag.setPID(0.4, .005, 0);
/*jag.setPID(1, 0, 0);
jag.changeControlMode(CANJaguar.ControlMode.kSpeed);
jag.setSpeedReference(CANJaguar.SpeedReference.kQuadEncoder);
jag.configEncoderCodesPerRev(CPR);
// jag.setVoltageRampRate(VOLTAGE_RAMP);
jag.enableControl();*/
// System.out.println("Control Mode = " + jag.getControlMode());
}
示例12: initEncoder
import edu.wpi.first.wpilibj.CANJaguar; //导入依赖的package包/类
private void initEncoder(){
try {
jaguar.configEncoderCodesPerRev(ticsPerRev); // Config encoder tics per rev
// Set speed or position reference
switch(controlMode.value){
case ControlMode.kPosition_val:
jaguar.setPositionReference(CANJaguar.PositionReference.kQuadEncoder);
break;
case ControlMode.kSpeed_val:
jaguar.setSpeedReference(CANJaguar.SpeedReference.kQuadEncoder);
break;
default:
break;
}
} catch (CANTimeoutException ex) {
ex.printStackTrace();
}
}
示例13: DriveTrain
import edu.wpi.first.wpilibj.CANJaguar; //导入依赖的package包/类
public DriveTrain(){
try{
leftFront = new CANJaguar(1);
leftRear = new CANJaguar(2);
rightFront = new CANJaguar(4);
rightRear = new CANJaguar(3);
}catch(Exception e){
System.out.println(e);
System.out.println(leftFront);
System.out.println(leftRear);
System.out.println(rightFront);
System.out.println(rightRear);
}
drive = new RobotDrive(leftFront, leftRear, rightFront, rightRear);
gyro.reset();
gyro.setSensitivity(0.007);
}
示例14: setSpeed
import edu.wpi.first.wpilibj.CANJaguar; //导入依赖的package包/类
public void setSpeed(double rpm) throws CANTimeoutException {
//Right now, we're using voltage control mode
// guess voltage to rpm relationship
double voltage = rpm / 0;
//Check to see if 'rpm' works
if ((firstShootingMotor.getControlMode() == CANJaguar.ControlMode.kVoltage)
&& (secondShootingMotor.getControlMode() == CANJaguar.ControlMode.kVoltage)) {
firstShootingMotor.setX(voltage);
} else {
firstShootingMotor.setX(rpm);
secondShootingMotor.setX(rpm);
}
}
示例15: Drive
import edu.wpi.first.wpilibj.CANJaguar; //导入依赖的package包/类
public Drive(){
try {
//Setup the drive motors
leftFront = new CANJaguar(1);
rightFront = new CANJaguar(2);
leftRear = new CANJaguar(3);
rightRear = new CANJaguar(4);
//Setup the Drive
robotDrive = new RobotDrive(leftFront, leftRear, rightFront, rightRear);
} catch (CANTimeoutException ex) {
ex.printStackTrace();
}
}