13#include <units/angular_velocity.h>
14#include <units/angle.h>
15#include <units/frequency.h>
16#include <units/time.h>
31 ctre::phoenix::StatusCode SendRequest(
const char *network, uint32_t deviceHash, std::shared_ptr<ControlRequest> &req)
override
33 if (req.get() !=
this)
36 if (reqCast !=
nullptr)
42 req = std::make_shared<DifferentialVelocityDutyCycle>(*
this);
46 return c_ctre_phoenix6_RequestControlDifferentialVelocityDutyCycle(network, deviceHash,
UpdateFreqHz.to<
double>(),
TargetVelocity.to<
double>(),
DifferentialPosition.to<
double>(),
EnableFOC,
TargetSlot,
DifferentialSlot,
OverrideBrakeDurNeutral,
LimitForwardMotion,
LimitReverseMotion,
UseTimesync);
374 std::stringstream ss;
375 ss <<
"Control: DifferentialVelocityDutyCycle" << std::endl;
376 ss <<
" TargetVelocity: " <<
TargetVelocity.to<
double>() <<
" rotations per second" << std::endl;
377 ss <<
" DifferentialPosition: " <<
DifferentialPosition.to<
double>() <<
" rotations" << std::endl;
378 ss <<
" EnableFOC: " <<
EnableFOC << std::endl;
379 ss <<
" TargetSlot: " <<
TargetSlot << std::endl;
384 ss <<
" UseTimesync: " <<
UseTimesync << std::endl;
395 std::map<std::string, std::string> controlInfo;
396 std::stringstream ss;
397 controlInfo[
"Name"] =
GetName();
398 ss <<
TargetVelocity.to<
double>(); controlInfo[
"TargetVelocity"] = ss.str(); ss.str(std::string{});
399 ss <<
DifferentialPosition.to<
double>(); controlInfo[
"DifferentialPosition"] = ss.str(); ss.str(std::string{});
400 ss <<
EnableFOC; controlInfo[
"EnableFOC"] = ss.str(); ss.str(std::string{});
401 ss <<
TargetSlot; controlInfo[
"TargetSlot"] = ss.str(); ss.str(std::string{});
402 ss <<
DifferentialSlot; controlInfo[
"DifferentialSlot"] = ss.str(); ss.str(std::string{});
404 ss <<
LimitForwardMotion; controlInfo[
"LimitForwardMotion"] = ss.str(); ss.str(std::string{});
405 ss <<
LimitReverseMotion; controlInfo[
"LimitReverseMotion"] = ss.str(); ss.str(std::string{});
406 ss <<
UseTimesync; controlInfo[
"UseTimesync"] = ss.str(); ss.str(std::string{});
CTREXPORT int c_ctre_phoenix6_RequestControlDifferentialVelocityDutyCycle(const char *canbus, uint32_t ecuEncoding, double updateTime, double TargetVelocity, double DifferentialPosition, bool EnableFOC, int TargetSlot, int DifferentialSlot, bool OverrideBrakeDurNeutral, bool LimitForwardMotion, bool LimitReverseMotion, bool 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 a differential position setpoint.
Definition: DifferentialVelocityDutyCycle.hpp:30
DifferentialVelocityDutyCycle & WithUpdateFreqHz(units::frequency::hertz_t newUpdateFreqHz)
Sets the period at which this control will update at.
Definition: DifferentialVelocityDutyCycle.hpp:362
bool EnableFOC
Set to true to use FOC commutation (requires Phoenix Pro), which increases peak power by ~15%.
Definition: DifferentialVelocityDutyCycle.hpp:70
units::angle::turn_t DifferentialPosition
Differential position to drive toward in rotations.
Definition: DifferentialVelocityDutyCycle.hpp:57
DifferentialVelocityDutyCycle & WithLimitReverseMotion(bool newLimitReverseMotion)
Modifies this Control Request's LimitReverseMotion parameter and returns itself for method-chaining a...
Definition: DifferentialVelocityDutyCycle.hpp:325
int DifferentialSlot
Select which gains are applied to the differential controller by selecting the slot.
Definition: DifferentialVelocityDutyCycle.hpp:82
DifferentialVelocityDutyCycle & WithDifferentialSlot(int newDifferentialSlot)
Modifies this Control Request's DifferentialSlot parameter and returns itself for method-chaining and...
Definition: DifferentialVelocityDutyCycle.hpp:273
DifferentialVelocityDutyCycle & WithDifferentialPosition(units::angle::turn_t newDifferentialPosition)
Modifies this Control Request's DifferentialPosition parameter and returns itself for method-chaining...
Definition: DifferentialVelocityDutyCycle.hpp:215
std::string ToString() const override
Returns a string representation of the object.
Definition: DifferentialVelocityDutyCycle.hpp:372
DifferentialVelocityDutyCycle & WithUseTimesync(bool newUseTimesync)
Modifies this Control Request's UseTimesync parameter and returns itself for method-chaining and easi...
Definition: DifferentialVelocityDutyCycle.hpp:343
units::frequency::hertz_t UpdateFreqHz
The period at which this control will update at.
Definition: DifferentialVelocityDutyCycle.hpp:121
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:200
DifferentialVelocityDutyCycle & WithTargetSlot(int newTargetSlot)
Modifies this Control Request's TargetSlot parameter and returns itself for method-chaining and easie...
Definition: DifferentialVelocityDutyCycle.hpp:256
DifferentialVelocityDutyCycle & WithLimitForwardMotion(bool newLimitForwardMotion)
Modifies this Control Request's LimitForwardMotion parameter and returns itself for method-chaining a...
Definition: DifferentialVelocityDutyCycle.hpp:308
DifferentialVelocityDutyCycle(units::angular_velocity::turns_per_second_t TargetVelocity, units::angle::turn_t DifferentialPosition, bool EnableFOC=true, int TargetSlot=0, int DifferentialSlot=1, bool OverrideBrakeDurNeutral=false, bool LimitForwardMotion=false, bool LimitReverseMotion=false, bool UseTimesync=false)
Request PID to target velocity with a differential position setpoint.
Definition: DifferentialVelocityDutyCycle.hpp:179
DifferentialVelocityDutyCycle & WithEnableFOC(bool newEnableFOC)
Modifies this Control Request's EnableFOC parameter and returns itself for method-chaining and easier...
Definition: DifferentialVelocityDutyCycle.hpp:239
DifferentialVelocityDutyCycle & WithOverrideBrakeDurNeutral(bool newOverrideBrakeDurNeutral)
Modifies this Control Request's OverrideBrakeDurNeutral parameter and returns itself for method-chain...
Definition: DifferentialVelocityDutyCycle.hpp:291
units::angular_velocity::turns_per_second_t TargetVelocity
Average velocity to drive toward in rotations per second.
Definition: DifferentialVelocityDutyCycle.hpp:53
bool LimitForwardMotion
Set to true to force forward limiting.
Definition: DifferentialVelocityDutyCycle.hpp:95
bool LimitReverseMotion
Set to true to force reverse limiting.
Definition: DifferentialVelocityDutyCycle.hpp:101
int TargetSlot
Select which gains are applied to the primary controller by selecting the slot.
Definition: DifferentialVelocityDutyCycle.hpp:76
std::map< std::string, std::string > GetControlInfo() const override
Gets information about this control request.
Definition: DifferentialVelocityDutyCycle.hpp:393
bool UseTimesync
Set to true to delay applying this control request until a timesync boundary (requires Phoenix Pro an...
Definition: DifferentialVelocityDutyCycle.hpp:108
bool OverrideBrakeDurNeutral
Set to true to static-brake the rotor when output is zero (or within deadband).
Definition: DifferentialVelocityDutyCycle.hpp:89
Status codes reported by APIs, including OK, warnings, and errors.
Definition: StatusCodes.h:27
Represents the state of one swerve module.
Definition: StatusCodes.h:18