Merge branch 'main' into 2027

This commit is contained in:
Peter Johnson
2025-02-20 00:26:23 -08:00
123 changed files with 4634 additions and 2291 deletions

View File

@@ -24,12 +24,27 @@ namespace frc {
* By default, the timing supports WS2812B and WS2815 LEDs, but is configurable
* using SetBitTiming()
*
* Some LEDs use a different color order than the default GRB. The color order
* is configurable using SetColorOrder().
*
* <p>Only 1 LED driver is currently supported by the roboRIO. However,
* multiple LED strips can be connected in series and controlled from the
* single driver.
*/
class AddressableLED {
public:
/**
* Order that color data is sent over the wire.
*/
enum ColorOrder {
kRGB = HAL_ALED_RGB, ///< RGB order
kRBG = HAL_ALED_RBG, ///< RBG order
kBGR = HAL_ALED_BGR, ///< BGR order
kBRG = HAL_ALED_BRG, ///< BRG order
kGBR = HAL_ALED_GBR, ///< GBR order
kGRB = HAL_ALED_GRB ///< GRB order. This is the default order.
};
class LEDData : public HAL_AddressableLEDData {
public:
LEDData() : LEDData(0, 0, 0) {}
@@ -95,6 +110,15 @@ class AddressableLED {
AddressableLED(AddressableLED&&) = default;
AddressableLED& operator=(AddressableLED&&) = default;
/**
* Sets the color order for this AddressableLED. The default order is GRB.
*
* This will take effect on the next call to SetData().
*
* @param order the color order
*/
void SetColorOrder(ColorOrder order);
/**
* Sets the length of the LED strip.
*
@@ -169,4 +193,9 @@ class AddressableLED {
hal::Handle<HAL_AddressableLEDHandle, HAL_FreeAddressableLED> m_handle;
int m_port;
};
constexpr auto format_as(AddressableLED::ColorOrder order) {
return static_cast<int32_t>(order);
}
} // namespace frc

View File

@@ -148,6 +148,7 @@ class Joystick : public GenericHID {
* Get the X value of the current joystick.
*
* This depends on the mapping of the joystick connected to the current port.
* On most joysticks, positive is to the right.
*/
double GetX() const;
@@ -155,6 +156,7 @@ class Joystick : public GenericHID {
* Get the Y value of the current joystick.
*
* This depends on the mapping of the joystick connected to the current port.
* On most joysticks, positive is to the back.
*/
double GetY() const;
@@ -244,7 +246,7 @@ class Joystick : public GenericHID {
BooleanEvent Top(EventLoop* loop) const;
/**
* Get the magnitude of the direction vector formed by the joystick's
* Get the magnitude of the vector formed by the joystick's
* current position relative to its origin.
*
* @return The magnitude of the direction vector
@@ -252,7 +254,9 @@ class Joystick : public GenericHID {
double GetMagnitude() const;
/**
* Get the direction of the vector formed by the joystick and its origin.
* Get the direction of the vector formed by the joystick and its origin. 0 is
* forward and clockwise is positive. (Straight right is π/2 radians or 90
* degrees.)
*
* @return The direction of the vector.
*/

View File

@@ -52,11 +52,11 @@ class LinearSystemSim {
* @param dt The time between updates.
*/
void Update(units::second_t dt) {
// Update x. By default, this is the linear system dynamics x_k+1 = Ax_k +
// Bu_k
// Update x. By default, this is the linear system dynamics xₖ₊₁ = Ax +
// Buₖ.
m_x = UpdateX(m_x, m_u, dt);
// y = Cx + Du
// y = Cx + Du
m_y = m_plant.CalculateY(m_x, m_u);
// Add noise. If the user did not pass a noise vector to the
@@ -115,7 +115,14 @@ class LinearSystemSim {
*
* @param state The new state.
*/
void SetState(const Vectord<States>& state) { m_x = state; }
void SetState(const Vectord<States>& state) {
m_x = state;
// Update the output to reflect the new state.
//
// yₖ = Cxₖ + Duₖ
m_y = m_plant.CalculateY(m_x, m_u);
}
protected:
/**