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);
169 Output = std::move(newOutput);
341 std::stringstream ss;
342 ss <<
"Control: TorqueCurrentFOC" << std::endl;
343 ss <<
" Output: " <<
Output.to<
double>() <<
" A" << std::endl;
344 ss <<
" MaxAbsDutyCycle: " <<
MaxAbsDutyCycle.to<
double>() <<
" fractional" << std::endl;
345 ss <<
" Deadband: " <<
Deadband.to<
double>() <<
" A" << std::endl;
350 ss <<
" UseTimesync: " <<
UseTimesync << std::endl;
361 std::map<std::string, std::string> controlInfo;
362 std::stringstream ss;
363 controlInfo[
"Name"] =
GetName();
364 ss <<
Output.to<
double>(); controlInfo[
"Output"] = ss.str(); ss.str(std::string{});
365 ss <<
MaxAbsDutyCycle.to<
double>(); controlInfo[
"MaxAbsDutyCycle"] = ss.str(); ss.str(std::string{});
366 ss <<
Deadband.to<
double>(); controlInfo[
"Deadband"] = ss.str(); ss.str(std::string{});
368 ss <<
LimitForwardMotion; controlInfo[
"LimitForwardMotion"] = ss.str(); ss.str(std::string{});
369 ss <<
LimitReverseMotion; controlInfo[
"LimitReverseMotion"] = ss.str(); ss.str(std::string{});
370 ss <<
IgnoreHardwareLimits; controlInfo[
"IgnoreHardwareLimits"] = ss.str(); ss.str(std::string{});
371 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:213
TorqueCurrentFOC & WithLimitForwardMotion(bool newLimitForwardMotion)
Modifies this Control Request's LimitForwardMotion parameter and returns itself for method-chaining a...
Definition TorqueCurrentFOC.hpp:248
TorqueCurrentFOC & WithUseTimesync(bool newUseTimesync)
Modifies this Control Request's UseTimesync parameter and returns itself for method-chaining and easi...
Definition TorqueCurrentFOC.hpp:310
TorqueCurrentFOC & WithUpdateFreqHz(units::frequency::hertz_t newUpdateFreqHz)
Sets the period at which this control will update at.
Definition TorqueCurrentFOC.hpp:329
std::map< std::string, std::string > GetControlInfo() const override
Gets information about this control request.
Definition TorqueCurrentFOC.hpp:359
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:167
bool IgnoreHardwareLimits
Set to true to ignore hardware limit switches and the LimitForwardMotion and LimitReverseMotion param...
Definition TorqueCurrentFOC.hpp:114
bool UseTimesync
Set to true to delay applying this control request until a timesync boundary (requires Phoenix Pro an...
Definition TorqueCurrentFOC.hpp:125
TorqueCurrentFOC & WithLimitReverseMotion(bool newLimitReverseMotion)
Modifies this Control Request's LimitReverseMotion parameter and returns itself for method-chaining a...
Definition TorqueCurrentFOC.hpp:265
units::current::ampere_t Output
Amount of motor current in Amperes.
Definition TorqueCurrentFOC.hpp:57
bool OverrideCoastDurNeutral
Set to true to coast the rotor when output is zero (or within deadband).
Definition TorqueCurrentFOC.hpp:89
TorqueCurrentFOC & WithOverrideCoastDurNeutral(bool newOverrideCoastDurNeutral)
Modifies this Control Request's OverrideCoastDurNeutral parameter and returns itself for method-chain...
Definition TorqueCurrentFOC.hpp:231
TorqueCurrentFOC & WithMaxAbsDutyCycle(units::dimensionless::scalar_t newMaxAbsDutyCycle)
Modifies this Control Request's MaxAbsDutyCycle parameter and returns itself for method-chaining and ...
Definition TorqueCurrentFOC.hpp:190
bool LimitReverseMotion
Set to true to force reverse limiting.
Definition TorqueCurrentFOC.hpp:101
units::current::ampere_t Deadband
Deadband in Amperes.
Definition TorqueCurrentFOC.hpp:82
TorqueCurrentFOC & WithIgnoreHardwareLimits(bool newIgnoreHardwareLimits)
Modifies this Control Request's IgnoreHardwareLimits parameter and returns itself for method-chaining...
Definition TorqueCurrentFOC.hpp:288
bool LimitForwardMotion
Set to true to force forward limiting.
Definition TorqueCurrentFOC.hpp:95
TorqueCurrentFOC(units::current::ampere_t Output)
Requires Phoenix Pro; Request a specified motor current (field oriented control).
Definition TorqueCurrentFOC.hpp:151
std::string ToString() const override
Returns a string representation of the object.
Definition TorqueCurrentFOC.hpp:339
units::frequency::hertz_t UpdateFreqHz
The period at which this control will update at.
Definition TorqueCurrentFOC.hpp:138
units::dimensionless::scalar_t MaxAbsDutyCycle
The maximum absolute motor output that can be applied, which effectively limits the velocity.
Definition TorqueCurrentFOC.hpp:69
Status codes reported by APIs, including OK, warnings, and errors.
Definition StatusCodes.h:27
Definition MotionMagicExpoTorqueCurrentFOC.hpp:18