CTRE Phoenix C++ 5.33.1
TrajectoryPoint.h
Go to the documentation of this file.
1/* Copyright (C) Cross The Road Electronics 2024 */
2#pragma once
3#include <stdint.h>
4namespace ctre {
5 namespace phoenix {
6 namespace motion {
7 /**
8 * Motion Profile Trajectory Point
9 * This is simply a data transfer object.
10 */
12 /** The position to servo to (in sensor units). */
13 double position = 0;
14 /** The velocity to feed-forward (in sensor-units per 100ms). */
15 double velocity = 0;
16 /** Added to the output of PID[0], should be within [-1,+1] where 0.01 = 1%. */
17 double arbFeedFwd = 0;
18 /** Not used. Use auxiliaryPos instead. @see auxiliaryPos */
19 double headingDeg = 0;
20 /** The position for auxiliary PID[1] to target (in sensor units). */
21 double auxiliaryPos = 0;
22 /** The velocity for auxiliary PID[1] to target. (in sensor-units per 100ms). */
23 double auxiliaryVel = 0;
24 /** Added to the output of PID[1], should be within [-1,+1] where 0.01 = 1%. */
26
27 /**
28 * Which slot to get PIDF gains.
29 * PID is used for position servo.
30 * F is used as the Kv constant for velocity feed-forward.
31 * Typically this is hard-coded
32 * to a particular slot, but you are free to gain schedule if need be.
33 * gain schedule if need be.
34 * Choose from [0,3].
35 */
36 uint32_t profileSlotSelect0 = 0;
37
38 /**
39 * Which slot to get PIDF gains for auxiliary PID.
40 * This only has impact during MotionProfileArc Control mode.
41 * Choose from [0,3].
42 */
43 uint32_t profileSlotSelect1 = 0;
44 /**
45 * Set to true to signal Talon that this is the final point, so do not
46 * attempt to pop another trajectory point from out of the Talon buffer.
47 * Instead continue processing this way point. Typically the velocity
48 * member variable should be zero so that the motor doesn't spin indefinitely.
49 */
50 bool isLastPoint = false;
51 /**
52 * Set to true to signal Talon to zero the selected sensor.
53 * When generating MPs, one simple method is to make the first target position zero,
54 * and the final target position the target distance from the current position.
55 * Then when you fire the MP, the current position gets set to zero.
56 * If this is the intent, you can set zeroPos on the first trajectory point.
57 *
58 * Otherwise you can leave this false for all points, and offset the positions
59 * of all trajectory points so they are correct.
60 *
61 * If using multiple sensor sources (Arc modes) we recommend you manually set sensor positions
62 * before arming MP.
63 */
64 bool zeroPos = false;
65
66 /**
67 * Duration (ms) to apply this trajectory pt.
68 * This time unit is ADDED to the existing base time set by
69 * ConfigMotionProfileTrajectoryPeriod().
70 */
71 int timeDur = 0;
72
73 /**
74 * If using MotionProfileArc, this flag must be true on all points.
75 * If using MotionProfile, this flag must be false on all points.
76 */
77 bool useAuxPID = false;
78
80 /* initializers above */
81 }
82
83 /**
84 * Create a trajectory point with specified values
85 *
86 * @param position The position to servo to (in sensor units).
87 * @param velocity The velocity to feed-forward (in sensor-units per 100ms).
88 * @param arbFeedFwd Added to the output of PID[0], should be within [-1,+1] where 0.01 = 1%.
89 * @param auxiliaryPos The position for auxiliary PID[1] to target (in sensor units).
90 * @param auxiliaryVel The velocity for auxiliary PID[1] to target. (in sensor-units per 100ms).
91 * @param auxiliaryArbFeedFwd Added to the output of PID[1], should be within [-1,+1] where 0.01 = 1%.
92 * @param profileSlotSelect0 The slot to select for base PIDF gains
93 * @param profileSlotSelect1 The slot to select for auxiliary PIDF gains
94 * @param isLastPoint True if this is the last piont
95 * @param zeroPos True if the motor controller should zero the sensor position
96 * @param timeDur The time duration of this point
97 * @param useAuxPID Enables the auxiliary PID
98 */
99
101 double velocity,
102 double arbFeedFwd,
103 double auxiliaryPos,
104 double auxiliaryVel,
105 double auxiliaryArbFeedFwd,
106 uint32_t profileSlotSelect0,
107 uint32_t profileSlotSelect1,
108 bool isLastPoint,
109 bool zeroPos,
110 uint32_t timeDur,
111 bool useAuxPID) {
112
113 this->position = position;
114 this->velocity = velocity;
115 this->arbFeedFwd = arbFeedFwd;
116 this->auxiliaryPos = auxiliaryPos;
117 this->auxiliaryVel = auxiliaryVel;
118 this->auxiliaryArbFeedFwd = auxiliaryArbFeedFwd;
119 this->profileSlotSelect0 = profileSlotSelect0;
120 this->profileSlotSelect1 = profileSlotSelect1;
121 this->isLastPoint = isLastPoint;
122 this->zeroPos = zeroPos;
123 this->timeDur = timeDur;
124 this->useAuxPID = useAuxPID;
125 }
126 };
127 } // namespace motion
128 } // namespace phoenix
129} // namespace ctre
namespace ctre
Definition: paramEnum.h:5
Motion Profile Trajectory Point This is simply a data transfer object.
Definition: TrajectoryPoint.h:11
TrajectoryPoint()
Definition: TrajectoryPoint.h:79
double auxiliaryPos
The position for auxiliary PID[1] to target (in sensor units).
Definition: TrajectoryPoint.h:21
double position
The position to servo to (in sensor units).
Definition: TrajectoryPoint.h:13
bool zeroPos
Set to true to signal Talon to zero the selected sensor.
Definition: TrajectoryPoint.h:64
double arbFeedFwd
Added to the output of PID[0], should be within [-1,+1] where 0.01 = 1%.
Definition: TrajectoryPoint.h:17
uint32_t profileSlotSelect0
Which slot to get PIDF gains.
Definition: TrajectoryPoint.h:36
double auxiliaryVel
The velocity for auxiliary PID[1] to target.
Definition: TrajectoryPoint.h:23
double auxiliaryArbFeedFwd
Added to the output of PID[1], should be within [-1,+1] where 0.01 = 1%.
Definition: TrajectoryPoint.h:25
bool useAuxPID
If using MotionProfileArc, this flag must be true on all points.
Definition: TrajectoryPoint.h:77
int timeDur
Duration (ms) to apply this trajectory pt.
Definition: TrajectoryPoint.h:71
double velocity
The velocity to feed-forward (in sensor-units per 100ms).
Definition: TrajectoryPoint.h:15
bool isLastPoint
Set to true to signal Talon that this is the final point, so do not attempt to pop another trajectory...
Definition: TrajectoryPoint.h:50
uint32_t profileSlotSelect1
Which slot to get PIDF gains for auxiliary PID.
Definition: TrajectoryPoint.h:43
double headingDeg
Not used.
Definition: TrajectoryPoint.h:19
TrajectoryPoint(double position, double velocity, double arbFeedFwd, double auxiliaryPos, double auxiliaryVel, double auxiliaryArbFeedFwd, uint32_t profileSlotSelect0, uint32_t profileSlotSelect1, bool isLastPoint, bool zeroPos, uint32_t timeDur, bool useAuxPID)
Create a trajectory point with specified values.
Definition: TrajectoryPoint.h:100