13#include <units/current.h>
14#include <units/dimensionless.h>
15#include <units/frequency.h>
16#include <units/time.h>
32 bool ApplyConfigsOnRequest;
34 ctre::phoenix::StatusCode SendRequest(
const char *network, uint32_t deviceHash,
bool cancelOtherRequests, std::shared_ptr<ControlRequest> &req)
38 ss <<
Output.to<
double>(); ref[
"Output"] = ss.str(); ss.str(std::string());
39 ss <<
MaxAbsDutyCycle.to<
double>(); ref[
"MaxAbsDutyCycle"] = ss.str(); ss.str(std::string());
40 ss <<
Deadband.to<
double>(); ref[
"Deadband"] = ss.str(); ss.str(std::string());
43 if (req.get() !=
this)
46 if (reqCast !=
nullptr)
52 req = std::make_shared<TorqueCurrentFOC>(*
this);
57 std::string strs{ss.str()};
59 ApplyConfigsOnRequest =
false;
244 std::stringstream ss;
245 ss <<
"class: TorqueCurrentFOC" << std::endl;
246 ss <<
"Output: " <<
Output.to<
double>() << std::endl;
247 ss <<
"MaxAbsDutyCycle: " <<
MaxAbsDutyCycle.to<
double>() << std::endl;
248 ss <<
"Deadband: " <<
Deadband.to<
double>() << std::endl;
CTREXPORT int c_ctre_phoenixpro_RequestControlTorqueCurrentFOC(const char *canbus, uint32_t ecuEncoding, double updateTime, bool cancelOtherRequests, double Output, double MaxAbsDutyCycle, double Deadband, bool OverrideCoastDurNeutral)
CTREXPORT int c_ctre_phoenixpro_requestConfigApply(const char *canbus, uint32_t ecuEncoding, double timeoutSeconds, const char *str, uint32_t strlen, bool forceApply)
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 current (field oriented control).
Definition: TorqueCurrentFOC.hpp:31
units::time::second_t ConfigTimeout
The timeout when sending configs associated with this control.
Definition: TorqueCurrentFOC.hpp:99
units::dimensionless::scalar_t MaxAbsDutyCycle
The maximum absolute motor output that can be applied, which effectively limits the velocity.
Definition: TorqueCurrentFOC.hpp:76
units::current::ampere_t Output
Amount of motor current in Amperes.
Definition: TorqueCurrentFOC.hpp:67
TorqueCurrentFOC & WithOutput(units::current::ampere_t newOutput)
Modifies this Control Request's Output parameter and returns itself for method-chaining and easier to...
Definition: TorqueCurrentFOC.hpp:177
TorqueCurrentFOC & WithMaxAbsDutyCycle(units::dimensionless::scalar_t newMaxAbsDutyCycle)
Modifies this Control Request's MaxAbsDutyCycle parameter and returns itself for method-chaining and ...
Definition: TorqueCurrentFOC.hpp:189
std::string ToString() const
Returns a string representation of the object.
Definition: TorqueCurrentFOC.hpp:242
TorqueCurrentFOC(units::current::ampere_t Output)
Request a specified motor current (field oriented control).
Definition: TorqueCurrentFOC.hpp:168
bool OverrideCoastDurNeutral
Set to true to coast the rotor when output is zero (or within deadband).
Definition: TorqueCurrentFOC.hpp:92
TorqueCurrentFOC & WithOverrideCoastDurNeutral(bool newOverrideCoastDurNeutral)
Modifies this Control Request's OverrideCoastDurNeutral parameter and returns itself for method-chain...
Definition: TorqueCurrentFOC.hpp:213
TorqueCurrentFOC & WithDeadband(units::current::ampere_t newDeadband)
Modifies this Control Request's Deadband parameter and returns itself for method-chaining and easier ...
Definition: TorqueCurrentFOC.hpp:201
units::current::ampere_t Deadband
Deadband in Amperes.
Definition: TorqueCurrentFOC.hpp:85
void ForceApplyConfigs()
Forces configs to be applied the next time this is used in a setControl.
Definition: TorqueCurrentFOC.hpp:258
TorqueCurrentFOC(units::current::ampere_t Output, units::dimensionless::scalar_t MaxAbsDutyCycle, units::current::ampere_t Deadband, bool OverrideCoastDurNeutral)
Request a specified motor current (field oriented control).
Definition: TorqueCurrentFOC.hpp:150
units::frequency::hertz_t UpdateFreqHz
The period at which this control will update at.
Definition: TorqueCurrentFOC.hpp:112
TorqueCurrentFOC & WithUpdateFreqHz(units::frequency::hertz_t newUpdateFreqHz)
Sets the period at which this control will update at.
Definition: TorqueCurrentFOC.hpp:232
Definition: string_util.hpp:14