mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
Cleaned up C++ examples (#672)
This commit is contained in:
committed by
Peter Johnson
parent
6401aa1fde
commit
45d48d6b5a
@@ -26,26 +26,6 @@
|
||||
* autonomous mode.
|
||||
*/
|
||||
class Robot : public frc::IterativeRobot {
|
||||
/**
|
||||
* The Encoder object is constructed with 4 parameters, the last two
|
||||
* being
|
||||
* optional.
|
||||
* The first two parameters (1, 2 in this case) refer to the ports on
|
||||
* the
|
||||
* roboRIO which the encoder uses. Because a quadrature encoder has
|
||||
* two signal wires, the signal from two DIO ports on the roboRIO are
|
||||
* used.
|
||||
* The third (optional) parameter is a boolean which defaults to false.
|
||||
* If you set this parameter to true, the direction of the encoder
|
||||
* will
|
||||
* be reversed, in case it makes more sense mechanically.
|
||||
* The final (optional) parameter specifies encoding rate (k1X, k2X, or
|
||||
* k4X)
|
||||
* and defaults to k4X. Faster (k4X) encoding gives greater positional
|
||||
* precision but more noise in the rate.
|
||||
*/
|
||||
frc::Encoder m_encoder{1, 2, false, Encoder::k4X};
|
||||
|
||||
public:
|
||||
Robot() {
|
||||
/* Defines the number of samples to average when determining the
|
||||
@@ -88,6 +68,27 @@ public:
|
||||
frc::SmartDashboard::PutNumber(
|
||||
"Encoder Rate", m_encoder.GetRate());
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* The Encoder object is constructed with 4 parameters, the last two
|
||||
* being
|
||||
* optional.
|
||||
* The first two parameters (1, 2 in this case) refer to the ports on
|
||||
* the
|
||||
* roboRIO which the encoder uses. Because a quadrature encoder has
|
||||
* two signal wires, the signal from two DIO ports on the roboRIO are
|
||||
* used.
|
||||
* The third (optional) parameter is a boolean which defaults to false.
|
||||
* If you set this parameter to true, the direction of the encoder
|
||||
* will
|
||||
* be reversed, in case it makes more sense mechanically.
|
||||
* The final (optional) parameter specifies encoding rate (k1X, k2X, or
|
||||
* k4X)
|
||||
* and defaults to k4X. Faster (k4X) encoding gives greater positional
|
||||
* precision but more noise in the rate.
|
||||
*/
|
||||
frc::Encoder m_encoder{1, 2, false, Encoder::k4X};
|
||||
};
|
||||
|
||||
START_ROBOT_CLASS(Robot)
|
||||
|
||||
Reference in New Issue
Block a user