13#include <units/frequency.h>
14#include <units/time.h>
15#include <units/angular_velocity.h>
16#include <units/angle.h>
30 ctre::phoenix::StatusCode SendRequest(
const char *network, uint32_t deviceHash, std::shared_ptr<ControlRequest> &req)
const override
32 if (req.get() !=
this)
35 if (reqCast !=
nullptr)
41 req = std::make_shared<DifferentialVelocityVoltage>(*
this);
45 return c_ctre_phoenix6_RequestControlDifferentialVelocityVoltage(network, deviceHash,
UpdateFreqHz.to<
double>(),
TargetVelocity.to<
double>(),
DifferentialPosition.to<
double>(),
EnableFOC,
TargetSlot,
DifferentialSlot,
OverrideBrakeDurNeutral,
LimitForwardMotion,
LimitReverseMotion,
IgnoreHardwareLimits,
UseTimesync);
380 std::stringstream ss;
381 ss <<
"Control: DifferentialVelocityVoltage" << std::endl;
382 ss <<
" TargetVelocity: " <<
TargetVelocity.to<
double>() <<
" rotations per second" << std::endl;
383 ss <<
" DifferentialPosition: " <<
DifferentialPosition.to<
double>() <<
" rotations" << std::endl;
384 ss <<
" EnableFOC: " <<
EnableFOC << std::endl;
385 ss <<
" TargetSlot: " <<
TargetSlot << std::endl;
391 ss <<
" UseTimesync: " <<
UseTimesync << std::endl;
402 std::map<std::string, std::string> controlInfo;
403 std::stringstream ss;
404 controlInfo[
"Name"] =
GetName();
405 ss <<
TargetVelocity.to<
double>(); controlInfo[
"TargetVelocity"] = ss.str(); ss.str(std::string{});
406 ss <<
DifferentialPosition.to<
double>(); controlInfo[
"DifferentialPosition"] = ss.str(); ss.str(std::string{});
407 ss <<
EnableFOC; controlInfo[
"EnableFOC"] = ss.str(); ss.str(std::string{});
408 ss <<
TargetSlot; controlInfo[
"TargetSlot"] = ss.str(); ss.str(std::string{});
409 ss <<
DifferentialSlot; controlInfo[
"DifferentialSlot"] = ss.str(); ss.str(std::string{});
411 ss <<
LimitForwardMotion; controlInfo[
"LimitForwardMotion"] = ss.str(); ss.str(std::string{});
412 ss <<
LimitReverseMotion; controlInfo[
"LimitReverseMotion"] = ss.str(); ss.str(std::string{});
413 ss <<
IgnoreHardwareLimits; controlInfo[
"IgnoreHardwareLimits"] = ss.str(); ss.str(std::string{});
414 ss <<
UseTimesync; controlInfo[
"UseTimesync"] = ss.str(); ss.str(std::string{});
CTREXPORT int c_ctre_phoenix6_RequestControlDifferentialVelocityVoltage(const char *canbus, uint32_t ecuEncoding, double updateFrequency, double TargetVelocity, double DifferentialPosition, bool EnableFOC, int TargetSlot, int DifferentialSlot, bool OverrideBrakeDurNeutral, 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
Request PID to target velocity with a differential position setpoint.
Definition DifferentialVelocityVoltage.hpp:29
bool UseTimesync
Set to true to delay applying this control request until a timesync boundary (requires Phoenix Pro an...
Definition DifferentialVelocityVoltage.hpp:131
DifferentialVelocityVoltage & WithLimitReverseMotion(bool newLimitReverseMotion)
Modifies this Control Request's LimitReverseMotion parameter and returns itself for method-chaining a...
Definition DifferentialVelocityVoltage.hpp:304
DifferentialVelocityVoltage & WithLimitForwardMotion(bool newLimitForwardMotion)
Modifies this Control Request's LimitForwardMotion parameter and returns itself for method-chaining a...
Definition DifferentialVelocityVoltage.hpp:287
DifferentialVelocityVoltage & WithTargetSlot(int newTargetSlot)
Modifies this Control Request's TargetSlot parameter and returns itself for method-chaining and easie...
Definition DifferentialVelocityVoltage.hpp:235
int DifferentialSlot
Select which gains are applied to the differential controller by selecting the slot.
Definition DifferentialVelocityVoltage.hpp:88
std::map< std::string, std::string > GetControlInfo() const override
Gets information about this control request.
Definition DifferentialVelocityVoltage.hpp:400
units::frequency::hertz_t UpdateFreqHz
The period at which this control will update at.
Definition DifferentialVelocityVoltage.hpp:144
DifferentialVelocityVoltage & WithUseTimesync(bool newUseTimesync)
Modifies this Control Request's UseTimesync parameter and returns itself for method-chaining and easi...
Definition DifferentialVelocityVoltage.hpp:349
bool EnableFOC
Set to true to use FOC commutation (requires Phoenix Pro), which increases peak power by ~15% on supp...
Definition DifferentialVelocityVoltage.hpp:76
DifferentialVelocityVoltage & WithIgnoreHardwareLimits(bool newIgnoreHardwareLimits)
Modifies this Control Request's IgnoreHardwareLimits parameter and returns itself for method-chaining...
Definition DifferentialVelocityVoltage.hpp:327
DifferentialVelocityVoltage & WithOverrideBrakeDurNeutral(bool newOverrideBrakeDurNeutral)
Modifies this Control Request's OverrideBrakeDurNeutral parameter and returns itself for method-chain...
Definition DifferentialVelocityVoltage.hpp:270
DifferentialVelocityVoltage & WithUpdateFreqHz(units::frequency::hertz_t newUpdateFreqHz)
Sets the period at which this control will update at.
Definition DifferentialVelocityVoltage.hpp:368
DifferentialVelocityVoltage & WithTargetVelocity(units::angular_velocity::turns_per_second_t newTargetVelocity)
Modifies this Control Request's TargetVelocity parameter and returns itself for method-chaining and e...
Definition DifferentialVelocityVoltage.hpp:175
DifferentialVelocityVoltage & WithDifferentialPosition(units::angle::turn_t newDifferentialPosition)
Modifies this Control Request's DifferentialPosition parameter and returns itself for method-chaining...
Definition DifferentialVelocityVoltage.hpp:193
std::string ToString() const override
Returns a string representation of the object.
Definition DifferentialVelocityVoltage.hpp:378
bool OverrideBrakeDurNeutral
Set to true to static-brake the rotor when output is zero (or within deadband).
Definition DifferentialVelocityVoltage.hpp:95
bool LimitForwardMotion
Set to true to force forward limiting.
Definition DifferentialVelocityVoltage.hpp:101
units::angular_velocity::turns_per_second_t TargetVelocity
Average velocity to drive toward in rotations per second.
Definition DifferentialVelocityVoltage.hpp:55
bool LimitReverseMotion
Set to true to force reverse limiting.
Definition DifferentialVelocityVoltage.hpp:107
units::angle::turn_t DifferentialPosition
Differential position to drive toward in rotations.
Definition DifferentialVelocityVoltage.hpp:62
bool IgnoreHardwareLimits
Set to true to ignore hardware limit switches and the LimitForwardMotion and LimitReverseMotion param...
Definition DifferentialVelocityVoltage.hpp:120
DifferentialVelocityVoltage(units::angular_velocity::turns_per_second_t TargetVelocity, units::angle::turn_t DifferentialPosition)
Request PID to target velocity with a differential position setpoint.
Definition DifferentialVelocityVoltage.hpp:158
DifferentialVelocityVoltage & WithDifferentialSlot(int newDifferentialSlot)
Modifies this Control Request's DifferentialSlot parameter and returns itself for method-chaining and...
Definition DifferentialVelocityVoltage.hpp:252
DifferentialVelocityVoltage & WithEnableFOC(bool newEnableFOC)
Modifies this Control Request's EnableFOC parameter and returns itself for method-chaining and easier...
Definition DifferentialVelocityVoltage.hpp:218
int TargetSlot
Select which gains are applied to the primary controller by selecting the slot.
Definition DifferentialVelocityVoltage.hpp:82
Status codes reported by APIs, including OK, warnings, and errors.
Definition StatusCodes.h:27
Definition Diff_PositionDutyCycle_Position.hpp:15