mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Adds tests to ensure all examples have matching item in json file (#1079)
Also checks that all items in the json file have a matching example One was missing from C++, that example was added (The one in eclipse was completely wrong)
This commit is contained in:
committed by
Peter Johnson
parent
c4728d291e
commit
863cfde394
@@ -0,0 +1,51 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <Encoder.h>
|
||||
#include <IterativeRobot.h>
|
||||
#include <Joystick.h>
|
||||
#include <SmartDashboard/SmartDashboard.h>
|
||||
#include <Spark.h>
|
||||
|
||||
constexpr double kPi = 3.14159265358979;
|
||||
|
||||
/**
|
||||
* This sample program shows how to control a motor using a joystick. In the
|
||||
* operator control part of the program, the joystick is read and the value is
|
||||
* written to the motor.
|
||||
*
|
||||
* Joystick analog values range from -1 to 1 and speed controller inputs as
|
||||
* range from -1 to 1 making it easy to work together.
|
||||
*
|
||||
* In addition, the encoder value of an encoder connected to ports 0 and 1 is
|
||||
* consistently sent to the Dashboard.
|
||||
*/
|
||||
class Robot : public frc::IterativeRobot {
|
||||
public:
|
||||
void TeleopPeriodic() override { m_motor.Set(m_stick.GetY()); }
|
||||
|
||||
/*
|
||||
* The RobotPeriodic function is called every control packet no matter the
|
||||
* robot mode.
|
||||
*/
|
||||
void RobotPeriodic() override {
|
||||
frc::SmartDashboard::PutNumber("Encoder", m_encoder.GetDistance());
|
||||
}
|
||||
|
||||
void RobotInit() override {
|
||||
// Use SetDistancePerPulse to set the multiplier for GetDistance
|
||||
// This is set up assuming a 6 inch wheel with a 360 CPR encoder.
|
||||
m_encoder.SetDistancePerPulse((kPi * 6) / 360.0);
|
||||
}
|
||||
|
||||
private:
|
||||
frc::Joystick m_stick{0};
|
||||
frc::Spark m_motor{0};
|
||||
frc::Encoder m_encoder{0, 1};
|
||||
};
|
||||
|
||||
int main() { return frc::StartRobot<Robot>(); }
|
||||
@@ -7,7 +7,9 @@
|
||||
"Actuators",
|
||||
"Joystick",
|
||||
"Complete List"
|
||||
]
|
||||
],
|
||||
"foldername": "MotorControl",
|
||||
"gradlebase": "cpp"
|
||||
},
|
||||
{
|
||||
"name": "Motor Control With Encoder",
|
||||
@@ -19,7 +21,9 @@
|
||||
"Actuators",
|
||||
"Joystick",
|
||||
"Complete List"
|
||||
]
|
||||
],
|
||||
"foldername": "MotorControlEncoder",
|
||||
"gradlebase": "cpp"
|
||||
},
|
||||
{
|
||||
"name": "Relay",
|
||||
@@ -28,7 +32,9 @@
|
||||
"Actuators",
|
||||
"Joystick",
|
||||
"Complete List"
|
||||
]
|
||||
],
|
||||
"foldername": "Relay",
|
||||
"gradlebase": "cpp"
|
||||
},
|
||||
{
|
||||
"name": "PDP CAN Monitoring",
|
||||
@@ -37,7 +43,9 @@
|
||||
"Complete List",
|
||||
"CAN",
|
||||
"Sensors"
|
||||
]
|
||||
],
|
||||
"foldername": "CANPDP",
|
||||
"gradlebase": "cpp"
|
||||
},
|
||||
{
|
||||
"name": "Solenoids",
|
||||
@@ -47,7 +55,9 @@
|
||||
"Joystick",
|
||||
"Pneumatics",
|
||||
"Complete List"
|
||||
]
|
||||
],
|
||||
"foldername": "Solenoid",
|
||||
"gradlebase": "cpp"
|
||||
},
|
||||
{
|
||||
"name": "Encoder",
|
||||
@@ -56,7 +66,9 @@
|
||||
"Complete List",
|
||||
"Digital",
|
||||
"Sensors"
|
||||
]
|
||||
],
|
||||
"foldername": "Encoder",
|
||||
"gradlebase": "cpp"
|
||||
},
|
||||
{
|
||||
"name": "Arcade Drive",
|
||||
@@ -66,7 +78,9 @@
|
||||
"Robot and Motor",
|
||||
"Joystick",
|
||||
"Complete List"
|
||||
]
|
||||
],
|
||||
"foldername": "ArcadeDrive",
|
||||
"gradlebase": "cpp"
|
||||
},
|
||||
{
|
||||
"name": "Mecanum Drive",
|
||||
@@ -76,7 +90,9 @@
|
||||
"Robot and Motor",
|
||||
"Joystick",
|
||||
"Complete List"
|
||||
]
|
||||
],
|
||||
"foldername": "MecanumDrive",
|
||||
"gradlebase": "cpp"
|
||||
},
|
||||
{
|
||||
"name": "Ultrasonic",
|
||||
@@ -86,7 +102,9 @@
|
||||
"Complete List",
|
||||
"Sensors",
|
||||
"Analog"
|
||||
]
|
||||
],
|
||||
"foldername": "Ultrasonic",
|
||||
"gradlebase": "cpp"
|
||||
},
|
||||
{
|
||||
"name": "UltrasonicPID",
|
||||
@@ -96,7 +114,9 @@
|
||||
"Complete List",
|
||||
"Sensors",
|
||||
"Analog"
|
||||
]
|
||||
],
|
||||
"foldername": "UltrasonicPID",
|
||||
"gradlebase": "cpp"
|
||||
},
|
||||
{
|
||||
"name": "Gyro",
|
||||
@@ -107,7 +127,9 @@
|
||||
"Sensors",
|
||||
"Analog",
|
||||
"Joystick"
|
||||
]
|
||||
],
|
||||
"foldername": "Gyro",
|
||||
"gradlebase": "cpp"
|
||||
},
|
||||
{
|
||||
"name": "Gyro Mecanum",
|
||||
@@ -118,7 +140,9 @@
|
||||
"Sensors",
|
||||
"Analog",
|
||||
"Joysitck"
|
||||
]
|
||||
],
|
||||
"foldername": "GyroMecanum",
|
||||
"gradlebase": "cpp"
|
||||
},
|
||||
{
|
||||
"name": "PotentiometerPID",
|
||||
@@ -129,7 +153,9 @@
|
||||
"Complete List",
|
||||
"Sensors",
|
||||
"Analog"
|
||||
]
|
||||
],
|
||||
"foldername": "PotentiometerPID",
|
||||
"gradlebase": "cpp"
|
||||
},
|
||||
{
|
||||
"name": "Getting Started",
|
||||
@@ -137,7 +163,9 @@
|
||||
"tags": [
|
||||
"Getting Started with C++",
|
||||
"Complete List"
|
||||
]
|
||||
],
|
||||
"foldername": "GettingStarted",
|
||||
"gradlebase": "cpp"
|
||||
},
|
||||
{
|
||||
"name": "Simple Vision",
|
||||
@@ -145,7 +173,9 @@
|
||||
"tags": [
|
||||
"Vision",
|
||||
"Complete List"
|
||||
]
|
||||
],
|
||||
"foldername": "QuickVision",
|
||||
"gradlebase": "cpp"
|
||||
},
|
||||
{
|
||||
"name": "Intermediate Vision",
|
||||
@@ -153,7 +183,9 @@
|
||||
"tags": [
|
||||
"Vision",
|
||||
"Complete List"
|
||||
]
|
||||
],
|
||||
"foldername": "IntermediateVision",
|
||||
"gradlebase": "cpp"
|
||||
},
|
||||
{
|
||||
"name": "Axis Camera Sample",
|
||||
@@ -161,7 +193,9 @@
|
||||
"tags": [
|
||||
"Vision",
|
||||
"Complete List"
|
||||
]
|
||||
],
|
||||
"foldername": "AxisCameraSample",
|
||||
"gradlebase": "cpp"
|
||||
},
|
||||
{
|
||||
"name": "GearsBot",
|
||||
@@ -169,7 +203,9 @@
|
||||
"tags": [
|
||||
"CommandBased Robot",
|
||||
"Complete List"
|
||||
]
|
||||
],
|
||||
"foldername": "GearsBot",
|
||||
"gradlebase": "cpp"
|
||||
},
|
||||
{
|
||||
"name": "PacGoat",
|
||||
@@ -177,6 +213,8 @@
|
||||
"tags": [
|
||||
"CommandBased Robot",
|
||||
"Complete List"
|
||||
]
|
||||
],
|
||||
"foldername": "PacGoat",
|
||||
"gradlebase": "cpp"
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user