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
@@ -5,7 +5,8 @@
|
||||
"tags": [
|
||||
"Getting Started with Java"
|
||||
],
|
||||
"foldername": "gettingstarted"
|
||||
"foldername": "gettingstarted",
|
||||
"gradlebase": "java"
|
||||
},
|
||||
{
|
||||
"name": "Tank Drive",
|
||||
@@ -16,7 +17,8 @@
|
||||
"Robot and Motor",
|
||||
"Safety"
|
||||
],
|
||||
"foldername": "tankdrive"
|
||||
"foldername": "tankdrive",
|
||||
"gradlebase": "java"
|
||||
},
|
||||
{
|
||||
"name": "Mecanum Drive",
|
||||
@@ -27,7 +29,8 @@
|
||||
"Robot and Motor",
|
||||
"Safety"
|
||||
],
|
||||
"foldername": "mecanumdrive"
|
||||
"foldername": "mecanumdrive",
|
||||
"gradlebase": "java"
|
||||
},
|
||||
{
|
||||
"name": "Ultrasonic",
|
||||
@@ -37,7 +40,8 @@
|
||||
"Robot and Motor",
|
||||
"Analog"
|
||||
],
|
||||
"foldername": "ultrasonic"
|
||||
"foldername": "ultrasonic",
|
||||
"gradlebase": "java"
|
||||
},
|
||||
{
|
||||
"name": "Ultrasonic PID",
|
||||
@@ -47,7 +51,8 @@
|
||||
"Robot and Motor",
|
||||
"Analog"
|
||||
],
|
||||
"foldername": "ultrasonicpid"
|
||||
"foldername": "ultrasonicpid",
|
||||
"gradlebase": "java"
|
||||
},
|
||||
{
|
||||
"name": "Potentiometer PID",
|
||||
@@ -58,7 +63,8 @@
|
||||
"Analog",
|
||||
"Joystick"
|
||||
],
|
||||
"foldername": "potentiometerpid"
|
||||
"foldername": "potentiometerpid",
|
||||
"gradlebase": "java"
|
||||
},
|
||||
{
|
||||
"name": "Gyro",
|
||||
@@ -69,7 +75,8 @@
|
||||
"Analog",
|
||||
"Joystick"
|
||||
],
|
||||
"foldername": "gyro"
|
||||
"foldername": "gyro",
|
||||
"gradlebase": "java"
|
||||
},
|
||||
{
|
||||
"name": "Gyro Mecanum",
|
||||
@@ -80,7 +87,8 @@
|
||||
"Analog",
|
||||
"Joystick"
|
||||
],
|
||||
"foldername": "gyromecanum"
|
||||
"foldername": "gyromecanum",
|
||||
"gradlebase": "java"
|
||||
},
|
||||
{
|
||||
"name": "Motor Controller",
|
||||
@@ -90,7 +98,22 @@
|
||||
"Joystick",
|
||||
"Robot and Motor"
|
||||
],
|
||||
"foldername": "motorcontrol"
|
||||
"foldername": "motorcontrol",
|
||||
"gradlebase": "java"
|
||||
},
|
||||
{
|
||||
"name": "Motor Control With Encoder",
|
||||
"description": "Demonstrate controlling a single motor with a Joystick and displaying the net movement of the motor using an encoder.",
|
||||
"tags": [
|
||||
"Robot and Motor",
|
||||
"Digital",
|
||||
"Sensors",
|
||||
"Actuators",
|
||||
"Joystick",
|
||||
"Complete List"
|
||||
],
|
||||
"foldername": "motorcontrolencoder",
|
||||
"gradlebase": "java"
|
||||
},
|
||||
{
|
||||
"name": "GearsBot",
|
||||
@@ -98,7 +121,8 @@
|
||||
"tags": [
|
||||
"Complete Robot"
|
||||
],
|
||||
"foldername": "gearsbot"
|
||||
"foldername": "gearsbot",
|
||||
"gradlebase": "java"
|
||||
},
|
||||
{
|
||||
"name": "PacGoat",
|
||||
@@ -106,7 +130,8 @@
|
||||
"tags": [
|
||||
"Complete Robot"
|
||||
],
|
||||
"foldername": "pacgoat"
|
||||
"foldername": "pacgoat",
|
||||
"gradlebase": "java"
|
||||
},
|
||||
{
|
||||
"name": "Simple Vision",
|
||||
@@ -115,7 +140,8 @@
|
||||
"Vision",
|
||||
"Complete List"
|
||||
],
|
||||
"foldername": "simplevision"
|
||||
"foldername": "quickvision",
|
||||
"gradlebase": "java"
|
||||
},
|
||||
{
|
||||
"name": "Intermediate Vision",
|
||||
@@ -124,7 +150,8 @@
|
||||
"Vision",
|
||||
"Complete List"
|
||||
],
|
||||
"foldername": "intermediatevision"
|
||||
"foldername": "intermediatevision",
|
||||
"gradlebase": "java"
|
||||
},
|
||||
{
|
||||
"name": "Axis Camera Sample",
|
||||
@@ -132,6 +159,7 @@
|
||||
"tags": [
|
||||
"Vision"
|
||||
],
|
||||
"foldername": "axiscamera"
|
||||
"foldername": "axiscamera",
|
||||
"gradlebase": "java"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
package edu.wpi.first.wpilibj.examples.motorcontrolencoder;
|
||||
|
||||
import edu.wpi.first.wpilibj.Encoder;
|
||||
import edu.wpi.first.wpilibj.IterativeRobot;
|
||||
import edu.wpi.first.wpilibj.Joystick;
|
||||
import edu.wpi.first.wpilibj.SpeedController;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||
import edu.wpi.first.wpilibj.Spark;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* <p>Joystick analog values range from -1 to 1 and speed controller inputs also
|
||||
* range from -1 to 1 making it easy to work together.
|
||||
*
|
||||
* <p>In addition, the encoder value of an encoder connected to ports 0 and 1 is
|
||||
* consistently sent to the Dashboard.
|
||||
*/
|
||||
public class Robot extends IterativeRobot {
|
||||
private static final int kMotorPort = 0;
|
||||
private static final int kJoystickPort = 0;
|
||||
private static final int kEncoderPortA = 0;
|
||||
private static final int kEncoderPortB = 1;
|
||||
|
||||
private SpeedController m_motor;
|
||||
private Joystick m_joystick;
|
||||
private Encoder m_encoder;
|
||||
|
||||
@Override
|
||||
public void robotInit() {
|
||||
m_motor = new Spark(kMotorPort);
|
||||
m_joystick = new Joystick(kJoystickPort);
|
||||
m_encoder = new Encoder(kEncoderPortA, kEncoderPortB);
|
||||
// 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((Math.PI * 6) / 360.0);
|
||||
}
|
||||
|
||||
/*
|
||||
* The RobotPeriodic function is called every control packet no matter the
|
||||
* robot mode.
|
||||
*/
|
||||
@Override
|
||||
public void robotPeriodic() {
|
||||
SmartDashboard.putNumber("Encoder", m_encoder.getDistance());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleopPeriodic() {
|
||||
m_motor.set(m_joystick.getY());
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,8 @@
|
||||
"tags": [
|
||||
"Iterative"
|
||||
],
|
||||
"foldername": "iterative"
|
||||
"foldername": "iterative",
|
||||
"gradlebase": "java"
|
||||
},
|
||||
{
|
||||
"name": "Timed Robot",
|
||||
@@ -13,7 +14,8 @@
|
||||
"tags": [
|
||||
"Timed"
|
||||
],
|
||||
"foldername": "timed"
|
||||
"foldername": "timed",
|
||||
"gradlebase": "java"
|
||||
},
|
||||
{
|
||||
"name": "Command Robot",
|
||||
@@ -21,7 +23,8 @@
|
||||
"tags": [
|
||||
"Command"
|
||||
],
|
||||
"foldername": "commandbased"
|
||||
"foldername": "commandbased",
|
||||
"gradlebase": "java"
|
||||
},
|
||||
{
|
||||
"name": "Sample Robot",
|
||||
@@ -29,6 +32,7 @@
|
||||
"tags": [
|
||||
"Sample"
|
||||
],
|
||||
"foldername": "sample"
|
||||
"foldername": "sample",
|
||||
"gradlebase": "java"
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user