13#include <units/dimensionless.h>
14#include <units/frequency.h>
15#include <units/time.h>
29 bool ApplyConfigsOnRequest;
31 ctre::phoenix::StatusCode SendRequest(
const char *network, uint32_t deviceHash,
bool cancelOtherRequests, std::shared_ptr<ControlRequest> &req)
35 ss <<
Output.to<
double>(); ref[
"Output"] = ss.str(); ss.str(std::string());
36 ss <<
EnableFOC; ref[
"EnableFOC"] = ss.str(); ss.str(std::string());
39 if (req.get() !=
this)
41 auto const reqCast =
dynamic_cast<DutyCycleOut *
>(req.get());
42 if (reqCast !=
nullptr)
48 req = std::make_shared<DutyCycleOut>(*
this);
53 std::string strs{ss.str()};
55 ApplyConfigsOnRequest =
false;
63 units::dimensionless::scalar_t
Output;
212 std::stringstream ss;
213 ss <<
"class: DutyCycleOut" << std::endl;
214 ss <<
"Output: " <<
Output.to<
double>() << std::endl;
215 ss <<
"EnableFOC: " <<
EnableFOC << std::endl;
CTREXPORT int c_ctre_phoenixpro_requestConfigApply(const char *canbus, uint32_t ecuEncoding, double timeoutSeconds, const char *str, uint32_t strlen, bool forceApply)
CTREXPORT int c_ctre_phoenixpro_RequestControlDutyCycleOut(const char *canbus, uint32_t ecuEncoding, double updateTime, bool cancelOtherRequests, double Output, bool EnableFOC, bool OverrideBrakeDurNeutral)
std::map< std::string, std::string > & GetNameValues()
Gets the map of control parameter names to the corresponding applied value.
Definition: ControlRequest.hpp:52
Abstract Control Request class that other control requests extend for use.
Definition: ControlRequest.hpp:65
ControlInfo requestReference
Definition: ControlRequest.hpp:70
Request a specified motor duty cycle.
Definition: DutyCycleOut.hpp:28
units::frequency::hertz_t UpdateFreqHz
The period at which this control will update at.
Definition: DutyCycleOut.hpp:101
DutyCycleOut & WithOutput(units::dimensionless::scalar_t newOutput)
Modifies this Control Request's Output parameter and returns itself for method-chaining and easier to...
Definition: DutyCycleOut.hpp:157
DutyCycleOut & WithEnableFOC(bool newEnableFOC)
Modifies this Control Request's EnableFOC parameter and returns itself for method-chaining and easier...
Definition: DutyCycleOut.hpp:169
void ForceApplyConfigs()
Forces configs to be applied the next time this is used in a setControl.
Definition: DutyCycleOut.hpp:225
bool OverrideBrakeDurNeutral
Set to true to static-brake the rotor when output is zero (or within deadband).
Definition: DutyCycleOut.hpp:81
units::dimensionless::scalar_t Output
Proportion of supply voltage to apply in fractional units between -1 and +1.
Definition: DutyCycleOut.hpp:63
DutyCycleOut & WithUpdateFreqHz(units::frequency::hertz_t newUpdateFreqHz)
Sets the period at which this control will update at.
Definition: DutyCycleOut.hpp:200
bool EnableFOC
Set to true to use FOC commutation, which increases peak power by ~15%.
Definition: DutyCycleOut.hpp:74
DutyCycleOut(units::dimensionless::scalar_t Output, bool EnableFOC, bool OverrideBrakeDurNeutral)
Request a specified motor duty cycle.
Definition: DutyCycleOut.hpp:132
std::string ToString() const
Returns a string representation of the object.
Definition: DutyCycleOut.hpp:210
DutyCycleOut(units::dimensionless::scalar_t Output)
Request a specified motor duty cycle.
Definition: DutyCycleOut.hpp:148
units::time::second_t ConfigTimeout
The timeout when sending configs associated with this control.
Definition: DutyCycleOut.hpp:88
DutyCycleOut & WithOverrideBrakeDurNeutral(bool newOverrideBrakeDurNeutral)
Modifies this Control Request's OverrideBrakeDurNeutral parameter and returns itself for method-chain...
Definition: DutyCycleOut.hpp:181
Definition: string_util.hpp:14