项目:SwerveDrive
文件:AbsoluteAnalogEncoder.java
public AbsoluteAnalogEncoder(int channel,double minVoltage,double maxVoltage,double offsetdegrees) {
super(channel);
if (minVoltage >= maxVoltage) throw new IllegalArgumentException("Minimum voltage must be less than maximum voltage");
if (offsetdegrees < 0 || offsetdegrees > 360) throw new IllegalArgumentException("Offset must be between 0 and 360 degrees");
_channel = channel;
_minVoltage = minVoltage;
_maxVoltage = maxVoltage;
_offsetdegrees = offsetdegrees;
// Turn counter only ever stores 0 //
_turnCounter = new Counter();
_turnCounter.reset();
_turnCounter.stop();
}
项目:Aerial-Assist
文件:Launcher.java
/**
* Constructs a new Launcher,with two Talons for winding,a release relay,* and a limit switch for winding regulation based on input from a
* MaxbotixUltrasonic rangefinder.
*/
public Launcher() {
super("Launcher");
winderL = new Talon(RobotMap.WIND_LEFT_PORT);
winderR = new Talon(RobotMap.WIND_RIGHT_PORT);
releaseMotor = new Relay(RobotMap.RELAY_PORT);
camera = new AxisCameraM1101();
rangefinder = new MaxbotixUltrasonic(RobotMap.ULTRASONIC_RANGEFINDER);
limitSwitch = new DigitalInput(RobotMap.LIMIT_SWITCH);
counter = new Counter(limitSwitch);
counterInit(counter);
}
项目:Woodchuck-2013
文件:Shooter.java
public Shooter(Vision vision,JoystickControl controller)
{
this.vision = vision;
this.controller = controller;
averageSpeed = new MovingAverage(ENCODER_AVERAGE_SAMPLES);
Feeder = new Relay(FeedER_RELAY_CHANNEL);
Feeder.setDirection(Relay.Direction.kForward);
FeederSwitch = new DigitalInput(FeedER_DIGITAL_SIDECAR_SLOT,FeedER_DIGITAL_CHANNEL);
encoderInput = new DigitalInput(ENCODER_DIGITAL_SIDECAR_SLOT,ENCODER_DIGITAL_CHANNEL);
shooterEncoder = new Counter(encoderInput);
shooterEncoder.setSemiPeriodMode(true);
shooterMotor = new Motor(SHOOTER_JAGUAR_CHANNEL,SHOOTER_JAGUAR_INVERTED);
cycleCounts = 0;
rateCount = 0.0;
prevTime = 0.0;
currentSpeed = 0.0;
}
项目:FRC6414program
文件:USensor.java
public USensor() {
leftpulse = new DigitalOutput(RobotMap.LEFT_pulse);
left = new Counter(RobotMap.LEFT_ECHO);
left.setMaxPeriod(1);
left.setSemiPeriodMode(true);
left.reset();
rightpulse = new DigitalOutput(RobotMap.RIGHT_pulse);
right = new Counter(RobotMap.RIGHT_ECHO);
right.setMaxPeriod(1);
right.setSemiPeriodMode(true);
right.reset();
threadInit(() -> {
leftpulse.pulse(RobotMap.US_pulse);
rightpulse.pulse(RobotMap.US_pulse);
do {
try {
Thread.sleep(1);
} catch (InterruptedException e) {
e.printstacktrace();
}
} while (left.get() < 2 || right.get() < 2);
leftdistant = left.getPeriod() * 0.5 * RobotMap.SPEED_OF_SOUND;
rightdistant = right.getPeriod() * 0.5 * RobotMap.SPEED_OF_SOUND;
SmartDashboard.putNumber("left dis",leftdistant);
SmartDashboard.putNumber("right dis",rightdistant);
left.reset();
right.reset();
});
}
项目:R2017
文件:Shooter.java
项目:Stronghold-2016
文件:FlyWheels.java
public FlyWheels() {
left = new CANTalon(RobotMap.LEFT_SHOOTER_MOTOR);
right = new CANTalon(RobotMap.RIGHT_SHOOTER_MOTOR);
left.enableBrakeMode(true);
right.enableBrakeMode(true);
right.changeControlMode(CANTalon.TalonControlMode.Follower);
right.reverSEOutput(true);
pusher = new DoubleSolenoid(RobotMap.PUSHER_OUT_PORT,RobotMap.PUSHER_IN_PORT);
wheelSwitch = new DigitalInput(RobotMap.FLYWHEEL_ENCODER_SWITCH);
counter = new Counter(wheelSwitch);
}
项目:Robot2015
文件:SafeTalon.java
/**
* Set the negative limit switch for this Talon.
* <p>
* This limit switch will stop the motor (set the talon to zero) if the limit switch
* is engaged and the motor set value is negative (<0). Any calls to {@link #pidWrite(double)}
* or {@link #set(double)} that contain a negative value will be overridden to zero. Positive
* motor speeds will still be accepted.
*
* @param negativeLimitSwitch - a digital input used for this limit switch.
* @param defaultState - the default state for this limit switch. The value opposite of the default
* state is used to determine if the switch is engaged.
*/
public void setNegativeLimitSwitch(DigitalInput negativeLimitSwitch,boolean defaultState) {
this.negativeLimitSwitch = negativeLimitSwitch;
this.negativeLimitSwitchDefaultState = defaultState;
// If the default state is true,the counter should detect falling edges
this.negativeLimitSwitchCounter = new Counter(this.negativeLimitSwitch);
if (defaultState == false) {
this.negativeLimitSwitchCounter.setupsourceEdge(true,false);
} else {
this.negativeLimitSwitchCounter.setupsourceEdge(false,true);
}
this.negativeLimitSwitchCounter.reset();
}
项目:Robot2015
文件:SafeTalon.java
/**
* Set the positive limit switch for this Talon.
* <p>
* This limit switch will stop the motor (set the talon to zero) if the limit switch
* is engaged and the motor set value is positive (>0). Any calls to {@link #pidWrite(double)}
* or {@link #set(double)} that contain a positive value will be overridden to zero. Negative
* motor speeds will still be accepted.
*
* @param positiveLimitSwitch - a digital input used for this limit switch.
* @param defaultState - the default state for this limit switch. The value opposite of the default
* state is used to determine if the switch is engaged.
*/
public void setPositiveLimitSwitch(DigitalInput positiveLimitSwitch,boolean defaultState) {
this.positiveLimitSwitch = positiveLimitSwitch;
this.positiveLimitSwitchDefaultState = defaultState;
// If the default state is true,the counter should detect falling edges
this.positiveLimitSwitchCounter = new Counter(this.positiveLimitSwitch);
if (defaultState == false) {
this.positiveLimitSwitchCounter.setupsourceEdge(true,false);
} else {
this.positiveLimitSwitchCounter.setupsourceEdge(false,true);
}
this.positiveLimitSwitchCounter.reset();
}
项目:turtleshell
文件:TurtleHallSensor.java
项目:turtleshell
文件:Robot.java
public Robot() {
stick = new Joystick(0);
try {
/* Construct Digital I/O Objects */
pwm_out_9 = new Victor( getChannelFromPin( PinType.PWM,9 ));
pwm_out_8 = new Jaguar( getChannelFromPin( PinType.PWM,8 ));
dig_in_7 = new DigitalInput( getChannelFromPin( PinType.DigitalIO,7 ));
dig_in_6 = new DigitalInput( getChannelFromPin( PinType.DigitalIO,6 ));
dig_out_5 = new DigitalOutput( getChannelFromPin( PinType.DigitalIO,5 ));
dig_out_4 = new DigitalOutput( getChannelFromPin( PinType.DigitalIO,4 ));
enc_3and2 = new Encoder( getChannelFromPin( PinType.DigitalIO,3 ),getChannelFromPin( PinType.DigitalIO,2 ));
enc_1and0 = new Encoder( getChannelFromPin( PinType.DigitalIO,1 ),0 ));
/* Construct Analog I/O Objects */
/* NOTE: Due to a board layout issue on the navX MXP board revision */
/* 3.3,there is noticeable crosstalk between AN IN pins 3,2 and 1. */
/* For that reason,use of pin 3 and pin 2 is NOT RECOMMENDED. */
an_in_1 = new AnalogInput( getChannelFromPin( PinType.AnalogIn,1 ));
an_trig_0 = new AnalogTrigger( getChannelFromPin( PinType.AnalogIn,0 ));
an_trig_0_counter = new Counter( an_trig_0 );
an_out_1 = new Analogoutput( getChannelFromPin( PinType.Analogout,1 ));
an_out_0 = new Analogoutput( getChannelFromPin( PinType.Analogout,0 ));
/* Configure I/O Objects */
pwm_out_9.setSafetyEnabled(false); /* disable Motor Safety for Demo */
pwm_out_8.setSafetyEnabled(false); /* disable Motor Safety for Demo */
/* Configure Analog Trigger */
an_trig_0.setAveraged(true);
an_trig_0.setLimitsVoltage(MIN_AN_TRIGGER_VOLTAGE,MAX_AN_TRIGGER_VOLTAGE);
} catch (RuntimeException ex ) {
DriverStation.reportError( "Error instantiating MXP pin on navX MXP: "
+ ex.getMessage(),true);
}
}
项目:2015RobotCode
文件:ArmElevator.java
@Override
public void initialize() {
m_victor = new Victor(RobotMap.LIFT_MOTOR);
m_victor.enableDeadbandElimination(true);
m_victor.setExpiration(Victor.DEFAULT_SAFETY_EXPIRATION);
m_encoder = new Encoder(RobotMap.ENCODER_dio_PORTA,RobotMap.ENCODER_dio_PORTB,true);
m_encoder.setSamplesToAverage(10);
m_maxLimit = new DigitalInput(RobotMap.LIMIT_dio_PORT1);
max_counter = new Counter(m_maxLimit);
}
项目:SwerveDrive
文件:AbsoluteAnalogEncoder.java
public AbsoluteAnalogEncoder(int channel,double offsetdegrees,int analogSampleRate,double analogTriggerThresholdDifference) { //Todo: Implement direction
super(channel);
_channel = channel;
if (minVoltage >= maxVoltage) throw new IllegalArgumentException("Minimum voltage must be less than maximum voltage");
if (offsetdegrees < 0 || offsetdegrees > 360) throw new IllegalArgumentException("Offset must be between 0 and 360 degrees");
// Initialize analog trigger //
_analogTrigger = new AnalogTrigger(channel);
_analogTrigger.setFiltered(true);
_analogTrigger.setLimitsVoltage(minVoltage + analogTriggerThresholdDifference,maxVoltage - analogTriggerThresholdDifference);
AnalogTriggerOutput _analogTriggerFalling = new AnalogTriggerOutput(_analogTrigger,AnalogTriggerOutput.Type.kFallingpulse);
AnalogTriggerOutput _analogTriggerRising = new AnalogTriggerOutput(_analogTrigger,AnalogTriggerOutput.Type.kRisingpulse);
// Set analog module sampling rate //
AnalogModule module = (AnalogModule) Module.getModule(ModulePresence.ModuleType.kAnalog,DEFAULT_ANALOG_MODULE);
module.setSampleRate(analogSampleRate);
// Initialize turn counter //
_turnCounter = new Counter();
_turnCounter.setupdownCounterMode();
_turnCounter.setupsource(_analogTriggerRising);
_turnCounter.setDownSource(_analogTriggerFalling);
_turnCounter.start();
_minVoltage = minVoltage;
_maxVoltage = maxVoltage;
_offsetdegrees = offsetdegrees;
}
项目:Aerial-Assist
文件:Launcher.java
/**
* Measures a physical switch press and translates it to virtual meaning. If
* the winder motor is moving in the negative direction,the mechanism is
* unwinding and so the switch press count should decrease,and if the motor
* is moving in the positive direction,the mechanism is winding,and thus
* the switch press count should increase.
*
* @param counter The Counter object that represents the physical limit
* switch virtually. A physical switch press increments the counter value
* twice: once on the press (by 4 - 10) and once on the release (by 1 - 3).
* The code only ackNowledges the presses by ignoring all increases that are
* less than 4.
*/
private void isSwitchpressed(Counter counter) {
if (counter.get() > 3) {
if (winderL.get() <= -0.1) {
currentClick--;
} else if (winderL.get() >= 0.1) {
currentClick++;
} else {
System.out.println("The switch should not have been pressed.");
}
clickTime = Timer.getFPGATimestamp();
}
counter.reset();
}
项目:2013_drivebase_proto
文件:FlywheelEncoders.java
public void update (){
enter_wheel_speed = ((Double) WsOutputManager.getInstance().getoutput(WsOutputManager.SHOOTER_VICTOR_ENTER).get((IoUtputEnum) null));
exit_wheel_speed = ((Double) WsOutputManager.getInstance().getoutput(WsOutputManager.SHOOTER_VICTOR_EXIT).get((IoUtputEnum) null));
//Use instanteous speed to update encoders
if (enter_wheel_speed > 0) {
enter_wheel_encoder+= AMOUNT_TO_CHANGE;
} else {
enter_wheel_encoder-= AMOUNT_TO_CHANGE;
if (enter_wheel_encoder < 0){
enter_wheel_encoder = 0 ;
}
}
if (exit_wheel_speed > 0) {
exit_wheel_encoder+= AMOUNT_TO_CHANGE;
} else {
exit_wheel_encoder-= AMOUNT_TO_CHANGE;
if (exit_wheel_encoder < 0){
exit_wheel_encoder = 0 ;
}
}
((Counter) ((WsShooter) WsSubsystemContainer.getInstance().getSubsystem(WsSubsystemContainer.WS_SHOOTER)).getEnterCounter()).set(enter_wheel_encoder);
((Counter) ((WsShooter) WsSubsystemContainer.getInstance().getSubsystem(WsSubsystemContainer.WS_SHOOTER)).getExitCounter()).set(exit_wheel_encoder);
}
项目:2014-robot-code
文件:ShootArm.java
public ShootArm() {
arm = new Talon(Ports.SHOOTER_LAUNCHER);
arm.set(0);
launcherEncoder = new Encoder(Ports.SHOOTER_ENCODER_1,Ports.SHOOTER_ENCODER_2,false,Encoder.EncodingType.k4X);
launcherEncoder.start();
launcherEncoder.setdistancePerpulse(0.96);
launcherEncoder.setMinRate(1);
armHome = new DigitalInput(Ports.SHOOTER_HOME);
armCounter = new Counter(armHome);
armCounter.start();
state = 0;
}
项目:SwerveDriveTest
文件:AnalogChannelVolt.java
public AnalogChannelVolt(int moduleNumber,int channel) {
super(moduleNumber,channel);
this.getModule().setSampleRate(1000);
m_trig = new AnalogTrigger(moduleNumber,channel);
m_trig.setFiltered(true);
m_trig.setLimitsVoltage(1.35,3.65);
m_count = new Counter();
m_count.setupdownCounterMode();
m_count.setupsource(m_trig,AnalogTriggerOutput.Type.kFallingpulse);
m_count.setDownSource(m_trig,AnalogTriggerOutput.Type.kRisingpulse);
m_count.start();
}
项目:MOEnarch-Drive
文件:AnalogChannelVolt.java
public AnalogChannelVolt(int moduleNumber,AnalogTriggerOutput.Type.kRisingpulse);
m_count.start();
}
项目:RobotCode2013
文件:PhotoelectricSensor.java
/**
* Initializes important objects for the
*/
private void initialize() {
counter = new Counter(input);
counter.setSemiPeriodMode(false);
rateCalc = new RateCalculator(counter);
rateThread = new Thread(rateCalc);
}
项目:RobotCode2013
文件:PhotoelectricSensor.java
项目:Zed-Java
文件:Auger.java
public Auger(int augerRelay,int augerRotationSwitch,int augerTopSwitch) {
super("Auger");
auger = new Relay(augerRelay);
augerRotateSwitch = new DigitalInput(augerRotationSwitch);
augerTopLimitSwitch = new DigitalInput(augerTopSwitch);
counter = new Counter(augerRotateSwitch);
counter.setSemiPeriodMode(false);
direction = AugerDirection.AUGER_STOP;
counter.start();
}
项目:FRC2013
文件:Shooter.java
private Shooter(int motorChannel,int loader,int tilter,int encoder) {
motor = new Victor(motorChannel);
loaderPiston = new Solenoid(loader);
tilterPiston = new Solenoid(tilter);
cntr = new Counter(encoder);
//cntr.setSemiPeriodMode(true);
cntr.start();
new Thread(this).start();
}
项目:frc1675-2013
文件:EncoderShooter.java
public EncoderShooter() {
backMotor = new Victor(RobotMap.BACK_SHOOTER_MOTOR);
frontMotor = new Victor(RobotMap.FRONT_SHOOTER_MOTOR);
counter = new Counter(RobotMap.SHOOTER_ENCODER);
counter.setupdownCounterMode();
counter.start();
setpoint = RobotMap.DEFAULT_SETPOINT;
backMotor.set(RobotMap.BACK_SHOOTING_SPEED);
}
public climbingSystem(Robottemplate robo)
{
try
{
up = new Solenoid(Wiring.climB_SOLENOID_UP);
down = new Solenoid(Wiring.climB_SOLENOID_DOWN);
forward = new Solenoid(Wiring.climBING_SOLENOID_FORWARD);
back = new Solenoid(Wiring.climBING_SOLENOID_BACKWARD);
home = new DigitalInput(Wiring.CYLINDER_HOME);
part = new DigitalInput(Wiring.CYLINDER_PART);
max = new DigitalInput(Wiring.CYLINDER_MAX);
winch = new CANJaguar(Wiring.WINCH_MOTOR);
countPart = new Counter(part);
countPart.setupsourceEdge(true,false);
countPart.reset();
countPart.start();
winch.configMaxOutputVoltage(6.0);
forward.set(true);
back.set(false);
this.robo = robo;
time.start();
typicalCurrent = 0;
}
catch (CANTimeoutException ex)
{
ex.printstacktrace();
}
}
public climbingSystem(Robottemplate robo)
{
try
{
up = new Solenoid(Wiring.climB_SOLENOID_UP);
down = new Solenoid(Wiring.climB_SOLENOID_DOWN);
forward = new Solenoid(Wiring.climBING_SOLENOID_FORWARD);
back = new Solenoid(Wiring.climBING_SOLENOID_BACKWARD);
home = new DigitalInput(Wiring.CYLINDER_HOME);
part = new DigitalInput(Wiring.CYLINDER_PART);
max = new DigitalInput(Wiring.CYLINDER_MAX);
winch = new CANJaguar(Wiring.WINCH_MOTOR);
countPart = new Counter(part);
countPart.setupsourceEdge(true,false);
countPart.reset();
countPart.start();
winch.configMaxOutputVoltage(6.0);
forward.set(true);
back.set(false);
this.robo = robo;
time.start();
typicalCurrent = 0;
}
catch (CANTimeoutException ex)
{
ex.printstacktrace();
}
}
项目:2013_robot_software
文件:FlywheelEncoders.java
public void update (){
enter_wheel_speed = ((Double) WsOutputManager.getInstance().getoutput(WsOutputManager.SHOOTER_VICTOR_ENTER).get((IoUtputEnum) null));
exit_wheel_speed = ((Double) WsOutputManager.getInstance().getoutput(WsOutputManager.SHOOTER_VICTOR_EXIT).get((IoUtputEnum) null));
//Use instanteous speed to update encoders
if (enter_wheel_speed > 0) {
enter_wheel_encoder+= AMOUNT_TO_CHANGE;
} else {
enter_wheel_encoder-= AMOUNT_TO_CHANGE;
if (enter_wheel_encoder < 0){
enter_wheel_encoder = 0 ;
}
}
if (exit_wheel_speed > 0) {
exit_wheel_encoder+= AMOUNT_TO_CHANGE;
} else {
exit_wheel_encoder-= AMOUNT_TO_CHANGE;
if (exit_wheel_encoder < 0){
exit_wheel_encoder = 0 ;
}
}
((Counter) ((WsShooter) WsSubsystemContainer.getInstance().getSubsystem(WsSubsystemContainer.WS_SHOOTER)).getEnterCounter()).set(enter_wheel_encoder);
((Counter) ((WsShooter) WsSubsystemContainer.getInstance().getSubsystem(WsSubsystemContainer.WS_SHOOTER)).getExitCounter()).set(exit_wheel_encoder);
}
项目:StormRobotics2017
文件:HallEffectSensor.java
public HallEffectSensor(int port){
_hallEffect = new DigitalInput(port);
_counter = new Counter(_hallEffect);
}
项目:2013_drivebase_proto
文件:WsShooter.java
public Counter getEnterCounter() {
return counterEnter;
}
项目:2013_drivebase_proto
文件:WsShooter.java
public Counter getExitCounter() {
return counterExit;
}
项目:2013_drivebase_proto
文件:WsShooter.java
public Counter getEnterCounterValue() {
return counterEnter;
}
项目:2013_drivebase_proto
文件:WsShooter.java
public Counter getExitCounterValue() {
return counterExit;
}
项目:Storm2014
文件:HallEffectSpeedSensor.java
public HallEffectSpeedSensor(int port) {
_hallEffect = new DigitalInput(port);
_counter = new Counter(_hallEffect);
_counter.start();
}
项目:2015-frc-robot
文件:MecanumEncoder.java
项目:2015-frc-robot
文件:MecanumEncoder.java
项目:Storm2013
文件:HallEffectSpeedSensor.java
public HallEffectSpeedSensor(int port) {
_hallEffect = new DigitalInput(port);
_counter = new Counter(_hallEffect);
_counter.start();
}
项目:wpilib-java
文件:FakeEncoderTest.java
项目:wpilib-java
文件:FakeQuadEncoderTest.java
项目:wpilib-java
文件:JaguarTest.java
public void setup() {
victor = new Victor(2);
gts = new Counter(2,GreyJagGearTooth); // need to encode this slot number
}