mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Add C++20 std::math constants shim (#1788)
Based on http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0631r7.pdf
This commit is contained in:
committed by
Peter Johnson
parent
dd43109596
commit
37d316aa09
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2017-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. */
|
||||
@@ -11,14 +11,13 @@
|
||||
#include <cmath>
|
||||
|
||||
#include <hal/HAL.h>
|
||||
#include <wpi/math>
|
||||
|
||||
#include "frc/SpeedController.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
constexpr double kPi = 3.14159265358979323846;
|
||||
|
||||
KilloughDrive::KilloughDrive(SpeedController& leftMotor,
|
||||
SpeedController& rightMotor,
|
||||
SpeedController& backMotor)
|
||||
@@ -30,12 +29,12 @@ KilloughDrive::KilloughDrive(SpeedController& leftMotor,
|
||||
SpeedController& backMotor, double leftMotorAngle,
|
||||
double rightMotorAngle, double backMotorAngle)
|
||||
: m_leftMotor(leftMotor), m_rightMotor(rightMotor), m_backMotor(backMotor) {
|
||||
m_leftVec = {std::cos(leftMotorAngle * (kPi / 180.0)),
|
||||
std::sin(leftMotorAngle * (kPi / 180.0))};
|
||||
m_rightVec = {std::cos(rightMotorAngle * (kPi / 180.0)),
|
||||
std::sin(rightMotorAngle * (kPi / 180.0))};
|
||||
m_backVec = {std::cos(backMotorAngle * (kPi / 180.0)),
|
||||
std::sin(backMotorAngle * (kPi / 180.0))};
|
||||
m_leftVec = {std::cos(leftMotorAngle * (wpi::math::pi / 180.0)),
|
||||
std::sin(leftMotorAngle * (wpi::math::pi / 180.0))};
|
||||
m_rightVec = {std::cos(rightMotorAngle * (wpi::math::pi / 180.0)),
|
||||
std::sin(rightMotorAngle * (wpi::math::pi / 180.0))};
|
||||
m_backVec = {std::cos(backMotorAngle * (wpi::math::pi / 180.0)),
|
||||
std::sin(backMotorAngle * (wpi::math::pi / 180.0))};
|
||||
AddChild(&m_leftMotor);
|
||||
AddChild(&m_rightMotor);
|
||||
AddChild(&m_backMotor);
|
||||
@@ -84,8 +83,9 @@ void KilloughDrive::DrivePolar(double magnitude, double angle,
|
||||
reported = true;
|
||||
}
|
||||
|
||||
DriveCartesian(magnitude * std::sin(angle * (kPi / 180.0)),
|
||||
magnitude * std::cos(angle * (kPi / 180.0)), zRotation, 0.0);
|
||||
DriveCartesian(magnitude * std::sin(angle * (wpi::math::pi / 180.0)),
|
||||
magnitude * std::cos(angle * (wpi::math::pi / 180.0)),
|
||||
zRotation, 0.0);
|
||||
}
|
||||
|
||||
void KilloughDrive::StopMotor() {
|
||||
|
||||
Reference in New Issue
Block a user