2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2019-11-21 19:52:56 -08:00
|
|
|
|
|
|
|
|
#include <frc/geometry/Translation2d.h>
|
|
|
|
|
#include <frc/kinematics/MecanumDriveKinematics.h>
|
|
|
|
|
#include <frc/trajectory/TrapezoidProfile.h>
|
2020-06-29 22:25:09 -07:00
|
|
|
#include <units/acceleration.h>
|
|
|
|
|
#include <units/angle.h>
|
2022-08-17 13:42:36 -07:00
|
|
|
#include <units/angular_acceleration.h>
|
2020-06-29 22:25:09 -07:00
|
|
|
#include <units/angular_velocity.h>
|
|
|
|
|
#include <units/length.h>
|
|
|
|
|
#include <units/time.h>
|
|
|
|
|
#include <units/velocity.h>
|
|
|
|
|
#include <units/voltage.h>
|
2021-05-26 00:09:36 -07:00
|
|
|
#include <wpi/numbers>
|
2019-11-21 19:52:56 -08:00
|
|
|
|
|
|
|
|
#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 {
|
|
|
|
|
constexpr int kFrontLeftMotorPort = 0;
|
|
|
|
|
constexpr int kRearLeftMotorPort = 1;
|
|
|
|
|
constexpr int kFrontRightMotorPort = 2;
|
|
|
|
|
constexpr int kRearRightMotorPort = 3;
|
|
|
|
|
|
|
|
|
|
constexpr int kFrontLeftEncoderPorts[]{0, 1};
|
|
|
|
|
constexpr int kRearLeftEncoderPorts[]{2, 3};
|
|
|
|
|
constexpr int kFrontRightEncoderPorts[]{4, 5};
|
2021-05-15 21:39:00 -07:00
|
|
|
constexpr int kRearRightEncoderPorts[]{6, 7};
|
2019-11-21 19:52:56 -08:00
|
|
|
|
|
|
|
|
constexpr bool kFrontLeftEncoderReversed = false;
|
|
|
|
|
constexpr bool kRearLeftEncoderReversed = true;
|
|
|
|
|
constexpr bool kFrontRightEncoderReversed = false;
|
|
|
|
|
constexpr bool kRearRightEncoderReversed = true;
|
|
|
|
|
|
|
|
|
|
constexpr auto kTrackWidth =
|
|
|
|
|
0.5_m; // Distance between centers of right and left wheels on robot
|
|
|
|
|
constexpr auto kWheelBase =
|
|
|
|
|
0.7_m; // Distance between centers of front and back wheels on robot
|
|
|
|
|
extern const frc::MecanumDriveKinematics kDriveKinematics;
|
|
|
|
|
|
|
|
|
|
constexpr int kEncoderCPR = 1024;
|
2021-07-11 10:38:13 -04:00
|
|
|
constexpr double kWheelDiameterMeters = 0.15;
|
2019-11-21 19:52:56 -08:00
|
|
|
constexpr double kEncoderDistancePerPulse =
|
|
|
|
|
// Assumes the encoders are directly mounted on the wheel shafts
|
2021-05-26 00:09:36 -07:00
|
|
|
(kWheelDiameterMeters * wpi::numbers::pi) /
|
|
|
|
|
static_cast<double>(kEncoderCPR);
|
2019-11-21 19:52:56 -08:00
|
|
|
|
|
|
|
|
// These are example values only - DO NOT USE THESE FOR YOUR OWN ROBOT!
|
|
|
|
|
// These characterization values MUST be determined either experimentally or
|
2021-12-11 21:25:43 -08:00
|
|
|
// theoretically for *your* robot's drive. The SysId tool provides a convenient
|
|
|
|
|
// method for obtaining these values for your robot.
|
2019-11-21 19:52:56 -08:00
|
|
|
constexpr auto ks = 1_V;
|
|
|
|
|
constexpr auto kv = 0.8 * 1_V * 1_s / 1_m;
|
|
|
|
|
constexpr auto ka = 0.15 * 1_V * 1_s * 1_s / 1_m;
|
|
|
|
|
|
|
|
|
|
// Example value only - as above, this must be tuned for your drive!
|
|
|
|
|
constexpr double kPFrontLeftVel = 0.5;
|
|
|
|
|
constexpr double kPRearLeftVel = 0.5;
|
|
|
|
|
constexpr double kPFrontRightVel = 0.5;
|
|
|
|
|
constexpr double kPRearRightVel = 0.5;
|
|
|
|
|
} // namespace DriveConstants
|
|
|
|
|
|
|
|
|
|
namespace AutoConstants {
|
2022-08-17 13:42:36 -07:00
|
|
|
constexpr auto kMaxSpeed = 3_mps;
|
|
|
|
|
constexpr auto kMaxAcceleration = 3_mps_sq;
|
|
|
|
|
constexpr auto kMaxAngularSpeed = 3_rad_per_s;
|
|
|
|
|
constexpr auto kMaxAngularAcceleration = 3_rad_per_s_sq;
|
2019-11-21 19:52:56 -08:00
|
|
|
|
|
|
|
|
constexpr double kPXController = 0.5;
|
|
|
|
|
constexpr double kPYController = 0.5;
|
|
|
|
|
constexpr double kPThetaController = 0.5;
|
|
|
|
|
|
2019-12-25 00:42:14 -06:00
|
|
|
extern const frc::TrapezoidProfile<units::radians>::Constraints
|
|
|
|
|
kThetaControllerConstraints;
|
2019-11-21 19:52:56 -08:00
|
|
|
|
|
|
|
|
} // namespace AutoConstants
|
|
|
|
|
|
|
|
|
|
namespace OIConstants {
|
2021-08-01 06:39:50 +03:00
|
|
|
constexpr int kDriverControllerPort = 0;
|
2019-11-21 19:52:56 -08:00
|
|
|
} // namespace OIConstants
|