### CTRE Phoenix 6 TwinkleAnimation Constructor Example Source: https://api.ctr-electronics.com/phoenix6/release/cpp/_twinkle_animation_8hpp_source Demonstrates the constructor for the TwinkleAnimation class, initializing the LED start and end indices. This is used to define the range of LEDs affected by the animation. ```cpp TwinkleAnimation(int LEDStartIndex, int LEDEndIndex) : ControlRequest{"TwinkleAnimation"}, LEDStartIndex{std::move(LEDStartIndex)}, LEDEndIndex{std::move(LEDEndIndex)} {} ``` -------------------------------- ### CoreCANdi Configuration and Initialization Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1hardware_1_1core_1_1_core_c_a_ndi-members Methods for initializing and configuring the CoreCANdi device, including constructor overloads and accessing the configuration interface. ```APIDOC ## CoreCANdi Configuration and Initialization ### Description Methods for initializing and configuring the CoreCANdi device, including constructor overloads and accessing the configuration interface. ### Methods #### Constructor (int deviceId, std::string canbus="") - **Method**: `CoreCANdi(int deviceId, std::string canbus = "")` - **Description**: Constructs a CoreCANdi object with the specified device ID and CAN bus string. #### Constructor (int deviceId, CANBus canbus) - **Method**: `CoreCANdi(int deviceId, CANBus canbus)` - **Description**: Constructs a CoreCANdi object with the specified device ID and CAN bus object. #### GetConfigurator - **Method**: `GetConfigurator()` or `GetConfigurator() const` - **Description**: Retrieves the configurator object for the CoreCANdi device. ``` -------------------------------- ### ParentDevice - Construction and Destruction Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1hardware_1_1core_1_1_core_c_a_ndle-members Details on how to construct and manage the lifecycle of ParentDevice objects. ```APIDOC ## ParentDevice - Construction and Destruction ### Description Information regarding the instantiation and deallocation of ParentDevice objects. ### Method CONSTRUCTOR / DESTRUCTOR ### Endpoint N/A (Class methods) ### Parameters #### Constructor Parameters - **deviceID** (int) - Required - The unique identifier for the device. - **model** (std::string) - Required - The model name of the device. - **canbus** (std::string) - Required - The CAN bus identifier. ### Request Example ```json { "deviceID": 1, "model": "CANdle", "canbus": "CAN 1" } ``` ### Response #### Success Response (200) - **device** (ParentDevice) - The newly constructed ParentDevice object. #### Response Example ```json { "device": "ParentDevice Object" } ``` ``` -------------------------------- ### Get Missing Differential FX Fault Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1hardware_1_1traits_1_1_common_talon_with_external_motor Checks if the remote Talon used for differential control is missing from the CAN Bus. This function helps identify communication failures in differential setups, with a refresh option. ```cpp virtual StatusSignal< bool > & | GetFault_MissingDifferentialFX (bool refresh=true)=0 ``` -------------------------------- ### General Signals and Configurations Source: https://api.ctr-electronics.com/phoenix6/release/cpp/functions_m Documentation for general signals, device identification, and various control parameters. ```APIDOC ## General Signals and Configurations ### Description This section covers various general signals, health values, device identification, and other miscellaneous configurations within the Phoenix 6 library. ### Method N/A (Definitions) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None **Signals:** * `MeasurementHealthValue()`: ctre::phoenix6::signals::MeasurementHealthValue * `MinSignalStrengthForValidMeasurement`: ctre::phoenix6::configs::ProximityParamsConfigs * `Modulated`: ctre::phoenix6::signals::VBatOutputModeValue * `ModulateVBatOut()`: ctre::phoenix6::controls::ModulateVBatOut **Device Information:** * `model`: ctre::phoenix6::hardware::DeviceIdentifier **Control Parameters:** * `MaxAbsDutyCycle`: ctre::phoenix6::controls::TorqueCurrentFOC * `MaxAbsRotationalRate`: ctre::phoenix6::swerve::requests::FieldCentricFacingAngle, ctre::phoenix6::swerve::requests::RobotCentricFacingAngle * `MaxLEDsOnProportion`: ctre::phoenix6::controls::TwinkleAnimation, ctre::phoenix6::controls::TwinkleOffAnimation **Motor Values:** * `Minion_JST`: ctre::phoenix6::signals::ConnectedMotorValue, ctre::phoenix6::signals::MotorArrangementValue **Master/Follower Controls:** * `MasterID`: ctre::phoenix6::controls::DifferentialFollower, ctre::phoenix6::controls::DifferentialStrictFollower, ctre::phoenix6::controls::Follower, ctre::phoenix6::controls::StrictFollower **Event Handling:** * `ManualEvent()`: ctre::phoenix::threading::ManualEvent **Status Codes:** * `MechanismFaulted`: ctre::phoenix::StatusCode * `MissingContext`: ctre::phoenix::StatusCode * `MissingRoutineInLibrary`: ctre::phoenix::StatusCode * `ModelMismatch`: ctre::phoenix::StatusCode * `MODULE_NOT_INIT_GET_ERROR`: ctre::phoenix::StatusCode * `MODULE_NOT_INIT_SET_ERROR`: ctre::phoenix::StatusCode * `MoreThanOneFile`: ctre::phoenix::StatusCode ``` -------------------------------- ### Get Differential Control Outputs (C++) Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1hardware_1_1core_1_1_core_talon_f_x Retrieves control outputs specifically for differential drive systems. GetDifferentialOutput provides the calculated motor output for differential followers, while GetDifferentialClosedLoopProportionalOutput offers the proportional component of the closed-loop control for differential setups. ```cpp StatusSignal< double > & GetDifferentialOutput (bool refresh=true) override; StatusSignal< double > & GetDifferentialClosedLoopProportionalOutput (bool refresh=true) override; ``` -------------------------------- ### Configure ColorFlowAnimation LED Start Index (C++) Source: https://api.ctr-electronics.com/phoenix6/release/cpp/_color_flow_animation_8hpp_source Sets the starting index for the LED animation and returns the object for method chaining. Handles onboard and strip LEDs, and reverses direction if start index exceeds end index. Requires an integer for the new start index. ```cpp ColorFlowAnimation &WithLEDStartIndex(int newLEDStartIndex) { LEDStartIndex = std::move(newLEDStartIndex); return *this; } ``` -------------------------------- ### Pigeon2 Hardware and Configuration Source: https://api.ctr-electronics.com/phoenix6/release/cpp/functions_p Documentation for Pigeon2 hardware, including its configuration and simulation state. ```APIDOC ## Pigeon2 Hardware and Configuration ### Description Provides access to the Pigeon2 IMU hardware, its configurations, and simulation state. ### Method N/A (Class constructors, properties, and methods) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### CANdi Device Configuration and State Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1hardware_1_1core_1_1_core_c_a_ndi Provides access to the CANdi device's configuration and simulation state. ```APIDOC ## CoreCANdi Constructors ### Description Constructs a new CANdi object with the specified device ID and optional CAN bus configuration. ### Method Constructor ### Parameters #### Path Parameters - **deviceId** (int) - Required - The unique identifier for the CANdi device. - **canbus** (std::string) - Optional - The CAN bus interface to use. - **canbus** (CANBus) - Optional - The CAN bus interface to use (enum type). ### Response #### Success Response (200) - **CANdi object** - A newly constructed CANdi object. ## GetConfigurator API ### Description Retrieves the configuration object for the CANdi device, allowing modification of settings. ### Method GET ### Endpoint `/websites/api_ctr-electronics_phoenix6_release_cpp/GetConfigurator` ### Response #### Success Response (200) - **configs::CANdiConfigurator** - The configurator object for the CANdi device. ## GetSimState API ### Description Retrieves the simulation state object for the CANdi device. ### Method GET ### Endpoint `/websites/api_ctr-electronics_phoenix6_release_cpp/GetSimState` ### Response #### Success Response (200) - **sim::CANdiSimState** - The simulation state object for the CANdi device. ``` -------------------------------- ### Get Target State Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1swerve_1_1impl_1_1_swerve_module_impl Get the target state of the module. ```APIDOC ## GET /state/target ### Description Get the target state of the module. ### Method GET ### Endpoint `/state/target` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) - **state** (SwerveModuleState) - The target state of the module #### Response Example ```json { "state": { "angle": "...", "velocity": "..." } } ``` ``` -------------------------------- ### Apply Configurations Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1mechanisms_1_1_simple_differential_mechanism Applies the mechanism configurations to the associated devices. ```APIDOC ## Apply Configurations ### Description Applies the configured settings to all hardware devices associated with the differential mechanism. ### Method POST ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **numRetries** (int) - Optional - The number of retries for applying configurations. Defaults to kDefaultConfigRetries. ### Request Example N/A ### Response #### Success Response (200) - **ctre::phoenix::StatusCode** - Status code indicating the result of the operation. #### Response Example N/A ## ctre::phoenix::StatusCode ApplyConfigs (int numRetries=kDefaultConfigRetries) ``` -------------------------------- ### C++ Span Deduction Guides Source: https://api.ctr-electronics.com/phoenix6/release/cpp/span_8hpp_source Demonstrates C++ deduction guides for constructing span objects from various C++ containers and arrays. These guides simplify span instantiation. ```cpp template span(T (&)[N])->span; template span(std::array&)->span; template span(const std::array&)->span; template span(Container&)->span; template span(const Container&)->span; ``` -------------------------------- ### Get Position Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1swerve_1_1_swerve_module Gets the current state of the swerve module, including latency-compensated values. ```APIDOC ## Get Position ### Description Gets the state of this module and passes it back as a SwerveModulePosition object with latency compensated values. ### Method `GetPosition(bool refresh)` ### Endpoint N/A (Member Function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```cpp // Get the module's position, forcing a refresh if needed SwerveModulePosition position = module.GetPosition(true); ``` ### Response #### Success Response (200) - **SwerveModulePosition** (object) - An object containing the module's current position data. #### Response Example ```json { "drive_rotations": 10.5, "angle_degrees": 90.0 } ``` ``` -------------------------------- ### ParentConfigurator and ParentDevice Source: https://api.ctr-electronics.com/phoenix6/release/cpp/functions_p Details on the ParentConfigurator and ParentDevice classes for managing parent configurations and devices. ```APIDOC ## ParentConfigurator and ParentDevice ### Description Provides access to parent configurator and device functionalities. ### Method N/A (Class constructors and accessors) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Files Source: https://api.ctr-electronics.com/phoenix6/release/cpp/_orchestra_8hpp Documentation for files within the CTRE Phoenix 6 C++ library. ```APIDOC ## Files ### Description Lists and provides access to source code for files within the CTRE Phoenix 6 C++ library, including `CANBus.hpp`, `HootReplay.hpp`, `Orchestra.hpp`, `SignalLogger.hpp`, `StatusSignal.hpp`, and `Timestamp.hpp`. ### Method N/A ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ### Error Handling N/A ``` -------------------------------- ### Get Position Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1swerve_1_1impl_1_1_swerve_module_impl Gets the state of this module and passes it back as a SwerveModulePosition object with latency compensated values. ```APIDOC ## GET /position ### Description Gets the state of this module and passes it back as a SwerveModulePosition object with latency compensated values. ### Method GET ### Endpoint `/position` ### Parameters #### Path Parameters None #### Query Parameters - **refresh** (boolean) - Required - Whether to refresh the signals for latency compensation #### Request Body None ### Request Example ```json { "refresh": true } ``` ### Response #### Success Response (200) - **position** (SwerveModulePosition) - The latency compensated state of the module #### Response Example ```json { "position": { "angle": "...", "velocity": "..." } } ``` ``` -------------------------------- ### Get Steer Closed Loop Output Type Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1swerve_1_1impl_1_1_swerve_module_impl Gets the closed-loop output type to use for the steer motor. ```APIDOC ## GET /config/steerClosedLoopOutputType ### Description Gets the closed-loop output type to use for the steer motor. ### Method GET ### Endpoint `/config/steerClosedLoopOutputType` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) - **outputType** (ClosedLoopOutputType) - The closed-loop output type for the steer motor #### Response Example ```json { "outputType": "SMART_MOTION" } ``` ``` -------------------------------- ### TalonFXSimState Methods Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1sim_1_1_talon_f_x_sim_state-members This section details the methods for interacting with and configuring the TalonFXSimState. ```APIDOC ## SetRotorVelocity /websites/api_ctr-electronics_phoenix6_release_cpp ### Description Sets the simulated rotor velocity of the TalonFX. ### Method `SetRotorVelocity` ### Endpoint N/A (This is a class method, not an HTTP endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **rps** (units::angular_velocity::turns_per_second_t) - Required - The desired rotor velocity in turns per second. ### Request Example ``` // Example usage: talonFXSimState.SetRotorVelocity(units::angular_velocity::turns_per_second_t(5.0)); ``` ### Response #### Success Response (void) This method does not return a value. #### Response Example N/A ``` ```APIDOC ## SetSupplyVoltage /websites/api_ctr-electronics_phoenix6_release_cpp ### Description Sets the simulated supply voltage for the TalonFX. ### Method `SetSupplyVoltage` ### Endpoint N/A (This is a class method, not an HTTP endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **volts** (units::voltage::volt_t) - Required - The desired supply voltage in volts. ### Request Example ``` // Example usage: talonFXSimState.SetSupplyVoltage(units::voltage::volt_t(12.0)); ``` ### Response #### Success Response (void) This method does not return a value. #### Response Example N/A ``` ```APIDOC ## TalonFXSimState Constructor (CoreTalonFX) ### Description Constructs a TalonFXSimState object using a CoreTalonFX device. ### Method `TalonFXSimState` ### Endpoint N/A (This is a class method, not an HTTP endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **device** (hardware::core::CoreTalonFX const &) - Required - The CoreTalonFX device to simulate. ### Request Example ``` // Example usage: auto talonFXSimState = TalonFXSimState(coreTalonFXDevice); ``` ### Response #### Success Response (TalonFXSimState) An instance of TalonFXSimState. #### Response Example N/A ``` ```APIDOC ## TalonFXSimState Constructor (CoreTalonFX, ChassisReference) ### Description Constructs a TalonFXSimState object using a CoreTalonFX device and chassis reference. ### Method `TalonFXSimState` ### Endpoint N/A (This is a class method, not an HTTP endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **device** (hardware::core::CoreTalonFX const &) - Required - The CoreTalonFX device to simulate. * **orientation** (ChassisReference) - Required - The chassis reference for orientation. ### Request Example ``` // Example usage: auto talonFXSimState = TalonFXSimState(coreTalonFXDevice, chassisReference); ``` ### Response #### Success Response (TalonFXSimState) An instance of TalonFXSimState. #### Response Example N/A ``` ```APIDOC ## TalonFXSimState Copy Constructor (Deleted) ### Description The copy constructor for TalonFXSimState is deleted, preventing copying of simulation states. ### Method `TalonFXSimState` ### Endpoint N/A (This is a class method, not an HTTP endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ``` // Copying is not allowed: // TalonFXSimState anotherSimState = originalSimState; ``` ### Response #### Success Response N/A (This is a deleted constructor) #### Response Example N/A ``` ```APIDOC ## TalonFXSimState Move Constructor (Default) ### Description Provides a default move constructor for TalonFXSimState, allowing efficient transfer of resources. ### Method `TalonFXSimState` ### Endpoint N/A (This is a class method, not an HTTP endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ``` // Example usage: TalonFXSimState anotherSimState = std::move(originalSimState); ``` ### Response #### Success Response (TalonFXSimState) An instance of TalonFXSimState after moving resources. #### Response Example N/A ``` -------------------------------- ### CoreCANdle Configuration and Properties Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1hardware_1_1core_1_1_core_c_a_ndle-members Methods for configuring and retrieving properties of the CoreCANdle device. ```APIDOC ## CoreCANdle Configuration and Properties This section details the API endpoints for configuring and retrieving properties of the CoreCANdle device. ### Constructors - **CoreCANdle(int deviceId, std::string canbus="")**: Constructor for CoreCANdle. - **CoreCANdle(int deviceId, CANBus canbus)**: Constructor for CoreCANdle with CANBus object. ### Configuration - **GetConfigurator()**: Returns the configurator for the CoreCANdle. - **GetConfigurator() const**: Returns the configurator for the CoreCANdle (const version). ### Device Information - **deviceIdentifier**: Protected member representing the device identifier. - **GetDeviceHash() const**: Retrieves the device hash. - **GetDeviceID() const**: Retrieves the device ID. - **GetNetwork() const**: Retrieves the network object. - **GetResetOccurredChecker() const**: Retrieves the reset occurred checker. ### CoreCANdle Specific Properties - **GetDeviceTemp(bool refresh=true)**: Retrieves the device temperature. - **GetFiveVRailVoltage(bool refresh=true)**: Retrieves the 5V rail voltage. - **GetIsProLicensed(bool refresh=true)**: Checks if the device is Pro licensed. - **GetMaxSimultaneousAnimationCount(bool refresh=true)**: Retrieves the maximum simultaneous animation count. - **GetOutputCurrent(bool refresh=true)**: Retrieves the output current. - **GetSimState()**: Retrieves the simulation state. ### ParentDevice Properties - **GetAppliedControl()**: Retrieves the applied control. - **GetAppliedControl() const**: Retrieves the applied control (const version). - **GetGenericSignal(uint32_t signal, bool refresh=true)**: Retrieves a generic signal. ``` -------------------------------- ### Get Drive Closed Loop Output Type Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1swerve_1_1impl_1_1_swerve_module_impl Gets the closed-loop output type to use for the drive motor. ```APIDOC ## GET /config/driveClosedLoopOutputType ### Description Gets the closed-loop output type to use for the drive motor. ### Method GET ### Endpoint `/config/driveClosedLoopOutputType` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) - **outputType** (ClosedLoopOutputType) - The closed-loop output type for the drive motor #### Response Example ```json { "outputType": "PERCENTAGE" } ``` ``` -------------------------------- ### Get Current State Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1swerve_1_1impl_1_1_swerve_module_impl Get the current state of the module. This is typically used for telemetry, as the SwerveModulePosition is used for odometry. ```APIDOC ## GET /state/current ### Description Get the current state of the module. This is typically used for telemetry, as the SwerveModulePosition is used for odometry. ### Method GET ### Endpoint `/state/current` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) - **state** (SwerveModuleState) - The current state of the module #### Response Example ```json { "state": { "angle": "...", "velocity": "..." } } ``` ``` -------------------------------- ### SimpleDifferentialMechanism Constructors Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1mechanisms_1_1_simple_differential_mechanism Constructors for initializing a SimpleDifferentialMechanism with different hardware configurations. ```APIDOC ## SimpleDifferentialMechanism Constructors ### Description Initializes a new simple differential mechanism using the specified hardware. ### Method CONSTRUCTOR ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ## SimpleDifferentialMechanism (hardware::TalonFX &differentialAddFX, hardware::TalonFX &differentialSubFX, bool motorDirectionsAlign) ## SimpleDifferentialMechanism (hardware::TalonFX &differentialAddFX, hardware::TalonFX &differentialSubFX, bool motorDirectionsAlign, hardware::Pigeon2 &pigeon2, DifferentialPigeon2Source pigeonSource) ## SimpleDifferentialMechanism (hardware::TalonFX &differentialAddFX, hardware::TalonFX &differentialSubFX, bool motorDirectionsAlign, hardware::CANcoder &cancoder) ``` -------------------------------- ### ReplayAutoEnable Start Function (C++) Source: https://api.ctr-electronics.com/phoenix6/release/cpp/_replay_auto_enable_8hpp_source Starts the automatic enabling of the robot during replay. This function manages a counter to ensure the replay enable is only started when no other actuators require it to be stopped. It depends on `std::mutex` for thread safety and `_enableNotifier` for periodic signaling. ```cpp void Start() { std::lock_guard lock{_lck}; if (_startCount < UINT32_MAX) { if (_startCount++ == 0) { /* start if we were previously at 0 */ _enableNotifier.StartPeriodic(20_ms); } } } ``` -------------------------------- ### Pigeon 2 Initialization and Reset Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1hardware_1_1_pigeon2 Provides methods for initializing the sendable nature of the Pigeon 2 and resetting its heading. ```APIDOC ## Pigeon2 Initialization ### Description Initializes the Pigeon 2 for network table publishing. ### Method `void InitSendable(wpi::SendableBuilder &builder)` ### Parameters #### Path Parameters - **builder** (wpi::SendableBuilder &) - Required - The builder object used for network table integration. ``` ```APIDOC ## Pigeon2 Reset ### Description Resets the Pigeon 2 to a heading of zero degrees. ### Method `void Reset()` ### Request Example ```cpp pigeon.Reset(); ``` ``` -------------------------------- ### VoltageConfigs Constructor Source: https://api.ctr-electronics.com/phoenix6/release/cpp/functions_v Provides details on the constructor for VoltageConfigs, used for setting voltage-related parameters. ```APIDOC ## VoltageConfigs Constructor ### Description This section describes the constructor for the `VoltageConfigs` class, which is used to set various voltage-related parameters for motor controllers. ### Class `ctre::phoenix6::configs::VoltageConfigs()` ``` -------------------------------- ### Get Cached Position Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1swerve_1_1impl_1_1_swerve_module_impl Gets the last cached swerve module position. This differs from GetPosition in that it will not perform any latency compensation or refresh the signals. ```APIDOC ## GET /position/cached ### Description Gets the last cached swerve module position. This differs from GetPosition in that it will not perform any latency compensation or refresh the signals. ### Method GET ### Endpoint `/position/cached` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) - **position** (SwerveModulePosition) - The last cached swerve module position #### Response Example ```json { "position": { "angle": "...", "velocity": "..." } } ``` ``` -------------------------------- ### ParentDevice Constructor and Destructor - C++ Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1hardware_1_1_parent_device Documentation for the constructors and destructor of the ParentDevice class. Includes overloaded constructors for initializing with device ID, model, and CAN bus, as well as a copy constructor and the virtual destructor. ```cpp ctre::phoenix6::hardware::ParentDevice::ParentDevice(int _deviceID_, std::string _model_, std::string _canbus_); virtual ctre::phoenix6::hardware::ParentDevice::~ParentDevice(); ctre::phoenix6::hardware::ParentDevice::ParentDevice(const ParentDevice& __|); ``` -------------------------------- ### ParentDevice: Get Device Hash Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1hardware_1_1_talon_f_x Gets a unique number for this device's hardware type and ID, useful for identifying the device on the network. ```cpp uint64_t | GetDeviceHash () const ``` -------------------------------- ### Signal Input Configuration Source: https://api.ctr-electronics.com/phoenix6/release/cpp/namespacectre_1_1phoenix6_1_1signals Details on configuring and reading the state of Signal 1 (S1IN) and Signal 2 (S2IN) inputs. ```APIDOC ## Signal Input Configuration ### Description Classes for configuring and reading the state of digital signal inputs S1IN and S2IN. ### Classes - **S1CloseStateValue**: Defines the value for S1IN to be detected as Closed. - **S1FloatStateValue**: Represents the floating state of S1IN. - **S1StateValue**: Represents the current state of S1IN. - **S2CloseStateValue**: Defines the value for S2IN to be detected as Closed. - **S2FloatStateValue**: Represents the floating state of S2IN. - **S2StateValue**: Represents the current state of S2IN. ``` -------------------------------- ### Configure Rainbow Animation LED Start Index Source: https://api.ctr-electronics.com/phoenix6/release/cpp/_rainbow_animation_8hpp_source Sets the starting index for the rainbow animation. This method supports method chaining. The index specifies the first LED the animation controls, with 0-7 for onboard LEDs and 8-399 for an attached strip. If the start index exceeds the end index, the animation direction reverses. ```cpp RainbowAnimation &RainbowAnimation::WithLEDStartIndex(int newLEDStartIndex) { LEDStartIndex = std::move(newLEDStartIndex); return *this; } ``` -------------------------------- ### Custom Parameters Configurations Source: https://api.ctr-electronics.com/phoenix6/release/cpp/namespacectre_1_1phoenix6_1_1configs Allows for the configuration of custom parameters. ```APIDOC ## CustomParamsConfigs ### Description Custom Params. ### Class CustomParamsConfigs ``` -------------------------------- ### Configure TwinkleAnimation LED Start Index Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1controls_1_1_twinkle_animation Sets the start index for the TwinkleAnimation and returns the modified object for chaining. ```APIDOC ## POST /controls/twinkle_animation/set_led_start_index ### Description Modifies this Control Request's LEDStartIndex parameter and returns itself for method-chaining and easier to use request API. ### Method POST ### Endpoint /controls/twinkle_animation/set_led_start_index ### Parameters #### Request Body - **newLEDStartIndex** (int) - Required - The index of the first LED this animation controls (inclusive). ### Request Example ```json { "newLEDStartIndex": 0 } ``` ### Response #### Success Response (200) - **status** (string) - Indicates success. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### TalonFXConfigurator Apply Configurations Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1configs_1_1_talon_f_x_configurator-members Methods for applying configurations to the TalonFX controller. ```APIDOC ## POST /configs/talonfx/apply ### Description Applies configurations to the TalonFX controller. Overloaded methods allow for applying different configuration types and specifying a timeout. ### Method POST ### Endpoint /configs/talonfx/apply ### Parameters #### Request Body - **configs** (Slot2Configs | SlotConfigs) - Required - The configuration object to apply. - **timeoutSeconds** (units::time::second_t) - Optional - The timeout in seconds for the operation. ``` -------------------------------- ### Control Logging (C++) Source: https://api.ctr-electronics.com/phoenix6/release/cpp/_signal_logger_8hpp_source Provides functions to start, stop, and manage automatic logging. 'Start()' initiates logging immediately, while 'Stop()' halts it. 'EnableAutoLogging(bool enable)' controls whether logging automatically begins at the start of an FRC match and stops at the end, a feature supported on the roboRIO. ```cpp static ctre::phoenix::StatusCode Start(); static ctre::phoenix::StatusCode Stop(); static ctre::phoenix::StatusCode EnableAutoLogging(bool enable); ``` -------------------------------- ### Namespaces Source: https://api.ctr-electronics.com/phoenix6/release/cpp/_orchestra_8hpp Documentation for the `ctre` and `ctre::phoenix6` namespaces. ```APIDOC ## Namespaces ### Description Provides documentation for the `ctre` and `ctre::phoenix6` namespaces. ### Method N/A ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ### Error Handling N/A ``` -------------------------------- ### Start Logger (C++) Source: https://api.ctr-electronics.com/phoenix6/release/cpp/platform__c__style_8h_source Initializes and starts the logging system. This function typically prepares the logger to capture subsequent events or data. ```cpp CTREXPORT int32_t c_ctre_phoenix6_platform_start_logger(void) ``` -------------------------------- ### MotionMagicDutyCycle Constructor and Configuration Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1controls_1_1_motion_magic_duty_cycle This section details how to instantiate and configure the MotionMagicDutyCycle control request, including setting the target position and other motion profile parameters. ```APIDOC ## MotionMagicDutyCycle Control Request ### Description Requests Motion MagicĀ® to target a final position using a motion profile. This control request allows for precise movement to a specified position with a defined motion profile. ### Method Constructor and Mutator Methods ### Endpoint N/A (This is a C++ class, not a REST API endpoint) ### Parameters #### Constructor Parameters - **Position** (units::angle::turn_t) - Required - The target position in rotations to drive toward. #### Mutator Methods (for chaining) - **WithPosition** (units::angle::turn_t newPosition) - Returns `MotionMagicDutyCycle&` - Modifies the target Position parameter. - **WithEnableFOC** (bool newEnableFOC) - Returns `MotionMagicDutyCycle&` - Modifies the EnableFOC parameter. Defaults to `true`. - **WithFeedForward** (units::dimensionless::scalar_t newFeedForward) - Returns `MotionMagicDutyCycle&` - Modifies the FeedForward parameter. Defaults to `0.0`. - **WithSlot** (int newSlot) - Returns `MotionMagicDutyCycle&` - Modifies the Slot parameter. Defaults to `0`. - **WithOverrideBrakeDurNeutral** (bool newOverrideBrakeDurNeutral) - Returns `MotionMagicDutyCycle&` - Modifies the OverrideBrakeDurNeutral parameter. Defaults to `false`. - **WithLimitForwardMotion** (bool newLimitForwardMotion) - Returns `MotionMagicDutyCycle&` - Modifies the LimitForwardMotion parameter. Defaults to `false`. - **WithLimitReverseMotion** (bool newLimitReverseMotion) - Returns `MotionMagicDutyCycle&` - Modifies the LimitReverseMotion parameter. Defaults to `false`. - **WithIgnoreHardwareLimits** (bool newIgnoreHardwareLimits) - Returns `MotionMagicDutyCycle&` - Modifies the IgnoreHardwareLimits parameter. Defaults to `false`. - **WithUseTimesync** (bool newUseTimesync) - Returns `MotionMagicDutyCycle&` - Modifies the UseTimesync parameter. Defaults to `false`. - **WithUpdateFreqHz** (units::frequency::hertz_t newUpdateFreqHz) - Returns `MotionMagicDutyCycle&` - Sets the period at which this control will update at. Defaults to `100_Hz`. ### Request Example (Conceptual C++ Code) ```cpp #include #include using namespace ctre::phoenix6::controls; using namespace units::angle; // Create a control request to move to 5 rotations MotionMagicDutyCycle driveToPosition(5.0_rot); // Chain additional configurations driveToPosition.WithFeedForward(0.1) .WithSlot(1) .WithUpdateFreqHz(50_Hz); // Assume 'talon' is a configured TalonFX device // talon.SetControl(driveToPosition); ``` ### Response #### Success Response N/A (This is a C++ class, not a REST API response) #### Response Example N/A ``` -------------------------------- ### GetGenericSignal - C++ Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1hardware_1_1_parent_device An internal testing routine to get a generic status signal. It takes a signal identifier and an optional refresh flag. Use other get routines for standard signal retrieval. ```cpp StatusSignal& ctre::phoenix6::hardware::ParentDevice::GetGenericSignal(uint32_t _signal_, bool _refresh_ = true); ``` -------------------------------- ### Start Logging - C++ Source: https://api.ctr-electronics.com/phoenix6/release/cpp/_signal_logger_8hpp_source Starts the logging of status signals. This is a core function of the SignalLogger class and returns a status code indicating success or failure. ```cpp static ctre::phoenix::StatusCode Start() { // Implementation details... } ``` -------------------------------- ### Version Information Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1hardware_1_1traits_1_1_has_talon_signals Retrieve the major, minor, bugfix, build, and full version numbers of the firmware running on the device. ```APIDOC ## GET /version ### Description Retrieves various components of the device's firmware version. ### Method GET ### Endpoint /version ### Parameters #### Query Parameters - **refresh** (boolean) - Optional - Whether to refresh the value from the device. ### Response #### Success Response (200) - **versionMajor** (integer) - The major version number. - **versionMinor** (integer) - The minor version number. - **versionBugfix** (integer) - The bugfix version number. - **versionBuild** (integer) - The build number. - **version** (integer) - The full version string. #### Response Example ```json { "versionMajor": 1, "versionMinor": 5, "versionBugfix": 2, "versionBuild": 1024, "version": 105021024 } ``` ``` -------------------------------- ### Apply LED Configuration Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1configs_1_1_c_a_ndle_configurator Applies the specified LED configuration to the device. You can optionally specify a timeout. ```APIDOC ## POST /websites/api_ctr-electronics_phoenix6_release_cpp/configs/led ### Description Applies the specified LED configuration to the device. ### Method POST ### Endpoint /websites/api_ctr-electronics_phoenix6_release_cpp/configs/led ### Parameters #### Query Parameters - **timeoutSeconds** (units::time::second_t) - Optional - The timeout duration for applying the configuration. #### Request Body - **configs** (LEDConfigs) - Required - The LED configuration to apply. ### Request Example ```json { "configs": { "someField": "someValue" } } ``` ### Response #### Success Response (200) - **statusCode** (ctre::phoenix::StatusCode) - The status of the operation. #### Response Example ```json { "statusCode": "OK" } ``` ``` -------------------------------- ### Get Drive/Steer Closed-Loop Output Type (C++) Source: https://api.ctr-electronics.com/phoenix6/release/cpp/_swerve_module_impl_8hpp_source Gets the closed-loop output type for the drive or steer motor of a swerve module. This indicates the nature of the feedback being used for control. ```cpp ClosedLoopOutputType GetSteerClosedLoopOutputType() const Gets the closed-loop output type to use for the steer motor. **Definition** SwerveModuleImpl.hpp:390 ``` ```cpp ClosedLoopOutputType GetDriveClosedLoopOutputType() const Gets the closed-loop output type to use for the drive motor. **Definition** SwerveModuleImpl.hpp:380 ``` -------------------------------- ### SwerveDrivePoseEstimator Constructors Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1swerve_1_1impl_1_1_swerve_drive_pose_estimator Constructors for initializing the SwerveDrivePoseEstimator. ```APIDOC ## SwerveDrivePoseEstimator (Constructor 1/2) ### Description Constructs a SwerveDrivePoseEstimator with default standard deviations for the model and vision measurements. The default standard deviations of the model states are 0.1 meters for x, 0.1 meters for y, and 0.1 radians for heading. The default standard deviations of the vision measurements are 0.9 meters for x, 0.9 meters for y, and 0.9 radians for heading. ### Method Constructor ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response None ## SwerveDrivePoseEstimator (Constructor 2/2) ### Description Constructs a SwerveDrivePoseEstimator with custom standard deviations for state and vision measurements. ### Method Constructor ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response None ``` -------------------------------- ### C++ Talon FX: Get Applied Rotor Polarity Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1hardware_1_1traits_1_1_has_talon_signals-members Gets the applied rotor polarity of the Talon FX motor controller. Use the 'refresh' parameter to control data updates. ```cpp GetAppliedRotorPolarity(bool refresh = true) = 0; ``` -------------------------------- ### Start Odometry Thread C++ Source: https://api.ctr-electronics.com/phoenix6/release/cpp/_swerve_drivetrain_impl_8hpp_source Starts the odometry thread, ensuring it only begins if it's not already joinable. It sets the running flag and creates a new thread that executes the Run() method. ```cpp void Start() { std::lock_guard lock{_threadMtx}; if (!_thread.joinable()) { _isRunning.store(true, std::memory_order_relaxed); _thread = std::thread{[this] { Run(); }}; } } ``` -------------------------------- ### Device Configurations and Serialization Source: https://api.ctr-electronics.com/phoenix6/release/cpp/functions_func_d This section covers device configuration management, including deserialization of various configuration types and methods for setting and getting device configuration values. ```APIDOC ## Device Configuration and Serialization API ### Description Provides methods for deserializing various device configurations and managing device configuration values. ### Methods #### `Deserialize()` * **Description**: Deserializes various configuration objects. * **Signature**: `Deserialize() -> [List of Configuration Types]` * **Details**: Supports deserialization for `AudioConfigs`, `CANcoderConfiguration`, `CANdiConfiguration`, `CANdleConfiguration`, `CANdleFeaturesConfigs`, `CANrangeConfiguration`, `ClosedLoopGeneralConfigs`, `ClosedLoopRampsConfigs`, `CommutationConfigs`, `CurrentLimitsConfigs`, `CustomParamsConfigs`, `DifferentialConstantsConfigs`, `DifferentialSensorsConfigs`, `DigitalInputsConfigs`, `ExternalFeedbackConfigs`, `FeedbackConfigs`, `FovParamsConfigs`, `GyroTrimConfigs`, `HardwareLimitSwitchConfigs`, `LEDConfigs`, `MagnetSensorConfigs`, `MotionMagicConfigs`, `MotorOutputConfigs`, `MountPoseConfigs`, `OpenLoopRampsConfigs`, `ParentConfiguration`, `Pigeon2Configuration`, `Pigeon2FeaturesConfigs`, `ProximityParamsConfigs`, `PWM1Configs`, `PWM2Configs`, `QuadratureConfigs`, `Slot0Configs`, `Slot1Configs`, `Slot2Configs`, `SlotConfigs`, `SoftwareLimitSwitchConfigs`, `TalonFXConfiguration`, `TalonFXSConfiguration`, `ToFParamsConfigs`, `TorqueCurrentConfigs`, `VoltageConfigs`. #### `Device_GetConfigValues()` * **Description**: Retrieves the current configuration values of a device. * **Signature**: `Device_GetConfigValues() -> ctre::phoenix6::networking::Wrappers` #### `Device_SetConfigValues()` * **Description**: Sets the configuration values for a device. * **Signature**: `Device_SetConfigValues(wrappers: ctre::phoenix6::networking::Wrappers) -> void` #### `DifferentialConstantsConfigs()` * **Description**: Represents configuration for differential constants. * **Signature**: `DifferentialConstantsConfigs() -> ctre::phoenix6::configs::DifferentialConstantsConfigs` #### `DifferentialSensorsConfigs()` * **Description**: Represents configuration for differential sensors. * **Signature**: `DifferentialSensorsConfigs() -> ctre::phoenix6::configs::DifferentialSensorsConfigs` #### `DigitalInputsConfigs()` * **Description**: Represents configuration for digital inputs. * **Signature**: `DigitalInputsConfigs() -> ctre::phoenix6::configs::DigitalInputsConfigs` ``` -------------------------------- ### Device Identification and Configuration Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1hardware_1_1_talon_f_x_s-members Methods for retrieving device identification and accessing configuration tools for the Talon FXS. ```APIDOC ## Get Device Identifier ### Description Retrieves the unique identifier for the device. ### Method GET ### Endpoint `/deviceId` ### Parameters ### Response #### Success Response (200) - **deviceId** (int) - The unique device identifier. #### Response Example ```json { "deviceId": 1 } ``` ## Get Device ID ### Description Retrieves the device ID of the Talon FXS. ### Method GET ### Endpoint `/deviceID` ### Parameters ### Response #### Success Response (200) - **deviceID** (int) - The device ID. #### Response Example ```json { "deviceID": 1 } ``` ## Get Device Hash ### Description Retrieves the hash of the device configuration. ### Method GET ### Endpoint `/deviceHash` ### Parameters ### Response #### Success Response (200) - **deviceHash** (string) - The device configuration hash. #### Response Example ```json { "deviceHash": "abc123xyz789" } ``` ## Get Configurator ### Description Retrieves the configuration object for the Talon FXS. ### Method GET ### Endpoint `/configurator` ### Parameters ### Response #### Success Response (200) - **configurator** (object) - The configuration object. #### Response Example ```json { "configurator": {} } ``` ``` -------------------------------- ### Configure Diagnostic Server Start Delay (C++) Source: https://api.ctr-electronics.com/phoenix6/release/cpp/_diagnostics___c_c_i_8h_source This function sets the number of seconds the Phoenix Diagnostic Server will wait before starting. It accepts a double value for the delay. This can be useful for controlling startup order. ```cpp #include "ctre/phoenix/export.h" /** Sets the number of seconds after which the Phoenix Diagnostic Server will start */ CTREXPORT void c_Phoenix_Diagnostics_SetSecondsToStart(double secondsToStart); ``` -------------------------------- ### GetOdometryThread Source: https://api.ctr-electronics.com/phoenix6/release/cpp/classctre_1_1phoenix6_1_1swerve_1_1_swerve_drivetrain Gets a reference to the odometry thread. ```APIDOC ## GetOdometryThread ### Description Gets a reference to the odometry thread. ### Method `OdometryThread& GetOdometryThread()` ### Endpoint N/A (Method within the class) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```cpp // Assuming 'drivetrain' is an instance of SwerveDrivetrain // OdometryThread& odometryThread = drivetrain.GetOdometryThread(); ``` ### Response #### Success Response (200) * **Return Value** (OdometryThread&) - A reference to the odometry thread. #### Response Example ```json { "returnValue": "" } ``` ``` -------------------------------- ### IMU (Pigeon 2) Configuration Source: https://api.ctr-electronics.com/phoenix6/release/cpp/functions_func_w Methods for configuring the Pigeon 2 IMU, including its mounting pose and features. ```APIDOC ## WithMountPose() ### Description Sets the mounting pose (position and orientation) of the Pigeon 2 IMU. ### Method (Implied: Constructor or Setter) ### Endpoint N/A (C++ Class Method) ### Parameters - **pose** (ctre::phoenix6::configs::MountPoseConfigs) - Required - The configuration object for the mount pose. ### Request Example ```cpp ctre::phoenix6::configs::Pigeon2Configuration pigeonConfig; ctre::phoenix6::configs::MountPoseConfigs mountPose; mountPose.WithMountPosePitch(units::angle::degrees_t(0)); mountPose.WithMountPoseRoll(units::angle::degrees_t(0)); mountPose.WithMountPoseYaw(units::angle::degrees_t(0)); pigeonConfig.WithMountPose(mountPose); ``` ### Response #### Success Response - **ctre::phoenix6::configs::Pigeon2Configuration** - The updated configuration object. #### Response Example (N/A - C++ return value) ``` ```APIDOC ## WithPigeon2Features() ### Description Configures various features and capabilities of the Pigeon 2 IMU. ### Method (Implied: Constructor or Setter) ### Endpoint N/A (C++ Class Method) ### Parameters - **features** (ctre::phoenix6::sensors::Pigeon2Features) - Required - The Pigeon 2 features configuration. ### Request Example ```cpp ctre::phoenix6::configs::Pigeon2Configuration pigeonConfig; pigeonConfig.WithPigeon2Features(ctre::phoenix6::sensors::Pigeon2Features::kAll); ``` ### Response #### Success Response - **ctre::phoenix6::configs::Pigeon2Configuration** - The updated configuration object. #### Response Example (N/A - C++ return value) ```