12#include <units/current.h>
13#include <units/dimensionless.h>
14#include <units/frequency.h>
15#include <units/time.h>
32 ctre::phoenix::StatusCode SendRequest(
const char *network, uint32_t deviceHash, std::shared_ptr<ControlRequest> &req)
const override
34 if (req.get() !=
this)
37 if (reqCast !=
nullptr)
43 req = std::make_shared<TorqueCurrentFOC>(*
this);
47 return c_ctre_phoenix6_RequestControlTorqueCurrentFOC(network, deviceHash,
UpdateFreqHz.to<
double>(),
Output.to<
double>(),
MaxAbsDutyCycle.to<
double>(),
Deadband.to<
double>(),
OverrideCoastDurNeutral,
LimitForwardMotion,
LimitReverseMotion,
IgnoreHardwareLimits,
UseTimesync);
157 Output = std::move(newOutput);
323 std::stringstream ss;
324 ss <<
"Control: TorqueCurrentFOC" << std::endl;
325 ss <<
" Output: " <<
Output.to<
double>() <<
" A" << std::endl;
326 ss <<
" MaxAbsDutyCycle: " <<
MaxAbsDutyCycle.to<
double>() <<
" fractional" << std::endl;
327 ss <<
" Deadband: " <<
Deadband.to<
double>() <<
" A" << std::endl;
332 ss <<
" UseTimesync: " <<
UseTimesync << std::endl;
343 std::map<std::string, std::string> controlInfo;
344 std::stringstream ss;
345 controlInfo[
"Name"] =
GetName();
346 ss <<
Output.to<
double>(); controlInfo[
"Output"] = ss.str(); ss.str(std::string{});
347 ss <<
MaxAbsDutyCycle.to<
double>(); controlInfo[
"MaxAbsDutyCycle"] = ss.str(); ss.str(std::string{});
348 ss <<
Deadband.to<
double>(); controlInfo[
"Deadband"] = ss.str(); ss.str(std::string{});
350 ss <<
LimitForwardMotion; controlInfo[
"LimitForwardMotion"] = ss.str(); ss.str(std::string{});
351 ss <<
LimitReverseMotion; controlInfo[
"LimitReverseMotion"] = ss.str(); ss.str(std::string{});
352 ss <<
IgnoreHardwareLimits; controlInfo[
"IgnoreHardwareLimits"] = ss.str(); ss.str(std::string{});
353 ss <<
UseTimesync; controlInfo[
"UseTimesync"] = ss.str(); ss.str(std::string{});
CTREXPORT int c_ctre_phoenix6_RequestControlTorqueCurrentFOC(const char *canbus, uint32_t ecuEncoding, double updateTime, double Output, double MaxAbsDutyCycle, double Deadband, bool OverrideCoastDurNeutral, 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
Requires Phoenix Pro; Request a specified motor current (field oriented control).
Definition TorqueCurrentFOC.hpp:31
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:195
TorqueCurrentFOC & WithLimitForwardMotion(bool newLimitForwardMotion)
Modifies this Control Request's LimitForwardMotion parameter and returns itself for method-chaining a...
Definition TorqueCurrentFOC.hpp:230
TorqueCurrentFOC & WithUseTimesync(bool newUseTimesync)
Modifies this Control Request's UseTimesync parameter and returns itself for method-chaining and easi...
Definition TorqueCurrentFOC.hpp:292
TorqueCurrentFOC & WithUpdateFreqHz(units::frequency::hertz_t newUpdateFreqHz)
Sets the period at which this control will update at.
Definition TorqueCurrentFOC.hpp:311
std::map< std::string, std::string > GetControlInfo() const override
Gets information about this control request.
Definition TorqueCurrentFOC.hpp:341
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:155
bool IgnoreHardwareLimits
Set to true to ignore hardware limit switches and the LimitForwardMotion and LimitReverseMotion param...
Definition TorqueCurrentFOC.hpp:105
bool UseTimesync
Set to true to delay applying this control request until a timesync boundary (requires Phoenix Pro an...
Definition TorqueCurrentFOC.hpp:116
TorqueCurrentFOC & WithLimitReverseMotion(bool newLimitReverseMotion)
Modifies this Control Request's LimitReverseMotion parameter and returns itself for method-chaining a...
Definition TorqueCurrentFOC.hpp:247
units::current::ampere_t Output
Amount of motor current in Amperes.
Definition TorqueCurrentFOC.hpp:54
bool OverrideCoastDurNeutral
Set to true to coast the rotor when output is zero (or within deadband).
Definition TorqueCurrentFOC.hpp:80
TorqueCurrentFOC & WithOverrideCoastDurNeutral(bool newOverrideCoastDurNeutral)
Modifies this Control Request's OverrideCoastDurNeutral parameter and returns itself for method-chain...
Definition TorqueCurrentFOC.hpp:213
TorqueCurrentFOC & WithMaxAbsDutyCycle(units::dimensionless::scalar_t newMaxAbsDutyCycle)
Modifies this Control Request's MaxAbsDutyCycle parameter and returns itself for method-chaining and ...
Definition TorqueCurrentFOC.hpp:175
bool LimitReverseMotion
Set to true to force reverse limiting.
Definition TorqueCurrentFOC.hpp:92
units::current::ampere_t Deadband
Deadband in Amperes.
Definition TorqueCurrentFOC.hpp:73
TorqueCurrentFOC & WithIgnoreHardwareLimits(bool newIgnoreHardwareLimits)
Modifies this Control Request's IgnoreHardwareLimits parameter and returns itself for method-chaining...
Definition TorqueCurrentFOC.hpp:270
bool LimitForwardMotion
Set to true to force forward limiting.
Definition TorqueCurrentFOC.hpp:86
TorqueCurrentFOC(units::current::ampere_t Output)
Requires Phoenix Pro; Request a specified motor current (field oriented control).
Definition TorqueCurrentFOC.hpp:142
std::string ToString() const override
Returns a string representation of the object.
Definition TorqueCurrentFOC.hpp:321
units::frequency::hertz_t UpdateFreqHz
The period at which this control will update at.
Definition TorqueCurrentFOC.hpp:129
units::dimensionless::scalar_t MaxAbsDutyCycle
The maximum absolute motor output that can be applied, which effectively limits the velocity.
Definition TorqueCurrentFOC.hpp:63
Status codes reported by APIs, including OK, warnings, and errors.
Definition StatusCodes.h:27
Definition MotionMagicExpoTorqueCurrentFOC.hpp:18