2023-Robot
Robot code for 2023 FRC season by Argos, FRC team #1756
Loading...
Searching...
No Matches
field_points.h
Go to the documentation of this file.
1
4
5#pragma once
6
8#include <frc/geometry/Pose2d.h>
9#include <frc/geometry/Translation2d.h>
10#include <frc/geometry/Translation3d.h>
11#include <frc/spline/Spline.h>
12#include <units/angle.h>
13#include <units/length.h>
14
15#include <vector>
16
17#include "measure_up.h"
18
34
35enum class ScoringRow { low, middle, high, invalid };
36
43
45
46struct Node {
48 frc::Translation3d m_position;
49};
50
52 // Field max x and y
53 constexpr auto fieldMaxY = 315.5975_in;
54 constexpr auto fieldMaxX = 651.2225_in;
55 constexpr auto fieldMiddleX = fieldMaxX / 2;
56} // namespace field_dimensions
57
58namespace utils {
59 // * Note this will only work on points contained in friendly half of field
63 constexpr frc::Translation3d ReflectFieldPoint(const frc::Translation3d source) {
64 return frc::Translation3d{source.X(), field_dimensions::fieldMaxY - source.Y(), source.Z()};
65 }
66
67 constexpr frc::Translation2d ReflectFieldPoint(const frc::Translation2d source) {
68 return frc::Translation2d{source.X(), field_dimensions::fieldMaxY - source.Y()};
69 }
70
71 constexpr units::angle::degree_t ReflectAngle(const units::angle::degree_t sourceAngle) {
72 return sourceAngle * units::scalar_t{-1};
73 }
74
75 template <class T>
76 std::vector<T> ReflectFieldPoint(const std::vector<T> source) {
77 std::vector<T> retVal;
78 retVal.reserve(source.size());
79 std::transform(
80 source.begin(), source.end(), std::back_inserter(retVal), [](T val) { return ReflectFieldPoint(val); });
81 return retVal;
82 }
83
84 constexpr frc::Spline<3>::ControlVector ReflectFieldPoint(const frc::Spline<3>::ControlVector source) {
85 return frc::Spline<3>::ControlVector{
86 .x{source.x}, .y{units::meter_t{field_dimensions::fieldMaxY}.to<double>() - source.y[0], -source.y[1]}};
87 }
88
89 frc::Pose2d ReflectFieldPoint(const frc::Pose2d source);
90
91 constexpr units::inch_t ReflectYLine(const units::inch_t source) {
92 return field_dimensions::fieldMaxY - source;
93 }
94} // namespace utils
95
96// (Inner grid is closest to loading station, outer is farthest, and middle is... middle)
97// Refernce pg 10 in field drawings for scoring grid dimensions
98// Node index 0 of inner grid is 14.5244 in in x direction, and 20.185 in in y direction (Blue alliance)
99// All field positions are relative to friendly alliance
100// * NOTE: in order to get red alliance field positions, call the TranslateAlliance function in the utils namespace
101namespace field_points {
102
103 // double human player substation height from floor, depth, and width
104 constexpr auto doubleSubstationHeight = 37.375_in;
105 constexpr auto doubleSubstationDepth = 13_in;
106 constexpr auto doubleSubstationSliderWidth = 14_in;
107 // single human player substation portal height from floor to bottom, floor to top, and width
108 constexpr auto singleSubstationHeightTop = 45.125_in;
109 constexpr auto singleSubstationHeightBottom = 27.125_in;
110 constexpr auto singleSubstationWidth = 22.75_in;
111 namespace grids {
112 constexpr auto gridDepth = 54.05_in;
113 // high cone and cube node heights from floor and depths
114 constexpr auto highConeNodeDepth = 39.75_in;
115 constexpr auto highConeNodeHeight = 46_in;
116 constexpr auto highCubeNodeDepth = 39.75_in;
117 constexpr auto highCubeNodeHeight = 35.5_in;
118 // middle cone and cube node heights from floor and depths
119 constexpr auto middleConeNodeDepth = 22.75_in;
120 constexpr auto middleConeNodeHeight = 34_in;
121 constexpr auto middleCubeNodeDepth = 22.75_in;
122 constexpr auto middleCubeNodeHeight = 23.5_in;
123 // low cone and cube node heights from floor and depths
124 constexpr auto lowConeNodeDepth = 12_in;
125 constexpr auto lowConeNodeHeight = 0_in;
126 constexpr auto lowCubeNodeDepth = 12_in;
127 constexpr auto lowCubeNodeHeight = 0_in;
128
129 // Universal alliance X-positions for scoring
130 constexpr auto highNodeX = 14.5244_in;
131 constexpr auto middleNodeX = 31.55_in;
132 constexpr auto lowNodeX = 46.01708_in;
133
134 } // namespace grids
135
136 namespace charge_station {
138 constexpr units::inch_t innerEdgeX = 115.894_in;
140 constexpr units::inch_t outerEdgeX = 190.105_in;
141
142 } // namespace charge_station
143
144 namespace blue_alliance {
145 // Reference game_piece_positions in Docs directory for conventions
146 namespace game_pieces {
147 constexpr auto gp_0 = frc::Translation3d{278.25_in, 180_in, 0_in};
148 constexpr auto gp_1 = frc::Translation3d{278.25_in, 132_in, 0_in};
149 constexpr auto gp_2 = frc::Translation3d{278.25_in, 84_in, 0_in};
150 constexpr auto gp_3 = frc::Translation3d{278.25_in, 36_in, 0_in};
151 } // namespace game_pieces
152
153 namespace charge_station {
154 constexpr frc::Translation3d chargeStationCenter = frc::Translation3d{153_in, 108_in, 9_in};
155 } // namespace charge_station
156
157 // Blue Alliance Y-Positions for nodes
158 // Columns are named left, middle, right as if you are facing them from inside the field
159 // Same as documented picture in /docs
160 constexpr auto innerGridLeftY = 196.185_in;
161 constexpr auto innerGridMiddleY = 174.185_in;
162 constexpr auto innerGridRightY = 152.185_in;
163 constexpr auto coopGridLeftY = 130.185_in;
164 constexpr auto coopGridMiddleY = 108.185_in;
165 constexpr auto coopGridRightY = 86.185_in;
166 constexpr auto outerGridLeftY = 64.185_in;
167 constexpr auto outerGridMiddleY = 42.185_in;
168 constexpr auto outerGridRightY = 20.185_in;
169 namespace inner_grid {
170
171 // Top row
182
183 // Middle row
196
197 // Bottom row
204
205 } // namespace inner_grid
206 namespace coop_grid {
207 // Top row
217
218 // Middle row
231
232 // Bottom row
239
240 } // namespace coop_grid
241 namespace outer_grid {
242 // Top row
253
254 // Middle row
267
268 // Bottom row
275
276 } // namespace outer_grid
277 } // namespace blue_alliance
278
279 namespace red_alliance {
286
287 namespace charge_station {
288 constexpr frc::Translation3d chargeStationCenter =
290 } // namespace charge_station
291
292 // Red Alliance Y-Positions for nodes
293 // Columns are named left, middle, right as if you are facing them from inside the field
294 // Same as documented picture in /docs
383
384 } // namespace red_alliance
385} // namespace field_points
386
387namespace cone {
388 constexpr auto coneWidth = 6_in;
389} // namespace cone
ScoringColumn
Definition field_points.h:19
ScoringRow
Definition field_points.h:35
GamePiece
Definition field_points.h:44
@ HYBRID
Definition field_points.h:44
@ CONE
Definition field_points.h:44
@ CUBE
Definition field_points.h:44
Definition field_points.h:387
constexpr auto coneWidth
Does not include square rim.
Definition field_points.h:388
Definition field_points.h:51
constexpr auto fieldMaxX
Definition field_points.h:54
constexpr auto fieldMaxY
Definition field_points.h:53
constexpr auto fieldMiddleX
Definition field_points.h:55
constexpr frc::Translation3d chargeStationCenter
Definition field_points.h:154
constexpr Node middleRowRight
Definition field_points.h:227
constexpr Node topRowMiddle
Definition field_points.h:211
constexpr Node bottomRowRight
Definition field_points.h:237
constexpr Node middleRowLeft
Definition field_points.h:219
constexpr Node bottomRowMiddle
Definition field_points.h:235
constexpr Node middleRowMiddle
Definition field_points.h:223
constexpr Node bottomRowLeft
Definition field_points.h:233
constexpr Node topRowLeft
Definition field_points.h:208
constexpr Node topRowRight
Definition field_points.h:214
constexpr auto gp_1
Definition field_points.h:148
constexpr auto gp_3
Definition field_points.h:150
constexpr auto gp_0
Definition field_points.h:147
constexpr auto gp_2
Definition field_points.h:149
constexpr Node middleRowRight
Definition field_points.h:192
constexpr Node bottomRowLeft
Definition field_points.h:198
constexpr Node topRowLeft
Definition field_points.h:172
constexpr Node bottomRowRight
Definition field_points.h:202
constexpr Node topRowMiddle
Definition field_points.h:175
constexpr Node topRowRight
Definition field_points.h:179
constexpr Node middleRowMiddle
Definition field_points.h:188
constexpr Node middleRowLeft
Definition field_points.h:184
constexpr Node bottomRowMiddle
Definition field_points.h:200
constexpr Node bottomRowLeft
Definition field_points.h:269
constexpr Node middleRowRight
Definition field_points.h:263
constexpr Node topRowMiddle
Definition field_points.h:246
constexpr Node bottomRowRight
Definition field_points.h:273
constexpr Node middleRowLeft
Definition field_points.h:255
constexpr Node middleRowMiddle
Definition field_points.h:259
constexpr Node topRowRight
Definition field_points.h:250
constexpr Node topRowLeft
Definition field_points.h:243
constexpr Node bottomRowMiddle
Definition field_points.h:271
constexpr auto coopGridMiddleY
Definition field_points.h:164
constexpr auto outerGridRightY
Definition field_points.h:168
constexpr auto innerGridRightY
Definition field_points.h:162
constexpr auto innerGridMiddleY
Definition field_points.h:161
constexpr auto innerGridLeftY
Definition field_points.h:160
constexpr auto coopGridLeftY
Definition field_points.h:163
constexpr auto coopGridRightY
Definition field_points.h:165
constexpr auto outerGridMiddleY
Definition field_points.h:167
constexpr auto outerGridLeftY
Definition field_points.h:166
constexpr units::inch_t outerEdgeX
Side closest to the game pieces.
Definition field_points.h:140
constexpr units::inch_t innerEdgeX
Side closest to the driver station.
Definition field_points.h:138
constexpr auto middleConeNodeDepth
Definition field_points.h:119
constexpr auto highCubeNodeDepth
Definition field_points.h:116
constexpr auto lowCubeNodeHeight
Definition field_points.h:127
constexpr auto middleConeNodeHeight
Definition field_points.h:120
constexpr auto middleNodeX
Definition field_points.h:131
constexpr auto highCubeNodeHeight
Definition field_points.h:117
constexpr auto middleCubeNodeDepth
Definition field_points.h:121
constexpr auto lowNodeX
Definition field_points.h:132
constexpr auto lowConeNodeHeight
Definition field_points.h:125
constexpr auto highConeNodeHeight
Definition field_points.h:115
constexpr auto lowConeNodeDepth
Definition field_points.h:124
constexpr auto highConeNodeDepth
Definition field_points.h:114
constexpr auto middleCubeNodeHeight
Definition field_points.h:122
constexpr auto lowCubeNodeDepth
Definition field_points.h:126
constexpr auto gridDepth
Distance from alliance station wall to end of grid dividers.
Definition field_points.h:112
constexpr auto highNodeX
Definition field_points.h:130
constexpr frc::Translation3d chargeStationCenter
Definition field_points.h:288
constexpr Node middleRowRight
Definition field_points.h:346
constexpr Node bottomRowLeft
Definition field_points.h:349
constexpr Node topRowMiddle
Definition field_points.h:336
constexpr Node bottomRowMiddle
Definition field_points.h:351
constexpr Node topRowRight
Definition field_points.h:338
constexpr Node topRowLeft
Definition field_points.h:334
constexpr Node middleRowLeft
Definition field_points.h:342
constexpr Node middleRowMiddle
Definition field_points.h:344
constexpr Node bottomRowRight
Definition field_points.h:353
constexpr auto gp_0
Definition field_points.h:281
constexpr auto gp_1
Definition field_points.h:282
constexpr auto gp_2
Definition field_points.h:283
constexpr auto gp_3
Definition field_points.h:284
constexpr Node topRowLeft
Definition field_points.h:307
constexpr Node middleRowLeft
Definition field_points.h:315
constexpr Node bottomRowLeft
Definition field_points.h:323
constexpr Node bottomRowRight
Definition field_points.h:327
constexpr Node topRowRight
Definition field_points.h:311
constexpr Node bottomRowMiddle
Definition field_points.h:325
constexpr Node middleRowMiddle
Definition field_points.h:317
constexpr Node topRowMiddle
Definition field_points.h:309
constexpr Node middleRowRight
Definition field_points.h:319
constexpr Node middleRowLeft
Definition field_points.h:367
constexpr Node topRowLeft
Definition field_points.h:359
constexpr Node bottomRowLeft
Definition field_points.h:375
constexpr Node bottomRowRight
Definition field_points.h:379
constexpr Node topRowMiddle
Definition field_points.h:361
constexpr Node topRowRight
Definition field_points.h:363
constexpr Node middleRowMiddle
Definition field_points.h:369
constexpr Node bottomRowMiddle
Definition field_points.h:377
constexpr Node middleRowRight
Definition field_points.h:371
constexpr auto innerGridLeftY
Definition field_points.h:295
constexpr auto innerGridMiddleY
Definition field_points.h:296
constexpr auto outerGridRightY
Definition field_points.h:303
constexpr auto coopGridMiddleY
Definition field_points.h:299
constexpr auto innerGridRightY
Definition field_points.h:297
constexpr auto outerGridLeftY
Definition field_points.h:301
constexpr auto outerGridMiddleY
Definition field_points.h:302
constexpr auto coopGridLeftY
Definition field_points.h:298
constexpr auto coopGridRightY
Definition field_points.h:300
Definition field_points.h:101
constexpr auto singleSubstationHeightBottom
Definition field_points.h:109
constexpr auto singleSubstationWidth
Definition field_points.h:110
constexpr auto doubleSubstationSliderWidth
Definition field_points.h:106
constexpr auto doubleSubstationHeight
Definition field_points.h:104
constexpr auto doubleSubstationDepth
Definition field_points.h:105
constexpr auto singleSubstationHeightTop
Definition field_points.h:108
Definition field_points.h:58
constexpr units::angle::degree_t ReflectAngle(const units::angle::degree_t sourceAngle)
Definition field_points.h:71
constexpr units::inch_t ReflectYLine(const units::inch_t source)
Definition field_points.h:91
constexpr frc::Translation3d ReflectFieldPoint(const frc::Translation3d source)
Reflects the point source over the middle of the field to get equivelent points accross the field.
Definition field_points.h:63
Definition field_points.h:46
frc::Translation3d m_position
Definition field_points.h:48
GamePiece m_gamePiece
Definition field_points.h:47
Definition field_points.h:37
ScoringColumn column
Definition field_points.h:38
auto operator<=>(const ScoringPosition &other) const =default
ScoringRow row
Definition field_points.h:39