mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
Merge branch 'main' into 2027
This commit is contained in:
@@ -5,12 +5,8 @@
|
||||
#include "frc/Joystick.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <numbers>
|
||||
|
||||
#include <hal/FRCUsageReporting.h>
|
||||
#include <units/dimensionless.h>
|
||||
#include <units/math.h>
|
||||
#include <wpi/deprecated.h>
|
||||
|
||||
#include "frc/event/BooleanEvent.h"
|
||||
|
||||
@@ -123,6 +119,5 @@ double Joystick::GetMagnitude() const {
|
||||
}
|
||||
|
||||
units::radian_t Joystick::GetDirection() const {
|
||||
return units::math::atan2(units::dimensionless::scalar_t{GetX()},
|
||||
units::dimensionless::scalar_t{-GetY()});
|
||||
return units::radian_t{std::atan2(GetX(), -GetY())};
|
||||
}
|
||||
|
||||
@@ -42,6 +42,15 @@ void DCMotorSim::SetState(units::radian_t angularPosition,
|
||||
SetState(Vectord<2>{angularPosition, angularVelocity});
|
||||
}
|
||||
|
||||
void DCMotorSim::SetAngle(units::radian_t angularPosition) {
|
||||
SetState(angularPosition, GetAngularVelocity());
|
||||
}
|
||||
|
||||
void DCMotorSim::SetAngularVelocity(
|
||||
units::radians_per_second_t angularVelocity) {
|
||||
SetState(GetAngularPosition(), angularVelocity);
|
||||
}
|
||||
|
||||
units::radian_t DCMotorSim::GetAngularPosition() const {
|
||||
return units::radian_t{GetOutput(0)};
|
||||
}
|
||||
@@ -76,3 +85,15 @@ void DCMotorSim::SetInputVoltage(units::volt_t voltage) {
|
||||
SetInput(Vectord<1>{voltage.value()});
|
||||
ClampInput(frc::RobotController::GetBatteryVoltage().value());
|
||||
}
|
||||
|
||||
const DCMotor& DCMotorSim::GetGearbox() const {
|
||||
return m_gearbox;
|
||||
}
|
||||
|
||||
double DCMotorSim::GetGearing() const {
|
||||
return m_gearing;
|
||||
}
|
||||
|
||||
units::kilogram_square_meter_t DCMotorSim::GetJ() const {
|
||||
return m_j;
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* A class for driving addressable LEDs, such as WS2812Bs and NeoPixels.
|
||||
* A class for driving addressable LEDs, such as WS2812B, WS2815, and NeoPixels.
|
||||
*
|
||||
* By default, the timing supports WS2812B LEDs, but is configurable using
|
||||
* SetBitTiming()
|
||||
* By default, the timing supports WS2812B and WS2815 LEDs, but is configurable
|
||||
* using SetBitTiming()
|
||||
*
|
||||
* <p>Only 1 LED driver is currently supported by the roboRIO. However,
|
||||
* multiple LED strips can be connected in series and controlled from the
|
||||
@@ -130,8 +130,8 @@ class AddressableLED {
|
||||
/**
|
||||
* Sets the bit timing.
|
||||
*
|
||||
* <p>By default, the driver is set up to drive WS2812Bs, so nothing needs to
|
||||
* be set for those.
|
||||
* <p>By default, the driver is set up to drive WS2812B and WS2815, so nothing
|
||||
* needs to be set for those.
|
||||
*
|
||||
* @param highTime0 high time for 0 bit (default 400ns)
|
||||
* @param lowTime0 low time for 0 bit (default 900ns)
|
||||
@@ -146,7 +146,7 @@ class AddressableLED {
|
||||
* Sets the sync time.
|
||||
*
|
||||
* <p>The sync time is the time to hold output so LEDs enable. Default set for
|
||||
* WS2812B.
|
||||
* WS2812B and WS2815.
|
||||
*
|
||||
* @param syncTime the sync time (default 280us)
|
||||
*/
|
||||
|
||||
@@ -45,6 +45,20 @@ class DCMotorSim : public LinearSystemSim<2, 1, 2> {
|
||||
void SetState(units::radian_t angularPosition,
|
||||
units::radians_per_second_t angularVelocity);
|
||||
|
||||
/**
|
||||
* Sets the DC motor's angular position.
|
||||
*
|
||||
* @param angularPosition The new position in radians.
|
||||
*/
|
||||
void SetAngle(units::radian_t angularPosition);
|
||||
|
||||
/**
|
||||
* Sets the DC motor's angular velocity.
|
||||
*
|
||||
* @param angularVelocity The new velocity in radians per second.
|
||||
*/
|
||||
void SetAngularVelocity(units::radians_per_second_t angularVelocity);
|
||||
|
||||
/**
|
||||
* Returns the DC motor position.
|
||||
*
|
||||
@@ -97,17 +111,17 @@ class DCMotorSim : public LinearSystemSim<2, 1, 2> {
|
||||
/**
|
||||
* Returns the gearbox.
|
||||
*/
|
||||
const DCMotor& Gearbox() const { return m_gearbox; }
|
||||
const DCMotor& GetGearbox() const;
|
||||
|
||||
/**
|
||||
* Returns the gearing;
|
||||
*/
|
||||
double Gearing() const { return m_gearing; }
|
||||
double GetGearing() const;
|
||||
|
||||
/**
|
||||
* Returns the moment of inertia
|
||||
*/
|
||||
units::kilogram_square_meter_t J() const { return m_j; }
|
||||
units::kilogram_square_meter_t GetJ() const;
|
||||
|
||||
private:
|
||||
DCMotor m_gearbox;
|
||||
|
||||
Reference in New Issue
Block a user