Add new C++ Command framework (#1785)

This is the C++ version of #1682.

The old command framework is still available, but will be deprecated.

Due to name conflicts, the new framework is in the frc2 namespace.
Eventually (after the old command framework is removed in a future year)
it will be moved into the main frc namespace.
This commit is contained in:
Oblarg
2019-08-25 23:55:59 -04:00
committed by Peter Johnson
parent a0be07c370
commit 076ed7770c
196 changed files with 10687 additions and 163 deletions

View File

@@ -0,0 +1,73 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 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. */
/*----------------------------------------------------------------------------*/
#pragma once
/**
* The Constants header provides a convenient place for teams to hold robot-wide
* numerical or bool constants. This should not be used for any other purpose.
*
* It is generally a good idea to place constants into subsystem- or
* command-specific namespaces within this header, which can then be used where
* they are needed.
*/
namespace DriveConstants {
const int kLeftMotor1Port = 0;
const int kLeftMotor2Port = 1;
const int kRightMotor1Port = 2;
const int kRightMotor2Port = 3;
const int kLeftEncoderPorts[]{0, 1};
const int kRightEncoderPorts[]{2, 3};
const bool kLeftEncoderReversed = false;
const bool kRightEncoderReversed = true;
const int kEncoderCPR = 1024;
const double kWheelDiameterInches = 6;
const double kEncoderDistancePerPulse =
// Assumes the encoders are directly mounted on the wheel shafts
(kWheelDiameterInches * 3.142) / static_cast<double>(kEncoderCPR);
} // namespace DriveConstants
namespace ShooterConstants {
const int kEncoderPorts[]{4, 5};
const bool kEncoderReversed = false;
const int kEncoderCPR = 1024;
const double kEncoderDistancePerPulse =
// Distance units will be rotations
1. / static_cast<double>(kEncoderCPR);
const int kShooterMotorPort = 4;
const int kFeederMotorPort = 5;
const double kShooterFreeRPS = 5300;
const double kShooterTargetRPS = 4000;
const double kShooterToleranceRPS = 50;
const double kP = 1;
const double kI = 0;
const double kD = 0;
// On a real robot the feedforward constants should be empirically determined;
// these are reasonable guesses.
const double kSFractional = .05;
const double kVFractional =
// Should have value 1 at free speed...
1. / kShooterFreeRPS;
const double kFeederSpeed = .5;
} // namespace ShooterConstants
namespace AutoConstants {
const double kAutoTimeoutSeconds = 12;
const double kAutoShootTimeSeconds = 7;
} // namespace AutoConstants
namespace OIConstants {
const int kDriverControllerPort = 1;
} // namespace OIConstants