12#include <units/angle.h>
13#include <units/frequency.h>
14#include <units/time.h>
29 ctre::phoenix::StatusCode SendRequest(
const char *network, uint32_t deviceHash, std::shared_ptr<ControlRequest> &req)
const override
31 if (req.get() !=
this)
34 if (reqCast !=
nullptr)
40 req = std::make_shared<DifferentialPositionDutyCycle>(*
this);
44 return c_ctre_phoenix6_RequestControlDifferentialPositionDutyCycle(network, deviceHash,
UpdateFreqHz.to<
double>(),
TargetPosition.to<
double>(),
DifferentialPosition.to<
double>(),
EnableFOC,
TargetSlot,
DifferentialSlot,
OverrideBrakeDurNeutral,
LimitForwardMotion,
LimitReverseMotion,
IgnoreHardwareLimits,
UseTimesync);
364 std::stringstream ss;
365 ss <<
"Control: DifferentialPositionDutyCycle" << std::endl;
366 ss <<
" TargetPosition: " <<
TargetPosition.to<
double>() <<
" rotations" << std::endl;
367 ss <<
" DifferentialPosition: " <<
DifferentialPosition.to<
double>() <<
" rotations" << std::endl;
368 ss <<
" EnableFOC: " <<
EnableFOC << std::endl;
369 ss <<
" TargetSlot: " <<
TargetSlot << std::endl;
375 ss <<
" UseTimesync: " <<
UseTimesync << std::endl;
386 std::map<std::string, std::string> controlInfo;
387 std::stringstream ss;
388 controlInfo[
"Name"] =
GetName();
389 ss <<
TargetPosition.to<
double>(); controlInfo[
"TargetPosition"] = ss.str(); ss.str(std::string{});
390 ss <<
DifferentialPosition.to<
double>(); controlInfo[
"DifferentialPosition"] = ss.str(); ss.str(std::string{});
391 ss <<
EnableFOC; controlInfo[
"EnableFOC"] = ss.str(); ss.str(std::string{});
392 ss <<
TargetSlot; controlInfo[
"TargetSlot"] = ss.str(); ss.str(std::string{});
393 ss <<
DifferentialSlot; controlInfo[
"DifferentialSlot"] = ss.str(); ss.str(std::string{});
395 ss <<
LimitForwardMotion; controlInfo[
"LimitForwardMotion"] = ss.str(); ss.str(std::string{});
396 ss <<
LimitReverseMotion; controlInfo[
"LimitReverseMotion"] = ss.str(); ss.str(std::string{});
397 ss <<
IgnoreHardwareLimits; controlInfo[
"IgnoreHardwareLimits"] = ss.str(); ss.str(std::string{});
398 ss <<
UseTimesync; controlInfo[
"UseTimesync"] = ss.str(); ss.str(std::string{});
CTREXPORT int c_ctre_phoenix6_RequestControlDifferentialPositionDutyCycle(const char *canbus, uint32_t ecuEncoding, double updateTime, double TargetPosition, double DifferentialPosition, bool EnableFOC, int TargetSlot, int DifferentialSlot, bool OverrideBrakeDurNeutral, bool LimitForwardMotion, bool LimitReverseMotion, bool IgnoreHardwareLimits, bool UseTimesync)
Abstract Control Request class that other control requests extend for use.
Definition ControlRequest.hpp:30
std::string const & GetName() const
Definition ControlRequest.hpp:53
Request PID to target position with a differential position setpoint.
Definition DifferentialPositionDutyCycle.hpp:28
int TargetSlot
Select which gains are applied to the primary controller by selecting the slot.
Definition DifferentialPositionDutyCycle.hpp:74
int DifferentialSlot
Select which gains are applied to the differential controller by selecting the slot.
Definition DifferentialPositionDutyCycle.hpp:80
units::angle::turn_t DifferentialPosition
Differential position to drive toward in rotations.
Definition DifferentialPositionDutyCycle.hpp:55
DifferentialPositionDutyCycle & WithUseTimesync(bool newUseTimesync)
Modifies this Control Request's UseTimesync parameter and returns itself for method-chaining and easi...
Definition DifferentialPositionDutyCycle.hpp:333
bool LimitReverseMotion
Set to true to force reverse limiting.
Definition DifferentialPositionDutyCycle.hpp:99
DifferentialPositionDutyCycle & WithUpdateFreqHz(units::frequency::hertz_t newUpdateFreqHz)
Sets the period at which this control will update at.
Definition DifferentialPositionDutyCycle.hpp:352
std::map< std::string, std::string > GetControlInfo() const override
Gets information about this control request.
Definition DifferentialPositionDutyCycle.hpp:384
DifferentialPositionDutyCycle(units::angle::turn_t TargetPosition, units::angle::turn_t DifferentialPosition)
Request PID to target position with a differential position setpoint.
Definition DifferentialPositionDutyCycle.hpp:149
bool IgnoreHardwareLimits
Set to true to ignore hardware limit switches and the LimitForwardMotion and LimitReverseMotion param...
Definition DifferentialPositionDutyCycle.hpp:112
DifferentialPositionDutyCycle & WithDifferentialSlot(int newDifferentialSlot)
Modifies this Control Request's DifferentialSlot parameter and returns itself for method-chaining and...
Definition DifferentialPositionDutyCycle.hpp:236
units::frequency::hertz_t UpdateFreqHz
The period at which this control will update at.
Definition DifferentialPositionDutyCycle.hpp:136
bool UseTimesync
Set to true to delay applying this control request until a timesync boundary (requires Phoenix Pro an...
Definition DifferentialPositionDutyCycle.hpp:123
DifferentialPositionDutyCycle & WithDifferentialPosition(units::angle::turn_t newDifferentialPosition)
Modifies this Control Request's DifferentialPosition parameter and returns itself for method-chaining...
Definition DifferentialPositionDutyCycle.hpp:178
DifferentialPositionDutyCycle & WithIgnoreHardwareLimits(bool newIgnoreHardwareLimits)
Modifies this Control Request's IgnoreHardwareLimits parameter and returns itself for method-chaining...
Definition DifferentialPositionDutyCycle.hpp:311
bool EnableFOC
Set to true to use FOC commutation (requires Phoenix Pro), which increases peak power by ~15%.
Definition DifferentialPositionDutyCycle.hpp:68
DifferentialPositionDutyCycle & WithEnableFOC(bool newEnableFOC)
Modifies this Control Request's EnableFOC parameter and returns itself for method-chaining and easier...
Definition DifferentialPositionDutyCycle.hpp:202
DifferentialPositionDutyCycle & WithTargetSlot(int newTargetSlot)
Modifies this Control Request's TargetSlot parameter and returns itself for method-chaining and easie...
Definition DifferentialPositionDutyCycle.hpp:219
bool LimitForwardMotion
Set to true to force forward limiting.
Definition DifferentialPositionDutyCycle.hpp:93
DifferentialPositionDutyCycle & WithOverrideBrakeDurNeutral(bool newOverrideBrakeDurNeutral)
Modifies this Control Request's OverrideBrakeDurNeutral parameter and returns itself for method-chain...
Definition DifferentialPositionDutyCycle.hpp:254
DifferentialPositionDutyCycle & WithLimitReverseMotion(bool newLimitReverseMotion)
Modifies this Control Request's LimitReverseMotion parameter and returns itself for method-chaining a...
Definition DifferentialPositionDutyCycle.hpp:288
DifferentialPositionDutyCycle & WithTargetPosition(units::angle::turn_t newTargetPosition)
Modifies this Control Request's TargetPosition parameter and returns itself for method-chaining and e...
Definition DifferentialPositionDutyCycle.hpp:163
units::angle::turn_t TargetPosition
Average position to drive toward in rotations.
Definition DifferentialPositionDutyCycle.hpp:51
std::string ToString() const override
Returns a string representation of the object.
Definition DifferentialPositionDutyCycle.hpp:362
DifferentialPositionDutyCycle & WithLimitForwardMotion(bool newLimitForwardMotion)
Modifies this Control Request's LimitForwardMotion parameter and returns itself for method-chaining a...
Definition DifferentialPositionDutyCycle.hpp:271
bool OverrideBrakeDurNeutral
Set to true to static-brake the rotor when output is zero (or within deadband).
Definition DifferentialPositionDutyCycle.hpp:87
Status codes reported by APIs, including OK, warnings, and errors.
Definition StatusCodes.h:27
Definition MotionMagicExpoTorqueCurrentFOC.hpp:18