14#include <units/frequency.h>
15#include <units/time.h>
31 ctre::phoenix::StatusCode SendRequest(
const char *network, uint32_t deviceHash, std::shared_ptr<ControlRequest> &req)
const override
33 if (req.get() !=
this)
35 auto const reqCast =
dynamic_cast<Diff_VelocityDutyCycle_Velocity *
>(req.get());
36 if (reqCast !=
nullptr)
42 req = std::make_shared<Diff_VelocityDutyCycle_Velocity>(*
this);
46 return c_ctre_phoenix6_RequestControlDiff_VelocityDutyCycle_Velocity(network, deviceHash, UpdateFreqHz.to<
double>(), AverageRequest.
Velocity.to<
double>(), AverageRequest.
Acceleration.to<
double>(), AverageRequest.
EnableFOC, AverageRequest.
FeedForward.to<
double>(), AverageRequest.
Slot, AverageRequest.
OverrideBrakeDurNeutral, AverageRequest.
LimitForwardMotion, AverageRequest.
LimitReverseMotion, AverageRequest.
IgnoreHardwareLimits, AverageRequest.
UseTimesync, DifferentialRequest.
Velocity.to<
double>(), DifferentialRequest.
Acceleration.to<
double>(), DifferentialRequest.
EnableFOC, DifferentialRequest.
FeedForward.to<
double>(), DifferentialRequest.
Slot, DifferentialRequest.
OverrideBrakeDurNeutral, DifferentialRequest.
LimitForwardMotion, DifferentialRequest.
LimitReverseMotion, DifferentialRequest.
IgnoreHardwareLimits, DifferentialRequest.
UseTimesync);
70 units::frequency::hertz_t UpdateFreqHz{100_Hz};
82 AverageRequest{std::move(AverageRequest)},
83 DifferentialRequest{std::move(DifferentialRequest)}
95 Diff_VelocityDutyCycle_Velocity &WithAverageRequest(
VelocityDutyCycle newAverageRequest)
97 AverageRequest = std::move(newAverageRequest);
110 Diff_VelocityDutyCycle_Velocity &WithDifferentialRequest(
VelocityDutyCycle newDifferentialRequest)
112 DifferentialRequest = std::move(newDifferentialRequest);
129 Diff_VelocityDutyCycle_Velocity &WithUpdateFreqHz(units::frequency::hertz_t newUpdateFreqHz)
131 UpdateFreqHz = newUpdateFreqHz;
139 std::string ToString()
const override
141 std::stringstream ss;
142 ss <<
"Control: Diff_VelocityDutyCycle_Velocity" << std::endl;
143 ss <<
"AverageRequest:" << std::endl;
144 ss <<
" Velocity: " << AverageRequest.
Velocity.to<
double>() << std::endl;
145 ss <<
" Acceleration: " << AverageRequest.
Acceleration.to<
double>() << std::endl;
146 ss <<
" EnableFOC: " << AverageRequest.
EnableFOC << std::endl;
147 ss <<
" FeedForward: " << AverageRequest.
FeedForward.to<
double>() << std::endl;
148 ss <<
" Slot: " << AverageRequest.
Slot << std::endl;
153 ss <<
" UseTimesync: " << AverageRequest.
UseTimesync << std::endl;
154 ss <<
"DifferentialRequest:" << std::endl;
155 ss <<
" Velocity: " << DifferentialRequest.
Velocity.to<
double>() << std::endl;
156 ss <<
" Acceleration: " << DifferentialRequest.
Acceleration.to<
double>() << std::endl;
157 ss <<
" EnableFOC: " << DifferentialRequest.
EnableFOC << std::endl;
158 ss <<
" FeedForward: " << DifferentialRequest.
FeedForward.to<
double>() << std::endl;
159 ss <<
" Slot: " << DifferentialRequest.
Slot << std::endl;
164 ss <<
" UseTimesync: " << DifferentialRequest.
UseTimesync << std::endl;
173 std::map<std::string, std::string> GetControlInfo()
const override
175 std::map<std::string, std::string> controlInfo;
176 std::stringstream ss;
177 controlInfo[
"Name"] =
GetName();
178 ss << AverageRequest.
ToString(); controlInfo[
"AverageRequest"] = ss.str(); ss.str(std::string{});
179 ss << DifferentialRequest.
ToString(); controlInfo[
"DifferentialRequest"] = ss.str(); ss.str(std::string{});
CTREXPORT int c_ctre_phoenix6_RequestControlDiff_VelocityDutyCycle_Velocity(const char *canbus, uint32_t ecuEncoding, double updateTime, double AverageRequest_Velocity, double AverageRequest_Acceleration, bool AverageRequest_EnableFOC, double AverageRequest_FeedForward, int AverageRequest_Slot, bool AverageRequest_OverrideBrakeDurNeutral, bool AverageRequest_LimitForwardMotion, bool AverageRequest_LimitReverseMotion, bool AverageRequest_IgnoreHardwareLimits, bool AverageRequest_UseTimesync, double DifferentialRequest_Velocity, double DifferentialRequest_Acceleration, bool DifferentialRequest_EnableFOC, double DifferentialRequest_FeedForward, int DifferentialRequest_Slot, bool DifferentialRequest_OverrideBrakeDurNeutral, bool DifferentialRequest_LimitForwardMotion, bool DifferentialRequest_LimitReverseMotion, bool DifferentialRequest_IgnoreHardwareLimits, bool DifferentialRequest_UseTimesync)
Abstract Control Request class that other control requests extend for use.
Definition ControlRequest.hpp:29
std::string const & GetName() const
Definition ControlRequest.hpp:52
Request PID to target velocity with duty cycle feedforward.
Definition VelocityDutyCycle.hpp:31
int Slot
Select which gains are applied by selecting the slot.
Definition VelocityDutyCycle.hpp:82
units::angular_acceleration::turns_per_second_squared_t Acceleration
Acceleration to drive toward in rotations per second squared.
Definition VelocityDutyCycle.hpp:59
bool OverrideBrakeDurNeutral
Set to true to static-brake the rotor when output is zero (or within deadband).
Definition VelocityDutyCycle.hpp:89
bool IgnoreHardwareLimits
Set to true to ignore hardware limit switches and the LimitForwardMotion and LimitReverseMotion param...
Definition VelocityDutyCycle.hpp:114
units::angular_velocity::turns_per_second_t Velocity
Velocity to drive toward in rotations per second.
Definition VelocityDutyCycle.hpp:54
units::dimensionless::scalar_t FeedForward
Feedforward to apply in fractional units between -1 and +1.
Definition VelocityDutyCycle.hpp:76
bool EnableFOC
Set to true to use FOC commutation (requires Phoenix Pro), which increases peak power by ~15%.
Definition VelocityDutyCycle.hpp:72
bool LimitReverseMotion
Set to true to force reverse limiting.
Definition VelocityDutyCycle.hpp:101
std::string ToString() const override
Returns a string representation of the object.
Definition VelocityDutyCycle.hpp:360
bool UseTimesync
Set to true to delay applying this control request until a timesync boundary (requires Phoenix Pro an...
Definition VelocityDutyCycle.hpp:125
bool LimitForwardMotion
Set to true to force forward limiting.
Definition VelocityDutyCycle.hpp:95
Status codes reported by APIs, including OK, warnings, and errors.
Definition StatusCodes.h:27
Definition StatusCodes.h:18