13#include <units/angle.h>
14#include <units/angular_velocity.h>
15#include <units/dimensionless.h>
16#include <units/frequency.h>
17#include <units/time.h>
32 bool ApplyConfigsOnRequest{
false};
34 ctre::phoenix::StatusCode SendRequest(
const char *network, uint32_t deviceHash,
bool cancelOtherRequests, std::shared_ptr<ControlRequest> &req)
override
36 if (req.get() !=
this)
39 if (reqCast !=
nullptr)
45 req = std::make_shared<PositionDutyCycle>(*
this);
51 std::string strs{ss.str()};
53 ApplyConfigsOnRequest =
false;
65 units::angular_velocity::turns_per_second_t
Velocity;
226 Slot = std::move(newSlot);
267 std::stringstream ss;
268 ss <<
"class: PositionDutyCycle" << std::endl;
269 ss <<
"Position: " <<
Position.to<
double>() << std::endl;
270 ss <<
"Velocity: " <<
Velocity.to<
double>() << std::endl;
271 ss <<
"EnableFOC: " <<
EnableFOC << std::endl;
272 ss <<
"FeedForward: " <<
FeedForward.to<
double>() << std::endl;
273 ss <<
"Slot: " <<
Slot << std::endl;
292 std::map<std::string, std::string> controlInfo;
293 std::stringstream ss;
294 controlInfo[
"Name"] =
GetName();
295 ss <<
Position.to<
double>(); controlInfo[
"Position"] = ss.str(); ss.str(std::string{});
296 ss <<
Velocity.to<
double>(); controlInfo[
"Velocity"] = ss.str(); ss.str(std::string{});
297 ss <<
EnableFOC; controlInfo[
"EnableFOC"] = ss.str(); ss.str(std::string{});
298 ss <<
FeedForward.to<
double>(); controlInfo[
"FeedForward"] = ss.str(); ss.str(std::string{});
299 ss <<
Slot; controlInfo[
"Slot"] = ss.str(); ss.str(std::string{});
CTREXPORT int c_ctre_phoenix6_RequestControlPositionDutyCycle(const char *canbus, uint32_t ecuEncoding, double updateTime, bool cancelOtherRequests, double Position, double Velocity, bool EnableFOC, double FeedForward, int Slot, bool OverrideBrakeDurNeutral)
CTREXPORT int c_ctre_phoenix6_requestConfigApply(const char *canbus, uint32_t ecuEncoding, double timeoutSeconds, const char *str, uint32_t strlen, bool forceApply)
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 position with duty cycle feedforward.
Definition: PositionDutyCycle.hpp:31
PositionDutyCycle & WithSlot(int newSlot)
Modifies this Control Request's Slot parameter and returns itself for method-chaining and easier to u...
Definition: PositionDutyCycle.hpp:224
units::dimensionless::scalar_t FeedForward
Feedforward to apply in fractional units between -1 and +1.
Definition: PositionDutyCycle.hpp:80
PositionDutyCycle & WithVelocity(units::angular_velocity::turns_per_second_t newVelocity)
Modifies this Control Request's Velocity parameter and returns itself for method-chaining and easier ...
Definition: PositionDutyCycle.hpp:188
PositionDutyCycle & WithEnableFOC(bool newEnableFOC)
Modifies this Control Request's EnableFOC parameter and returns itself for method-chaining and easier...
Definition: PositionDutyCycle.hpp:200
units::angular_velocity::turns_per_second_t Velocity
Velocity to drive toward in rotations per second.
Definition: PositionDutyCycle.hpp:65
PositionDutyCycle & WithFeedForward(units::dimensionless::scalar_t newFeedForward)
Modifies this Control Request's FeedForward parameter and returns itself for method-chaining and easi...
Definition: PositionDutyCycle.hpp:212
PositionDutyCycle(units::angle::turn_t Position, units::angular_velocity::turns_per_second_t Velocity, bool EnableFOC, units::dimensionless::scalar_t FeedForward, int Slot, bool OverrideBrakeDurNeutral)
Request PID to target position with duty cycle feedforward.
Definition: PositionDutyCycle.hpp:149
bool EnableFOC
Set to true to use FOC commutation (requires Phoenix Pro), which increases peak power by ~15%.
Definition: PositionDutyCycle.hpp:76
units::angle::turn_t Position
Position to drive toward in rotations.
Definition: PositionDutyCycle.hpp:61
int Slot
Select which gains are applied by selecting the slot.
Definition: PositionDutyCycle.hpp:86
std::map< std::string, std::string > GetControlInfo() const override
Gets information about this control request.
Definition: PositionDutyCycle.hpp:290
bool OverrideBrakeDurNeutral
Set to true to static-brake the rotor when output is zero (or within deadband).
Definition: PositionDutyCycle.hpp:93
units::frequency::hertz_t UpdateFreqHz
The period at which this control will update at.
Definition: PositionDutyCycle.hpp:113
PositionDutyCycle & WithUpdateFreqHz(units::frequency::hertz_t newUpdateFreqHz)
Sets the period at which this control will update at.
Definition: PositionDutyCycle.hpp:255
void ForceApplyConfigs()
Forces configs to be applied the next time this is used in a setControl.
Definition: PositionDutyCycle.hpp:283
units::time::second_t ConfigTimeout
The timeout when sending configs associated with this control.
Definition: PositionDutyCycle.hpp:100
PositionDutyCycle & WithOverrideBrakeDurNeutral(bool newOverrideBrakeDurNeutral)
Modifies this Control Request's OverrideBrakeDurNeutral parameter and returns itself for method-chain...
Definition: PositionDutyCycle.hpp:236
PositionDutyCycle & WithPosition(units::angle::turn_t newPosition)
Modifies this Control Request's Position parameter and returns itself for method-chaining and easier ...
Definition: PositionDutyCycle.hpp:176
std::string ToString() const override
Returns a string representation of the object.
Definition: PositionDutyCycle.hpp:265
PositionDutyCycle(units::angle::turn_t Position)
Request PID to target position with duty cycle feedforward.
Definition: PositionDutyCycle.hpp:167
Definition: ManualEvent.hpp:12