15#include <units/frequency.h>
16#include <units/time.h>
32 ctre::phoenix::StatusCode SendRequest(
const char *network, uint32_t deviceHash,
bool cancelOtherRequests, std::shared_ptr<ControlRequest> &req)
override
34 if (req.get() !=
this)
36 auto const reqCast =
dynamic_cast<Diff_VoltageOut_Velocity *
>(req.get());
37 if (reqCast !=
nullptr)
43 req = std::make_shared<Diff_VoltageOut_Velocity>(*
this);
47 return c_ctre_phoenix6_RequestControlDiff_VoltageOut_Velocity(network, deviceHash, UpdateFreqHz.to<
double>(), cancelOtherRequests, AverageRequest.Output.to<
double>(), AverageRequest.EnableFOC, AverageRequest.OverrideBrakeDurNeutral, AverageRequest.LimitForwardMotion, AverageRequest.LimitReverseMotion, DifferentialRequest.Velocity.to<
double>(), DifferentialRequest.Acceleration.to<
double>(), DifferentialRequest.EnableFOC, DifferentialRequest.FeedForward.to<
double>(), DifferentialRequest.Slot, DifferentialRequest.OverrideBrakeDurNeutral, DifferentialRequest.LimitForwardMotion, DifferentialRequest.LimitReverseMotion);
71 units::frequency::hertz_t UpdateFreqHz{100_Hz};
83 AverageRequest{std::move(AverageRequest)},
84 DifferentialRequest{std::move(DifferentialRequest)}
96 Diff_VoltageOut_Velocity& WithAverageRequest(
VoltageOut newAverageRequest)
98 AverageRequest = std::move(newAverageRequest);
111 Diff_VoltageOut_Velocity& WithDifferentialRequest(
VelocityVoltage newDifferentialRequest)
113 DifferentialRequest = std::move(newDifferentialRequest);
130 Diff_VoltageOut_Velocity &WithUpdateFreqHz(units::frequency::hertz_t newUpdateFreqHz)
132 UpdateFreqHz = newUpdateFreqHz;
140 std::string ToString()
const override
142 std::stringstream ss;
143 ss <<
"class: Diff_VoltageOut_Velocity" << std::endl;
144 ss <<
"AverageRequest:" << std::endl;
145 ss <<
" Output: " << AverageRequest.
Output.to<
double>() << std::endl;
146 ss <<
" EnableFOC: " << AverageRequest.
EnableFOC << std::endl;
150 ss <<
"DifferentialRequest:" << std::endl;
151 ss <<
" Velocity: " << DifferentialRequest.
Velocity.to<
double>() << std::endl;
152 ss <<
" Acceleration: " << DifferentialRequest.
Acceleration.to<
double>() << std::endl;
153 ss <<
" EnableFOC: " << DifferentialRequest.
EnableFOC << std::endl;
154 ss <<
" FeedForward: " << DifferentialRequest.
FeedForward.to<
double>() << std::endl;
155 ss <<
" Slot: " << DifferentialRequest.
Slot << std::endl;
167 std::map<std::string, std::string> GetControlInfo()
const override
169 std::map<std::string, std::string> controlInfo;
170 std::stringstream ss;
171 controlInfo[
"Name"] = GetName();
172 ss << AverageRequest.
ToString(); controlInfo[
"AverageRequest"] = ss.str(); ss.str(std::string{});
173 ss << DifferentialRequest.
ToString(); controlInfo[
"DifferentialRequest"] = ss.str(); ss.str(std::string{});
CTREXPORT int c_ctre_phoenix6_RequestControlDiff_VoltageOut_Velocity(const char *canbus, uint32_t ecuEncoding, double updateTime, bool cancelOtherRequests, double AverageRequest_Output, bool AverageRequest_EnableFOC, bool AverageRequest_OverrideBrakeDurNeutral, bool AverageRequest_LimitForwardMotion, bool AverageRequest_LimitReverseMotion, double DifferentialRequest_Velocity, double DifferentialRequest_Acceleration, bool DifferentialRequest_EnableFOC, double DifferentialRequest_FeedForward, int DifferentialRequest_Slot, bool DifferentialRequest_OverrideBrakeDurNeutral, bool DifferentialRequest_LimitForwardMotion, bool DifferentialRequest_LimitReverseMotion)
Abstract Control Request class that other control requests extend for use.
Definition: ControlRequest.hpp:28
Request PID to target velocity with voltage feedforward.
Definition: VelocityVoltage.hpp:31
std::string ToString() const override
Returns a string representation of the object.
Definition: VelocityVoltage.hpp:335
units::angular_velocity::turns_per_second_t Velocity
Velocity to drive toward in rotations per second.
Definition: VelocityVoltage.hpp:54
bool LimitReverseMotion
Set to true to force reverse limiting.
Definition: VelocityVoltage.hpp:101
bool OverrideBrakeDurNeutral
Set to true to static-brake the rotor when output is zero (or within deadband).
Definition: VelocityVoltage.hpp:89
units::angular_acceleration::turns_per_second_squared_t Acceleration
Acceleration to drive toward in rotations per second squared.
Definition: VelocityVoltage.hpp:59
bool LimitForwardMotion
Set to true to force forward limiting.
Definition: VelocityVoltage.hpp:95
units::voltage::volt_t FeedForward
Feedforward to apply in volts.
Definition: VelocityVoltage.hpp:76
int Slot
Select which gains are applied by selecting the slot.
Definition: VelocityVoltage.hpp:82
bool EnableFOC
Set to true to use FOC commutation (requires Phoenix Pro), which increases peak power by ~15%.
Definition: VelocityVoltage.hpp:72
Request a specified voltage.
Definition: VoltageOut.hpp:29
bool LimitReverseMotion
Set to true to force reverse limiting.
Definition: VoltageOut.hpp:84
bool OverrideBrakeDurNeutral
Set to true to static-brake the rotor when output is zero (or within deadband).
Definition: VoltageOut.hpp:72
bool LimitForwardMotion
Set to true to force forward limiting.
Definition: VoltageOut.hpp:78
units::voltage::volt_t Output
Voltage to attempt to drive at.
Definition: VoltageOut.hpp:52
bool EnableFOC
Set to true to use FOC commutation (requires Phoenix Pro), which increases peak power by ~15%.
Definition: VoltageOut.hpp:65
std::string ToString() const override
Returns a string representation of the object.
Definition: VoltageOut.hpp:260
Definition: string_util.hpp:15