-
Notifications
You must be signed in to change notification settings - Fork 288
Update some pneumatic RLIs #3083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update some pneumatic RLIs #3083
Conversation
|
\inspector check all |
Inspector ReportUp To DateDetailsOutdated - Automatically FixedDetailsInvalid - Manual Intervention NeededDetails
- 17 // Initializes an AnalogInput on port 0
- 18 AnalogInput m_analog = new AnalogInput(0);
+ 17
- 63 // Initializes an AnalogInput on port 0
- 64 frc::AnalogInput m_analog{0};
+ 63
- 25 // Sets the AnalogInput to 4-bit oversampling. 16 samples will be added together.
- 26 // Thus, the reported values will increase by about a factor of 16, and the update
- 27 // rate will decrease by a similar amount.
- 28 m_analog.setOversampleBits(4);
+ 25
- 15 // Sets the AnalogInput to 4-bit oversampling. 16 samples will be added
- 16 // together.
- 17 // Thus, the reported values will increase by about a factor of 16, and the
- 18 // update rate will decrease by a similar amount.
- 19 m_analog.SetOversampleBits(4);
+ 15
- 30 // Sets the AnalogInput to 4-bit averaging. 16 samples will be averaged together.
- 31 // The update rate will decrease by a factor of 16.
- 32 m_analog.setAverageBits(4);
+ 30
- 21 // Sets the AnalogInput to 4-bit averaging. 16 samples will be averaged
- 22 // together. The update rate will decrease by a factor of 16.
- 23 m_analog.SetAverageBits(4);
+ 21
- 37 // Gets the raw instantaneous measured value from the analog input, without
- 38 // applying any calibration and ignoring oversampling and averaging
- 39 // settings.
- 40 m_analog.getValue();
+ 37
- 25 // Gets the raw instantaneous measured value from the analog input, without
- 26 // applying any calibration and ignoring oversampling and averaging
- 27 // settings.
- 28 m_analog.GetValue();
+ 25
- 42 // Gets the instantaneous measured voltage from the analog input.
- 43 // Oversampling and averaging settings are ignored
- 44 m_analog.getVoltage();
+ 42
- 30 // Gets the instantaneous measured voltage from the analog input.
- 31 // Oversampling and averaging settings are ignored
- 32 m_analog.GetVoltage();
+ 30
- 46 // Gets the averaged value from the analog input. The value is not
- 47 // rescaled, but oversampling and averaging are both applied.
- 48 m_analog.getAverageValue();
+ 46
- 34 // Gets the averaged value from the analog input. The value is not
- 35 // rescaled, but oversampling and averaging are both applied.
- 36 m_analog.GetAverageValue();
+ 34
- 46 // Gets the averaged value from the analog input. The value is not
- 47 // rescaled, but oversampling and averaging are both applied.
- 48 m_analog.getAverageValue();
+ 46
- 38 // Gets the averaged voltage from the analog input. Rescaling,
- 39 // oversampling, and averaging are all applied.
- 40 m_analog.GetAverageVoltage();
+ 38
- 42 // Gets the instantaneous measured voltage from the analog input.
- 43 // Oversampling and averaging settings are ignored
- 44 m_analog.getVoltage();
+ 42
- 42 // Sets the initial value of the accumulator to 0
- 43 // This is the "starting point" from which the value will change over time
- 44 m_analog.SetAccumulatorInitialValue(0);
- 45 // Sets the "center" of the accumulator to 0. This value is subtracted from
- 46 // all measured values prior to accumulation.
- 47 m_analog.SetAccumulatorCenter(0);
- 48 // Returns the number of accumulated samples since the accumulator was last
- 49 // started/reset
- 50 m_analog.GetAccumulatorCount();
- 51 // Returns the value of the accumulator. Return type is long.
- 52 m_analog.GetAccumulatorValue();
- 53 // Resets the accumulator to the initial value
- 54 m_analog.ResetAccumulator();
+ 42
- 20 // Instantiate an AccumulatorResult object to hold the matched measurements
- 21 AccumulatorResult m_result = new AccumulatorResult();
- 67 // Fill the AccumulatorResult with the matched measurements
- 68 m_analog.getAccumulatorOutput(m_result);
- 69 // Read the values from the AccumulatorResult
- 70 long count = m_result.count;
- 71 long value = m_result.value;
+ 20
- 66 // Fill the count and value variables with the matched measurements
- 67 m_analog.GetAccumulatorOutput(count, value);
- 68 // The count and value variables to fill
- 58 int64_t count;
- 59 int64_t value;
+ 66
- 16 // Initializes an AnalogPotentiometer on analog port 0
- 17 // The full range of motion (in meaningful external units) is 0-180 (this could be degrees, for
- 18 // instance)
- 19 // The "starting point" of the motion, i.e. where the mechanism is located when the potentiometer
- 20 // reads 0v, is 30.
- 21 AnalogPotentiometer m_pot = new AnalogPotentiometer(0, 180, 30);
+ 16
- 26 // Initializes an AnalogPotentiometer on analog port 0
- 27 // The full range of motion (in meaningful external units) is 0-180 (this
- 28 // could be degrees, for instance) The "starting point" of the motion, i.e.
- 29 // where the mechanism is located when the potentiometer reads 0v, is 30.
- 30 frc::AnalogPotentiometer m_pot{0, 180, 30};
+ 26
- 23 // Initializes an AnalogInput on port 1
- 24 AnalogInput m_input = new AnalogInput(0);
- 25 // Initializes an AnalogPotentiometer with the given AnalogInput
- 26 // The full range of motion (in meaningful external units) is 0-180 (this could be degrees, for
- 27 // instance)
- 28 // The "starting point" of the motion, i.e. where the mechanism is located when the potentiometer
- 29 // reads 0v, is 30.
- 30 AnalogPotentiometer m_pot1 = new AnalogPotentiometer(m_input, 180, 30);
+ 23
- 32 // Initializes an AnalogInput on port 1
- 33 frc::AnalogInput m_input{1};
- 34 // Initializes an AnalogPotentiometer with the given AnalogInput
- 35 // The full range of motion (in meaningful external units) is 0-180 (this
- 36 // could be degrees, for instance) The "starting point" of the motion, i.e.
- 37 // where the mechanism is located when the potentiometer reads 0v, is 30.
- 38 frc::AnalogPotentiometer m_pot1{&m_input, 180, 30};
+ 32
- 40 // Get the value of the potentiometer
- 41 m_pot.get();
+ 40
- 21 // Get the value of the potentiometer
- 22 m_pot.Get();
+ 21
- 15 // Initializes a DigitalInput on DIO 0
- 16 DigitalInput m_input = new DigitalInput(0);
+ 15
- 21 // Initializes a DigitalInput on DIO 0
- 22 frc::DigitalInput m_input{0};
+ 21
- 20 // Gets the value of the digital input. Returns true if the circuit is open.
- 21 m_input.get();
+ 20
- 15 // Gets the value of the digital input. Returns true if the circuit is
- 16 // open.
- 17 m_input.Get();
+ 15
- 16 // Initializes an AnalogTrigger on port 0
- 17 AnalogTrigger m_trigger0 = new AnalogTrigger(0);
- 18 // Initializes an AnalogInput on port 1 and enables 2-bit oversampling
- 19 AnalogInput m_input = new AnalogInput(1);
20 16
- 21 // Initializes an AnalogTrigger using the above input
- 22 AnalogTrigger m_trigger1 = new AnalogTrigger(m_input);
- 27 // Initializes an AnalogTrigger on port 0
- 28 frc::AnalogTrigger trigger0{0};
- 29 // Initializes an AnalogInput on port 1
- 30 frc::AnalogInput input{1};
31 27
- 32 // Initializes an AnalogTrigger using the above input
- 33 frc::AnalogTrigger trigger1{input};
- 26 // Enables 2-bit oversampling
- 27 m_input.setAverageBits(2);
- 28 // Sets the trigger to enable at a raw value of 3500, and disable at a value of 1000
- 29 m_trigger0.setLimitsRaw(1000, 3500);
- 30 // Sets the trigger to enable at a voltage of 4 volts, and disable at a value of 1.5 volts
- 31 m_trigger0.setLimitsVoltage(1.5, 4);
+ 26
- 16 // Enables 2-bit oversampling
- 17 input.SetAverageBits(2);
- 18 // Sets the trigger to enable at a raw value of 3500, and disable at a value
- 19 // of 1000
- 20 trigger0.SetLimitsRaw(1000, 3500);
- 21 // Sets the trigger to enable at a voltage of 4 volts, and disable at a
- 22 // value of 1.5 volts
- 23 trigger0.SetLimitsVoltage(1.5, 4);
+ 16
- 16 // Initializes an encoder on DIO pins 0 and 1
- 17 // Defaults to 4X decoding and non-inverted
- 18 Encoder m_encoder = new Encoder(0, 1);
+ 16
- 56 // Initializes an encoder on DIO pins 0 and 1
- 57 // Defaults to 4X decoding and non-inverted
- 58 frc::Encoder m_encoder{0, 1};
+ 56
- 20 // Initializes an encoder on DIO pins 0 and 1
- 21 // 2X encoding and non-inverted
- 22 Encoder m_encoder2x = new Encoder(0, 1, false, Encoder.EncodingType.k2X);
+ 20
- 60 // Initializes an encoder on DIO pins 0 and 1
- 61 // 2X encoding and non-inverted
- 62 frc::Encoder m_encoder2x{0, 1, false, frc::Encoder::EncodingType::k2X};
+ 60
- 26 // Configures the encoder to return a distance of 4 for every 256 pulses
- 27 // Also changes the units of getRate
- 28 m_encoder.setDistancePerPulse(4.0 / 256.0);
- 29 // Configures the encoder to consider itself stopped after .1 seconds
- 30 m_encoder.setMaxPeriod(0.1);
- 31 // Configures the encoder to consider itself stopped when its rate is below 10
- 32 m_encoder.setMinRate(10);
- 33 // Reverses the direction of the encoder
- 34 m_encoder.setReverseDirection(true);
- 35 // Configures an encoder to average its period measurement over 5 samples
- 36 // Can be between 1 and 127 samples
- 37 m_encoder.setSamplesToAverage(5);
+ 26
- 20 // Configures the encoder to return a distance of 4 for every 256 pulses
- 21 // Also changes the units of getRate
- 22 m_encoder.SetDistancePerPulse(4.0 / 256.0);
- 23 // Configures the encoder to consider itself stopped after .1 seconds
- 24 m_encoder.SetMaxPeriod(0.1_s);
- 25 // Configures the encoder to consider itself stopped when its rate is below
- 26 // 10
- 27 m_encoder.SetMinRate(10);
- 28 // Reverses the direction of the encoder
- 29 m_encoder.SetReverseDirection(true);
- 30 // Configures an encoder to average its period measurement over 5 samples
- 31 // Can be between 1 and 127 samples
- 32 m_encoder.SetSamplesToAverage(5);
+ 20
- 44 // Gets the distance traveled
- 45 m_encoder.getDistance();
+ 44
- 36 // Gets the distance traveled
- 37 m_encoder.GetDistance();
+ 36
- 47 // Gets the current rate of the encoder
- 48 m_encoder.getRate();
+ 47
- 39 // Gets the current rate of the encoder
- 40 m_encoder.GetRate();
+ 39
- 50 // Gets whether the encoder is stopped
- 51 m_encoder.getStopped();
+ 50
- 42 // Gets whether the encoder is stopped
- 43 m_encoder.GetStopped();
+ 42
- 53 // Gets the last direction in which the encoder moved
- 54 m_encoder.getDirection();
+ 53
- 45 // Gets the last direction in which the encoder moved
- 46 m_encoder.GetDirection();
+ 45
- 56 // Gets the current period of the encoder
- 57 m_encoder.getPeriod();
+ 56
- 48 // Gets the current period of the encoder
- 49 m_encoder.GetPeriod();
+ 48
- 59 // Resets the encoder to read a distance of zero
- 60 m_encoder.reset();
+ 59
- 51 // Resets the encoder to read a distance of zero
- 52 m_encoder.Reset();
+ 51
- 15 // Initializes a duty cycle encoder on DIO pins 0
- 16 DutyCycleEncoder m_encoder = new DutyCycleEncoder(0);
+ 15
- 27 // Initializes a duty cycle encoder on DIO pins 0
- 28 frc::DutyCycleEncoder m_encoder{0};
+ 27
- 18 // Initializes a duty cycle encoder on DIO pins 0 to return a value of 4 for
- 19 // a full rotation, with the encoder reporting 0 half way through rotation (2
- 20 // out of 4)
- 21 DutyCycleEncoder m_encoderFR = new DutyCycleEncoder(0, 4.0, 2.0);
+ 18
- 30 // Initializes a duty cycle encoder on DIO pins 0 to return a value of 4 for
- 31 // a full rotation, with the encoder reporting 0 half way through rotation (2
- 32 // out of 4)
- 33 frc::DutyCycleEncoder m_encoderFR{0, 4.0, 2.0};
+ 30
- 28 // Gets the rotation
- 29 m_encoder.get();
+ 28
- 19 // Gets the rotation
- 20 m_encoder.Get();
+ 19
- 31 // Gets if the encoder is connected
- 32 m_encoder.isConnected();
+ 31
- 22 // Gets if the encoder is connected
- 23 m_encoder.IsConnected();
+ 22
- 15 // Initializes an analog encoder on Analog Input pin 0
- 16 AnalogEncoder m_encoder = new AnalogEncoder(0);
+ 15
- 24 // Initializes an analog encoder on Analog Input pin 0
- 25 frc::AnalogEncoder m_encoder{0};
+ 24
- 18 // Initializes an analog encoder on DIO pins 0 to return a value of 4 for
- 19 // a full rotation, with the encoder reporting 0 half way through rotation (2
- 20 // out of 4)
- 21 AnalogEncoder m_encoderFR = new AnalogEncoder(0, 4.0, 2.0);
+ 18
- 27 // Initializes an analog encoder on DIO pins 0 to return a value of 4 for
- 28 // a full rotation, with the encoder reporting 0 half way through rotation (2
- 29 // out of 4)
- 30 frc::AnalogEncoder m_encoderFR{0, 4.0, 2.0};
+ 27
- 28 // Gets the rotation
- 29 m_encoder.get();
+ 28
- 19 // Gets the rotation
- 20 m_encoder.Get();
+ 19
- 17 // Creates an encoder on DIO ports 0 and 1
- 18 Encoder m_encoder = new Encoder(0, 1);
- 19 // Initialize motor controllers and drive
- 20 Spark m_leftLeader = new Spark(0);
- 21 Spark m_leftFollower = new Spark(1);
- 22 Spark m_rightLeader = new Spark(2);
- 23 Spark m_rightFollower = new Spark(3);
- 24 DifferentialDrive m_drive = new DifferentialDrive(m_leftLeader::set, m_rightLeader::set);
25 17
- 26 /** Called once at the beginning of the robot program. */
- 27 public Robot() {
- 28 // Configures the encoder's distance-per-pulse
- 29 // The robot moves forward 1 foot per encoder rotation
- 30 // There are 256 pulses per encoder rotation
- 31 m_encoder.setDistancePerPulse(1.0 / 256.0);
- 32 // Invert the right side of the drivetrain. You might have to invert the other side
- 33 m_rightLeader.setInverted(true);
- 34 // Configure the followers to follow the leaders
- 35 m_leftLeader.addFollower(m_leftFollower);
- 36 m_rightLeader.addFollower(m_rightFollower);
- 37 }
- 38
- 39 /** Drives forward at half speed until the robot has moved 5 feet, then stops. */
- 40 @Override
- 41 public void autonomousPeriodic() {
- 42 if (m_encoder.getDistance() < 5.0) {
- 43 m_drive.tankDrive(0.5, 0.5);
- 44 } else {
- 45 m_drive.tankDrive(0.0, 0.0);
- 46 }
- 47 }
- 41 Robot() {
- 42 // Configures the encoder's distance-per-pulse
- 43 // The robot moves forward 1 foot per encoder rotation
- 44 // There are 256 pulses per encoder rotation
- 45 m_encoder.SetDistancePerPulse(1.0 / 256.0);
- 46 // Invert the right side of the drivetrain. You might have to invert the
- 47 // other side
- 48 rightLeader.SetInverted(true);
- 49 // Configure the followers to follow the leaders
- 18 leftLeader.AddFollower(leftFollower);
- 19 rightLeader.AddFollower(rightFollower);
- 20 }
- 21 void AutonomousPeriodic() override {
- 22 // Drives forward at half speed until the robot has moved 5 feet, then
- 23 // stops:
- 24 if (m_encoder.GetDistance() < 5) {
- 25 drive.TankDrive(0.5, 0.5);
- 26 } else {
- 27 drive.TankDrive(0, 0);
- 28 }
- 29 }
- 30 // Creates an encoder on DIO ports 0 and 1.
- 31 frc::Encoder m_encoder{0, 1};
- 32 // Initialize motor controllers and drive
- 33 frc::Spark leftLeader{0};
- 34 frc::Spark leftFollower{1};
- 35 frc::Spark rightLeader{2};
- 36 frc::Spark rightFollower{3};
- 37 frc::DifferentialDrive drive{[&](double output) { leftLeader.Set(output); },
- 38 [&](double output) { rightLeader.Set(output); }};
+ 41
- 17 Encoder m_encoder = new Encoder(0, 1);
- 18 Spark m_spark = new Spark(0);
- 19 // Limit switch on DIO 2
- 20 DigitalInput m_limit = new DigitalInput(2);
21 17
- 22 /**
- 23 * Runs the motor backwards at half speed until the limit switch is pressed then turn off the
- 24 * motor and reset the encoder.
- 25 */
- 26 @Override
- 27 public void autonomousPeriodic() {
- 28 if (!m_limit.get()) {
- 29 m_spark.set(-0.5);
- 30 } else {
- 31 m_spark.set(0.0);
- 32 m_encoder.reset();
- 33 }
- 34 }
- 30 void AutonomousPeriodic() override {
- 31 // Runs the motor backwards at half speed until the limit switch is pressed
- 32 // then turn off the motor and reset the encoder
- 33 if (!m_limit.Get()) {
- 18 m_spark.Set(-0.5);
- 19 } else {
- 20 m_spark.Set(0);
- 21 m_encoder.Reset();
- 22 }
- 23 }
- 24 frc::Encoder m_encoder{0, 1};
- 25 frc::Spark m_spark{0};
- 26 // Limit switch on DIO 2
- 27 frc::DigitalInput m_limit{2};
+ 30
- 17 DigitalInput m_toplimitSwitch = new DigitalInput(0);
- 18 DigitalInput m_bottomlimitSwitch = new DigitalInput(1);
- 19 PWMVictorSPX m_motor = new PWMVictorSPX(0);
- 20 Joystick m_joystick = new Joystick(0);
21 17
- 22 @Override
- 23 public void teleopPeriodic() {
- 24 setMotorSpeed(m_joystick.getRawAxis(2));
- 25 }
- 26
- 27 /**
- 28 * Sets the motor speed based on joystick input while respecting limit switches.
- 29 *
- 30 * @param speed the desired speed of the motor, positive for up and negative for down
- 31 */
- 32 public void setMotorSpeed(double speed) {
- 33 if (speed > 0) {
- 34 if (m_toplimitSwitch.get()) {
- 35 // We are going up and top limit is tripped so stop
- 36 m_motor.set(0);
- 37 } else {
- 38 // We are going up but top limit is not tripped so go at commanded speed
- 39 m_motor.set(speed);
- 40 }
- 41 } else {
- 42 if (m_bottomlimitSwitch.get()) {
- 43 // We are going down and bottom limit is tripped so stop
- 44 m_motor.set(0);
- 45 } else {
- 46 // We are going down but bottom limit is not tripped so go at commanded speed
- 47 m_motor.set(speed);
- 48 }
- 49 }
- 50 }
- 40 void TeleopPeriodic() override { SetMotorSpeed(m_joystick.GetRawAxis(2)); }
- 41 void SetMotorSpeed(double speed) {
- 42 if (speed > 0) {
- 43 if (m_toplimitSwitch.Get()) {
- 17 // We are going up and top limit is tripped so stop
- 18 m_motor.Set(0);
- 19 } else {
- 20 // We are going up but top limit is not tripped so go at commanded speed
- 21 m_motor.Set(speed);
- 22 }
- 23 } else {
- 24 if (m_bottomlimitSwitch.Get()) {
- 25 // We are going down and bottom limit is tripped so stop
- 26 m_motor.Set(0);
- 27 } else {
- 28 // We are going down but bottom limit is not tripped so go at commanded
- 29 // speed
- 30 m_motor.Set(speed);
- 31 }
- 32 }
- 33 }
- 34 frc::DigitalInput m_toplimitSwitch{0};
- 35 frc::DigitalInput m_bottomlimitSwitch{1};
- 36 frc::PWMVictorSPX m_motor{0};
- 37 frc::Joystick m_joystick{0};
+ 40 |
No description provided.