13#include <units/angular_velocity.h>
14#include <units/angle.h>
15#include <units/frequency.h>
16#include <units/time.h>
31 bool ApplyConfigsOnRequest{
false};
33 ctre::phoenix::StatusCode SendRequest(
const char *network, uint32_t deviceHash,
bool cancelOtherRequests, std::shared_ptr<ControlRequest> &req)
override
35 if (req.get() !=
this)
38 if (reqCast !=
nullptr)
44 req = std::make_shared<DifferentialVelocityDutyCycle>(*
this);
50 std::string strs{ss.str()};
52 ApplyConfigsOnRequest =
false;
277 std::stringstream ss;
278 ss <<
"class: DifferentialVelocityDutyCycle" << std::endl;
279 ss <<
"TargetVelocity: " <<
TargetVelocity.to<
double>() << std::endl;
281 ss <<
"EnableFOC: " <<
EnableFOC << std::endl;
282 ss <<
"TargetSlot: " <<
TargetSlot << std::endl;
302 std::map<std::string, std::string> controlInfo;
303 std::stringstream ss;
304 controlInfo[
"Name"] =
GetName();
305 ss <<
TargetVelocity.to<
double>(); controlInfo[
"TargetVelocity"] = ss.str(); ss.str(std::string{});
306 ss <<
DifferentialPosition.to<
double>(); controlInfo[
"DifferentialPosition"] = ss.str(); ss.str(std::string{});
307 ss <<
EnableFOC; controlInfo[
"EnableFOC"] = ss.str(); ss.str(std::string{});
308 ss <<
TargetSlot; controlInfo[
"TargetSlot"] = ss.str(); ss.str(std::string{});
309 ss <<
DifferentialSlot; controlInfo[
"DifferentialSlot"] = ss.str(); ss.str(std::string{});
CTREXPORT int c_ctre_phoenix6_requestConfigApply(const char *canbus, uint32_t ecuEncoding, double timeoutSeconds, const char *str, uint32_t strlen, bool forceApply)
CTREXPORT int c_ctre_phoenix6_RequestControlDifferentialVelocityDutyCycle(const char *canbus, uint32_t ecuEncoding, double updateTime, bool cancelOtherRequests, double TargetVelocity, double DifferentialPosition, bool EnableFOC, int TargetSlot, int DifferentialSlot, bool OverrideBrakeDurNeutral)
Abstract Control Request class that other control requests extend for use.
Definition: ControlRequest.hpp:28
std::string const & GetName() const
Definition: ControlRequest.hpp:51
Request PID to target velocity with a differential position setpoint.
Definition: DifferentialVelocityDutyCycle.hpp:30
units::time::second_t ConfigTimeout
The timeout when sending configs associated with this control.
Definition: DifferentialVelocityDutyCycle.hpp:101
DifferentialVelocityDutyCycle & WithUpdateFreqHz(units::frequency::hertz_t newUpdateFreqHz)
Sets the period at which this control will update at.
Definition: DifferentialVelocityDutyCycle.hpp:265
bool EnableFOC
Set to true to use FOC commutation (requires Phoenix Pro), which increases peak power by ~15%.
Definition: DifferentialVelocityDutyCycle.hpp:75
units::angle::turn_t DifferentialPosition
Differential position to drive toward in rotations.
Definition: DifferentialVelocityDutyCycle.hpp:64
int DifferentialSlot
Select which gains are applied to the differential controller by selecting the slot.
Definition: DifferentialVelocityDutyCycle.hpp:87
DifferentialVelocityDutyCycle & WithDifferentialSlot(int newDifferentialSlot)
Modifies this Control Request's DifferentialSlot parameter and returns itself for method-chaining and...
Definition: DifferentialVelocityDutyCycle.hpp:234
DifferentialVelocityDutyCycle & WithDifferentialPosition(units::angle::turn_t newDifferentialPosition)
Modifies this Control Request's DifferentialPosition parameter and returns itself for method-chaining...
Definition: DifferentialVelocityDutyCycle.hpp:198
DifferentialVelocityDutyCycle(units::angular_velocity::turns_per_second_t TargetVelocity, units::angle::turn_t DifferentialPosition)
Request PID to target velocity with a differential position setpoint.
Definition: DifferentialVelocityDutyCycle.hpp:177
std::string ToString() const override
Returns a string representation of the object.
Definition: DifferentialVelocityDutyCycle.hpp:275
units::frequency::hertz_t UpdateFreqHz
The period at which this control will update at.
Definition: DifferentialVelocityDutyCycle.hpp:114
DifferentialVelocityDutyCycle & WithTargetVelocity(units::angular_velocity::turns_per_second_t newTargetVelocity)
Modifies this Control Request's TargetVelocity parameter and returns itself for method-chaining and e...
Definition: DifferentialVelocityDutyCycle.hpp:186
DifferentialVelocityDutyCycle & WithTargetSlot(int newTargetSlot)
Modifies this Control Request's TargetSlot parameter and returns itself for method-chaining and easie...
Definition: DifferentialVelocityDutyCycle.hpp:222
DifferentialVelocityDutyCycle & WithEnableFOC(bool newEnableFOC)
Modifies this Control Request's EnableFOC parameter and returns itself for method-chaining and easier...
Definition: DifferentialVelocityDutyCycle.hpp:210
DifferentialVelocityDutyCycle(units::angular_velocity::turns_per_second_t TargetVelocity, units::angle::turn_t DifferentialPosition, bool EnableFOC, int TargetSlot, int DifferentialSlot, bool OverrideBrakeDurNeutral)
Request PID to target velocity with a differential position setpoint.
Definition: DifferentialVelocityDutyCycle.hpp:156
void ForceApplyConfigs()
Forces configs to be applied the next time this is used in a setControl.
Definition: DifferentialVelocityDutyCycle.hpp:293
DifferentialVelocityDutyCycle & WithOverrideBrakeDurNeutral(bool newOverrideBrakeDurNeutral)
Modifies this Control Request's OverrideBrakeDurNeutral parameter and returns itself for method-chain...
Definition: DifferentialVelocityDutyCycle.hpp:246
units::angular_velocity::turns_per_second_t TargetVelocity
Average velocity to drive toward in rotations per second.
Definition: DifferentialVelocityDutyCycle.hpp:60
int TargetSlot
Select which gains are applied to the primary controller by selecting the slot.
Definition: DifferentialVelocityDutyCycle.hpp:81
std::map< std::string, std::string > GetControlInfo() const override
Gets information about this control request.
Definition: DifferentialVelocityDutyCycle.hpp:300
bool OverrideBrakeDurNeutral
Set to true to static-brake the rotor when output is zero (or within deadband).
Definition: DifferentialVelocityDutyCycle.hpp:94
Definition: ManualEvent.hpp:12