13#include <units/angle.h>
14#include <units/frequency.h>
15#include <units/time.h>
30 ctre::phoenix::StatusCode SendRequest(
const char *network, uint32_t deviceHash,
bool cancelOtherRequests, std::shared_ptr<ControlRequest> &req)
override
32 if (req.get() !=
this)
35 if (reqCast !=
nullptr)
41 req = std::make_shared<DifferentialPositionDutyCycle>(*
this);
45 return c_ctre_phoenix6_RequestControlDifferentialPositionDutyCycle(network, deviceHash,
UpdateFreqHz.to<
double>(), cancelOtherRequests,
TargetPosition.to<
double>(),
DifferentialPosition.to<
double>(),
EnableFOC,
TargetSlot,
DifferentialSlot,
OverrideBrakeDurNeutral,
LimitForwardMotion,
LimitReverseMotion);
294 std::stringstream ss;
295 ss <<
"class: DifferentialPositionDutyCycle" << std::endl;
296 ss <<
"TargetPosition: " <<
TargetPosition.to<
double>() << std::endl;
298 ss <<
"EnableFOC: " <<
EnableFOC << std::endl;
299 ss <<
"TargetSlot: " <<
TargetSlot << std::endl;
314 std::map<std::string, std::string> controlInfo;
315 std::stringstream ss;
316 controlInfo[
"Name"] =
GetName();
317 ss <<
TargetPosition.to<
double>(); controlInfo[
"TargetPosition"] = ss.str(); ss.str(std::string{});
318 ss <<
DifferentialPosition.to<
double>(); controlInfo[
"DifferentialPosition"] = ss.str(); ss.str(std::string{});
319 ss <<
EnableFOC; controlInfo[
"EnableFOC"] = ss.str(); ss.str(std::string{});
320 ss <<
TargetSlot; controlInfo[
"TargetSlot"] = ss.str(); ss.str(std::string{});
321 ss <<
DifferentialSlot; controlInfo[
"DifferentialSlot"] = ss.str(); ss.str(std::string{});
323 ss <<
LimitForwardMotion; controlInfo[
"LimitForwardMotion"] = ss.str(); ss.str(std::string{});
324 ss <<
LimitReverseMotion; controlInfo[
"LimitReverseMotion"] = ss.str(); ss.str(std::string{});
CTREXPORT int c_ctre_phoenix6_RequestControlDifferentialPositionDutyCycle(const char *canbus, uint32_t ecuEncoding, double updateTime, bool cancelOtherRequests, double TargetPosition, double DifferentialPosition, bool EnableFOC, int TargetSlot, int DifferentialSlot, bool OverrideBrakeDurNeutral, bool LimitForwardMotion, bool LimitReverseMotion)
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 position with a differential position setpoint.
Definition: DifferentialPositionDutyCycle.hpp:29
int TargetSlot
Select which gains are applied to the primary controller by selecting the slot.
Definition: DifferentialPositionDutyCycle.hpp:73
int DifferentialSlot
Select which gains are applied to the differential controller by selecting the slot.
Definition: DifferentialPositionDutyCycle.hpp:79
units::angle::turn_t DifferentialPosition
Differential position to drive toward in rotations.
Definition: DifferentialPositionDutyCycle.hpp:56
bool LimitReverseMotion
Set to true to force reverse limiting.
Definition: DifferentialPositionDutyCycle.hpp:98
DifferentialPositionDutyCycle & WithUpdateFreqHz(units::frequency::hertz_t newUpdateFreqHz)
Sets the period at which this control will update at.
Definition: DifferentialPositionDutyCycle.hpp:282
std::map< std::string, std::string > GetControlInfo() const override
Gets information about this control request.
Definition: DifferentialPositionDutyCycle.hpp:312
DifferentialPositionDutyCycle(units::angle::turn_t TargetPosition, units::angle::turn_t DifferentialPosition, bool EnableFOC=true, int TargetSlot=0, int DifferentialSlot=1, bool OverrideBrakeDurNeutral=false, bool LimitForwardMotion=false, bool LimitReverseMotion=false)
Request PID to target position with a differential position setpoint.
Definition: DifferentialPositionDutyCycle.hpp:162
DifferentialPositionDutyCycle & WithDifferentialSlot(int newDifferentialSlot)
Modifies this Control Request's DifferentialSlot parameter and returns itself for method-chaining and...
Definition: DifferentialPositionDutyCycle.hpp:227
units::frequency::hertz_t UpdateFreqHz
The period at which this control will update at.
Definition: DifferentialPositionDutyCycle.hpp:111
DifferentialPositionDutyCycle & WithDifferentialPosition(units::angle::turn_t newDifferentialPosition)
Modifies this Control Request's DifferentialPosition parameter and returns itself for method-chaining...
Definition: DifferentialPositionDutyCycle.hpp:191
bool EnableFOC
Set to true to use FOC commutation (requires Phoenix Pro), which increases peak power by ~15%.
Definition: DifferentialPositionDutyCycle.hpp:67
DifferentialPositionDutyCycle & WithEnableFOC(bool newEnableFOC)
Modifies this Control Request's EnableFOC parameter and returns itself for method-chaining and easier...
Definition: DifferentialPositionDutyCycle.hpp:203
DifferentialPositionDutyCycle & WithTargetSlot(int newTargetSlot)
Modifies this Control Request's TargetSlot parameter and returns itself for method-chaining and easie...
Definition: DifferentialPositionDutyCycle.hpp:215
bool LimitForwardMotion
Set to true to force forward limiting.
Definition: DifferentialPositionDutyCycle.hpp:92
DifferentialPositionDutyCycle & WithOverrideBrakeDurNeutral(bool newOverrideBrakeDurNeutral)
Modifies this Control Request's OverrideBrakeDurNeutral parameter and returns itself for method-chain...
Definition: DifferentialPositionDutyCycle.hpp:239
DifferentialPositionDutyCycle & WithLimitReverseMotion(bool newLimitReverseMotion)
Modifies this Control Request's LimitReverseMotion parameter and returns itself for method-chaining a...
Definition: DifferentialPositionDutyCycle.hpp:263
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:179
units::angle::turn_t TargetPosition
Average position to drive toward in rotations.
Definition: DifferentialPositionDutyCycle.hpp:52
std::string ToString() const override
Returns a string representation of the object.
Definition: DifferentialPositionDutyCycle.hpp:292
DifferentialPositionDutyCycle & WithLimitForwardMotion(bool newLimitForwardMotion)
Modifies this Control Request's LimitForwardMotion parameter and returns itself for method-chaining a...
Definition: DifferentialPositionDutyCycle.hpp:251
bool OverrideBrakeDurNeutral
Set to true to static-brake the rotor when output is zero (or within deadband).
Definition: DifferentialPositionDutyCycle.hpp:86
Definition: RcManualEvent.hpp:12