13#include <units/angular_velocity.h>
14#include <units/angle.h>
15#include <units/frequency.h>
16#include <units/time.h>
31 ctre::phoenix::StatusCode SendRequest(
const char *network, uint32_t deviceHash,
bool cancelOtherRequests, std::shared_ptr<ControlRequest> &req)
override
33 if (req.get() !=
this)
36 if (reqCast !=
nullptr)
42 req = std::make_shared<DifferentialVelocityVoltage>(*
this);
46 return c_ctre_phoenix6_RequestControlDifferentialVelocityVoltage(network, deviceHash,
UpdateFreqHz.to<
double>(), cancelOtherRequests,
TargetVelocity.to<
double>(),
DifferentialPosition.to<
double>(),
EnableFOC,
TargetSlot,
DifferentialSlot,
OverrideBrakeDurNeutral,
LimitForwardMotion,
LimitReverseMotion);
343 std::stringstream ss;
344 ss <<
"class: DifferentialVelocityVoltage" << std::endl;
345 ss <<
"TargetVelocity: " <<
TargetVelocity.to<
double>() << std::endl;
347 ss <<
"EnableFOC: " <<
EnableFOC << std::endl;
348 ss <<
"TargetSlot: " <<
TargetSlot << std::endl;
363 std::map<std::string, std::string> controlInfo;
364 std::stringstream ss;
365 controlInfo[
"Name"] =
GetName();
366 ss <<
TargetVelocity.to<
double>(); controlInfo[
"TargetVelocity"] = ss.str(); ss.str(std::string{});
367 ss <<
DifferentialPosition.to<
double>(); controlInfo[
"DifferentialPosition"] = ss.str(); ss.str(std::string{});
368 ss <<
EnableFOC; controlInfo[
"EnableFOC"] = ss.str(); ss.str(std::string{});
369 ss <<
TargetSlot; controlInfo[
"TargetSlot"] = ss.str(); ss.str(std::string{});
370 ss <<
DifferentialSlot; controlInfo[
"DifferentialSlot"] = ss.str(); ss.str(std::string{});
372 ss <<
LimitForwardMotion; controlInfo[
"LimitForwardMotion"] = ss.str(); ss.str(std::string{});
373 ss <<
LimitReverseMotion; controlInfo[
"LimitReverseMotion"] = ss.str(); ss.str(std::string{});
CTREXPORT int c_ctre_phoenix6_RequestControlDifferentialVelocityVoltage(const char *canbus, uint32_t ecuEncoding, double updateTime, bool cancelOtherRequests, double TargetVelocity, double DifferentialPosition, bool EnableFOC, int TargetSlot, int DifferentialSlot, bool OverrideBrakeDurNeutral, bool LimitForwardMotion, bool LimitReverseMotion)
Abstract Control Request class that other control requests extend for use.
Definition: ControlRequest.hpp:28
std::string const & GetName() const
Definition: ControlRequest.hpp:51
Request PID to target velocity with a differential position setpoint.
Definition: DifferentialVelocityVoltage.hpp:30
DifferentialVelocityVoltage & WithLimitReverseMotion(bool newLimitReverseMotion)
Modifies this Control Request's LimitReverseMotion parameter and returns itself for method-chaining a...
Definition: DifferentialVelocityVoltage.hpp:312
DifferentialVelocityVoltage & WithLimitForwardMotion(bool newLimitForwardMotion)
Modifies this Control Request's LimitForwardMotion parameter and returns itself for method-chaining a...
Definition: DifferentialVelocityVoltage.hpp:295
DifferentialVelocityVoltage & WithTargetSlot(int newTargetSlot)
Modifies this Control Request's TargetSlot parameter and returns itself for method-chaining and easie...
Definition: DifferentialVelocityVoltage.hpp:243
int DifferentialSlot
Select which gains are applied to the differential controller by selecting the slot.
Definition: DifferentialVelocityVoltage.hpp:82
std::map< std::string, std::string > GetControlInfo() const override
Gets information about this control request.
Definition: DifferentialVelocityVoltage.hpp:361
units::frequency::hertz_t UpdateFreqHz
The period at which this control will update at.
Definition: DifferentialVelocityVoltage.hpp:114
bool EnableFOC
Set to true to use FOC commutation (requires Phoenix Pro), which increases peak power by ~15%.
Definition: DifferentialVelocityVoltage.hpp:70
DifferentialVelocityVoltage & WithOverrideBrakeDurNeutral(bool newOverrideBrakeDurNeutral)
Modifies this Control Request's OverrideBrakeDurNeutral parameter and returns itself for method-chain...
Definition: DifferentialVelocityVoltage.hpp:278
DifferentialVelocityVoltage & WithUpdateFreqHz(units::frequency::hertz_t newUpdateFreqHz)
Sets the period at which this control will update at.
Definition: DifferentialVelocityVoltage.hpp:331
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:187
DifferentialVelocityVoltage & WithDifferentialPosition(units::angle::turn_t newDifferentialPosition)
Modifies this Control Request's DifferentialPosition parameter and returns itself for method-chaining...
Definition: DifferentialVelocityVoltage.hpp:202
std::string ToString() const override
Returns a string representation of the object.
Definition: DifferentialVelocityVoltage.hpp:341
bool OverrideBrakeDurNeutral
Set to true to static-brake the rotor when output is zero (or within deadband).
Definition: DifferentialVelocityVoltage.hpp:89
bool LimitForwardMotion
Set to true to force forward limiting.
Definition: DifferentialVelocityVoltage.hpp:95
units::angular_velocity::turns_per_second_t TargetVelocity
Average velocity to drive toward in rotations per second.
Definition: DifferentialVelocityVoltage.hpp:53
bool LimitReverseMotion
Set to true to force reverse limiting.
Definition: DifferentialVelocityVoltage.hpp:101
units::angle::turn_t DifferentialPosition
Differential position to drive toward in rotations.
Definition: DifferentialVelocityVoltage.hpp:57
DifferentialVelocityVoltage(units::angular_velocity::turns_per_second_t TargetVelocity, units::angle::turn_t DifferentialPosition, bool EnableFOC=true, int TargetSlot=0, int DifferentialSlot=1, bool OverrideBrakeDurNeutral=false, bool LimitForwardMotion=false, bool LimitReverseMotion=false)
Request PID to target velocity with a differential position setpoint.
Definition: DifferentialVelocityVoltage.hpp:167
DifferentialVelocityVoltage & WithDifferentialSlot(int newDifferentialSlot)
Modifies this Control Request's DifferentialSlot parameter and returns itself for method-chaining and...
Definition: DifferentialVelocityVoltage.hpp:260
DifferentialVelocityVoltage & WithEnableFOC(bool newEnableFOC)
Modifies this Control Request's EnableFOC parameter and returns itself for method-chaining and easier...
Definition: DifferentialVelocityVoltage.hpp:226
int TargetSlot
Select which gains are applied to the primary controller by selecting the slot.
Definition: DifferentialVelocityVoltage.hpp:76
Definition: string_util.hpp:15