Austin Schuh | 6bcc230 | 2019-03-23 22:28:06 -0700 | [diff] [blame] | 1 | #include "y2019/actors/auto_splines.h" |
| 2 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 3 | #include "frc971/control_loops/control_loops_generated.h" |
Austin Schuh | 6bcc230 | 2019-03-23 22:28:06 -0700 | [diff] [blame] | 4 | |
| 5 | namespace y2019 { |
| 6 | namespace actors { |
| 7 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 8 | void MaybeFlipSpline( |
| 9 | aos::Sender<frc971::control_loops::drivetrain::Goal>::Builder *builder, |
| 10 | flatbuffers::Offset<flatbuffers::Vector<float>> spline_y_offset, |
| 11 | bool is_left) { |
| 12 | |
| 13 | flatbuffers::Vector<float> *spline_y = |
| 14 | GetMutableTemporaryPointer(*builder->fbb(), spline_y_offset); |
| 15 | |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 16 | if (!is_left) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 17 | for (size_t i = 0; i < spline_y->size(); i++) { |
| 18 | spline_y->Mutate(i, -spline_y->Get(i)); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 19 | } |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | // Path off of level 2 to the far side of the rocket with a panel |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 24 | flatbuffers::Offset<frc971::MultiSpline> AutonomousSplines::HABToFarRocket( |
| 25 | aos::Sender<frc971::control_loops::drivetrain::Goal>::Builder *builder, |
| 26 | bool is_left) { |
| 27 | flatbuffers::Offset<frc971::Constraint> longitudinal_constraint_offset; |
| 28 | flatbuffers::Offset<frc971::Constraint> lateral_constraint_offset; |
| 29 | flatbuffers::Offset<frc971::Constraint> voltage_constraint_offset; |
| 30 | flatbuffers::Offset<frc971::Constraint> velocity_constraint_offset; |
James Kuszmaul | bc83787 | 2019-04-07 12:01:47 -0700 | [diff] [blame] | 31 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 32 | { |
| 33 | frc971::Constraint::Builder longitudinal_constraint_builder = |
| 34 | builder->MakeBuilder<frc971::Constraint>(); |
| 35 | longitudinal_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 36 | frc971::ConstraintType::LONGITUDINAL_ACCELERATION); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 37 | longitudinal_constraint_builder.add_value(2.0); |
| 38 | longitudinal_constraint_offset = longitudinal_constraint_builder.Finish(); |
| 39 | } |
James Kuszmaul | bc83787 | 2019-04-07 12:01:47 -0700 | [diff] [blame] | 40 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 41 | { |
| 42 | frc971::Constraint::Builder lateral_constraint_builder = |
| 43 | builder->MakeBuilder<frc971::Constraint>(); |
| 44 | lateral_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 45 | frc971::ConstraintType::LATERAL_ACCELERATION); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 46 | lateral_constraint_builder.add_value(2.0); |
| 47 | lateral_constraint_offset = lateral_constraint_builder.Finish(); |
| 48 | } |
James Kuszmaul | bc83787 | 2019-04-07 12:01:47 -0700 | [diff] [blame] | 49 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 50 | { |
| 51 | frc971::Constraint::Builder voltage_constraint_builder = |
| 52 | builder->MakeBuilder<frc971::Constraint>(); |
| 53 | voltage_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 54 | frc971::ConstraintType::VOLTAGE); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 55 | voltage_constraint_builder.add_value(11.0); |
| 56 | voltage_constraint_offset = voltage_constraint_builder.Finish(); |
| 57 | } |
James Kuszmaul | bc83787 | 2019-04-07 12:01:47 -0700 | [diff] [blame] | 58 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 59 | { |
| 60 | frc971::Constraint::Builder velocity_constraint_builder = |
| 61 | builder->MakeBuilder<frc971::Constraint>(); |
| 62 | velocity_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 63 | frc971::ConstraintType::VELOCITY); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 64 | velocity_constraint_builder.add_value(4.0); |
| 65 | velocity_constraint_builder.add_start_distance(0.0); |
| 66 | velocity_constraint_builder.add_end_distance(10.0); |
| 67 | velocity_constraint_offset = velocity_constraint_builder.Finish(); |
| 68 | } |
James Kuszmaul | bc83787 | 2019-04-07 12:01:47 -0700 | [diff] [blame] | 69 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 70 | flatbuffers::Offset< |
| 71 | flatbuffers::Vector<flatbuffers::Offset<frc971::Constraint>>> |
| 72 | constraints_offset = |
| 73 | builder->fbb()->CreateVector<flatbuffers::Offset<frc971::Constraint>>( |
| 74 | {longitudinal_constraint_offset, lateral_constraint_offset, |
| 75 | voltage_constraint_offset, velocity_constraint_offset}); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 76 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 77 | flatbuffers::Offset<flatbuffers::Vector<float>> spline_x_offset = |
| 78 | builder->fbb()->CreateVector<float>({1.14763818102, 1.66, 3.10, 4.05, |
| 79 | 4.45, 5.11, 5.77, 6.71, 7.27, 7.19, |
| 80 | 6.57}); |
| 81 | flatbuffers::Offset<flatbuffers::Vector<float>> spline_y_offset = |
| 82 | builder->fbb()->CreateVector<float>({1.30261224364, 1.30217320136, 1.39, |
| 83 | 1.47, 1.56346705393, 1.69, 1.81, |
| 84 | 1.97, 2.18, 2.84, 3.33}); |
| 85 | MaybeFlipSpline(builder, spline_y_offset, is_left); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 86 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 87 | frc971::MultiSpline::Builder multispline_builder = |
| 88 | builder->MakeBuilder<frc971::MultiSpline>(); |
| 89 | |
| 90 | multispline_builder.add_spline_count(2); |
| 91 | multispline_builder.add_constraints(constraints_offset); |
| 92 | multispline_builder.add_spline_x(spline_x_offset); |
| 93 | multispline_builder.add_spline_y(spline_y_offset); |
| 94 | |
| 95 | return multispline_builder.Finish(); |
James Kuszmaul | bc83787 | 2019-04-07 12:01:47 -0700 | [diff] [blame] | 96 | } |
| 97 | |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 98 | // Path from the far side of the rocket to the loading station to pickup |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 99 | flatbuffers::Offset<frc971::MultiSpline> AutonomousSplines::FarRocketToHP( |
| 100 | aos::Sender<frc971::control_loops::drivetrain::Goal>::Builder *builder, |
| 101 | bool is_left) { |
| 102 | flatbuffers::Offset<frc971::Constraint> longitudinal_constraint_offset; |
| 103 | flatbuffers::Offset<frc971::Constraint> lateral_constraint_offset; |
| 104 | flatbuffers::Offset<frc971::Constraint> voltage_constraint_offset; |
| 105 | flatbuffers::Offset<frc971::Constraint> velocity_constraint_offset; |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 106 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 107 | { |
| 108 | frc971::Constraint::Builder longitudinal_constraint_builder = |
| 109 | builder->MakeBuilder<frc971::Constraint>(); |
| 110 | longitudinal_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 111 | frc971::ConstraintType::LONGITUDINAL_ACCELERATION); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 112 | longitudinal_constraint_builder.add_value(3.0); |
| 113 | longitudinal_constraint_offset = longitudinal_constraint_builder.Finish(); |
| 114 | } |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 115 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 116 | { |
| 117 | frc971::Constraint::Builder lateral_constraint_builder = |
| 118 | builder->MakeBuilder<frc971::Constraint>(); |
| 119 | lateral_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 120 | frc971::ConstraintType::LATERAL_ACCELERATION); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 121 | lateral_constraint_builder.add_value(2.0); |
| 122 | lateral_constraint_offset = lateral_constraint_builder.Finish(); |
| 123 | } |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 124 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 125 | { |
| 126 | frc971::Constraint::Builder voltage_constraint_builder = |
| 127 | builder->MakeBuilder<frc971::Constraint>(); |
| 128 | voltage_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 129 | frc971::ConstraintType::VOLTAGE); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 130 | voltage_constraint_builder.add_value(11.0); |
| 131 | voltage_constraint_offset = voltage_constraint_builder.Finish(); |
| 132 | } |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 133 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 134 | { |
| 135 | frc971::Constraint::Builder velocity_constraint_builder = |
| 136 | builder->MakeBuilder<frc971::Constraint>(); |
| 137 | velocity_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 138 | frc971::ConstraintType::VELOCITY); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 139 | velocity_constraint_builder.add_value(4.5); |
| 140 | velocity_constraint_builder.add_start_distance(0.0); |
| 141 | velocity_constraint_builder.add_end_distance(10.0); |
| 142 | velocity_constraint_offset = velocity_constraint_builder.Finish(); |
| 143 | } |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 144 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 145 | flatbuffers::Offset< |
| 146 | flatbuffers::Vector<flatbuffers::Offset<frc971::Constraint>>> |
| 147 | constraints_offset = |
| 148 | builder->fbb()->CreateVector<flatbuffers::Offset<frc971::Constraint>>( |
| 149 | {longitudinal_constraint_offset, lateral_constraint_offset, |
| 150 | voltage_constraint_offset, velocity_constraint_offset}); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 151 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 152 | flatbuffers::Offset<flatbuffers::Vector<float>> spline_x_offset = |
| 153 | builder->fbb()->CreateVector<float>( |
| 154 | {6.6, 7.511, 6.332, 4.590, 1.561, 0.179}); |
| 155 | flatbuffers::Offset<flatbuffers::Vector<float>> spline_y_offset = |
| 156 | builder->fbb()->CreateVector<float>( |
| 157 | {3.391, 2.826, 1.384, 3.395 - 0.20, 3.429 - 0.20, 3.434 - 0.20}); |
| 158 | MaybeFlipSpline(builder, spline_y_offset, is_left); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 159 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 160 | frc971::MultiSpline::Builder multispline_builder = |
| 161 | builder->MakeBuilder<frc971::MultiSpline>(); |
| 162 | |
| 163 | multispline_builder.add_spline_count(1); |
| 164 | multispline_builder.add_constraints(constraints_offset); |
| 165 | multispline_builder.add_spline_x(spline_x_offset); |
| 166 | multispline_builder.add_spline_y(spline_y_offset); |
| 167 | |
| 168 | return multispline_builder.Finish(); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | // Path from the human player station to the far side of the rocket with a panel |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 172 | flatbuffers::Offset<frc971::MultiSpline> AutonomousSplines::HPToFarRocket( |
| 173 | aos::Sender<frc971::control_loops::drivetrain::Goal>::Builder *builder, |
| 174 | bool is_left) { |
| 175 | flatbuffers::Offset<frc971::Constraint> longitudinal_constraint_offset; |
| 176 | flatbuffers::Offset<frc971::Constraint> lateral_constraint_offset; |
| 177 | flatbuffers::Offset<frc971::Constraint> voltage_constraint_offset; |
| 178 | flatbuffers::Offset<frc971::Constraint> velocity_constraint_offset; |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 179 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 180 | { |
| 181 | frc971::Constraint::Builder longitudinal_constraint_builder = |
| 182 | builder->MakeBuilder<frc971::Constraint>(); |
| 183 | longitudinal_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 184 | frc971::ConstraintType::LONGITUDINAL_ACCELERATION); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 185 | longitudinal_constraint_builder.add_value(3.0); |
| 186 | longitudinal_constraint_offset = longitudinal_constraint_builder.Finish(); |
| 187 | } |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 188 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 189 | { |
| 190 | frc971::Constraint::Builder lateral_constraint_builder = |
| 191 | builder->MakeBuilder<frc971::Constraint>(); |
| 192 | lateral_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 193 | frc971::ConstraintType::LATERAL_ACCELERATION); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 194 | lateral_constraint_builder.add_value(3.0); |
| 195 | lateral_constraint_offset = lateral_constraint_builder.Finish(); |
| 196 | } |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 197 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 198 | { |
| 199 | frc971::Constraint::Builder voltage_constraint_builder = |
| 200 | builder->MakeBuilder<frc971::Constraint>(); |
| 201 | voltage_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 202 | frc971::ConstraintType::VOLTAGE); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 203 | voltage_constraint_builder.add_value(11.0); |
| 204 | voltage_constraint_offset = voltage_constraint_builder.Finish(); |
| 205 | } |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 206 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 207 | { |
| 208 | frc971::Constraint::Builder velocity_constraint_builder = |
| 209 | builder->MakeBuilder<frc971::Constraint>(); |
| 210 | velocity_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 211 | frc971::ConstraintType::VELOCITY); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 212 | velocity_constraint_builder.add_value(4.0); |
| 213 | velocity_constraint_builder.add_start_distance(7.0); |
| 214 | velocity_constraint_builder.add_end_distance(15.0); |
| 215 | velocity_constraint_offset = velocity_constraint_builder.Finish(); |
| 216 | } |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 217 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 218 | flatbuffers::Offset< |
| 219 | flatbuffers::Vector<flatbuffers::Offset<frc971::Constraint>>> |
| 220 | constraints_offset = |
| 221 | builder->fbb()->CreateVector<flatbuffers::Offset<frc971::Constraint>>( |
| 222 | {longitudinal_constraint_offset, lateral_constraint_offset, |
| 223 | voltage_constraint_offset, velocity_constraint_offset}); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 224 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 225 | flatbuffers::Offset<flatbuffers::Vector<float>> spline_x_offset = |
| 226 | builder->fbb()->CreateVector<float>({0.895115737979, 2.9155615909, |
| 227 | 5.02361983866, 6.40346237218, |
| 228 | 7.1260656844, 7.83907559509}); |
| 229 | flatbuffers::Offset<flatbuffers::Vector<float>> spline_y_offset = |
| 230 | builder->fbb()->CreateVector<float>({3.43030859063, 3.44230565037, |
| 231 | 2.8824369646, 2.81000389973, |
| 232 | 3.08853311072, 2.6933085577}); |
| 233 | MaybeFlipSpline(builder, spline_y_offset, is_left); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 234 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 235 | frc971::MultiSpline::Builder multispline_builder = |
| 236 | builder->MakeBuilder<frc971::MultiSpline>(); |
| 237 | |
| 238 | multispline_builder.add_spline_count(1); |
| 239 | multispline_builder.add_constraints(constraints_offset); |
| 240 | multispline_builder.add_spline_x(spline_x_offset); |
| 241 | multispline_builder.add_spline_y(spline_y_offset); |
| 242 | |
| 243 | return multispline_builder.Finish(); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | // Path from the far side of the rocket to close to the loading station |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 247 | flatbuffers::Offset<frc971::MultiSpline> AutonomousSplines::FarRocketToNearHP( |
| 248 | aos::Sender<frc971::control_loops::drivetrain::Goal>::Builder *builder, |
| 249 | bool is_left) { |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 250 | // TODO(theo): Add some real constraints. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 251 | flatbuffers::Offset<flatbuffers::Vector<float>> spline_x_offset = |
| 252 | builder->fbb()->CreateVector<float>({6.51652191988, 6.83156293562, |
| 253 | 5.74513904409, 2.2337653586, |
| 254 | 1.94766705864, 0.727526876557}); |
| 255 | flatbuffers::Offset<flatbuffers::Vector<float>> spline_y_offset = |
| 256 | builder->fbb()->CreateVector<float>({3.2465107468, 2.88277456846, |
| 257 | 1.93458779243, 3.44064777429, |
| 258 | 3.44377880106, 3.43326367284}); |
| 259 | MaybeFlipSpline(builder, spline_y_offset, is_left); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 260 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 261 | frc971::MultiSpline::Builder multispline_builder = |
| 262 | builder->MakeBuilder<frc971::MultiSpline>(); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 263 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 264 | multispline_builder.add_spline_count(1); |
| 265 | multispline_builder.add_spline_x(spline_x_offset); |
| 266 | multispline_builder.add_spline_y(spline_y_offset); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 267 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 268 | return multispline_builder.Finish(); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | // Path from level 2 to 2nd cargo ship bay with a hatch panel |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 272 | flatbuffers::Offset<frc971::MultiSpline> AutonomousSplines::HABToSecondCargoShipBay( |
| 273 | aos::Sender<frc971::control_loops::drivetrain::Goal>::Builder *builder, |
| 274 | bool is_left) { |
| 275 | flatbuffers::Offset<frc971::Constraint> longitudinal_constraint_offset; |
| 276 | flatbuffers::Offset<frc971::Constraint> voltage_constraint_offset; |
| 277 | flatbuffers::Offset<frc971::Constraint> velocity_constraint_offset; |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 278 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 279 | { |
| 280 | frc971::Constraint::Builder longitudinal_constraint_builder = |
| 281 | builder->MakeBuilder<frc971::Constraint>(); |
| 282 | longitudinal_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 283 | frc971::ConstraintType::LONGITUDINAL_ACCELERATION); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 284 | longitudinal_constraint_builder.add_value(2.0); |
| 285 | longitudinal_constraint_offset = longitudinal_constraint_builder.Finish(); |
| 286 | } |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 287 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 288 | { |
| 289 | frc971::Constraint::Builder voltage_constraint_builder = |
| 290 | builder->MakeBuilder<frc971::Constraint>(); |
| 291 | voltage_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 292 | frc971::ConstraintType::VOLTAGE); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 293 | voltage_constraint_builder.add_value(10.0); |
| 294 | voltage_constraint_offset = voltage_constraint_builder.Finish(); |
| 295 | } |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 296 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 297 | { |
| 298 | frc971::Constraint::Builder velocity_constraint_builder = |
| 299 | builder->MakeBuilder<frc971::Constraint>(); |
| 300 | velocity_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 301 | frc971::ConstraintType::VELOCITY); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 302 | velocity_constraint_builder.add_value(1.6); |
| 303 | velocity_constraint_builder.add_start_distance(4.0); |
| 304 | velocity_constraint_builder.add_end_distance(10.0); |
| 305 | velocity_constraint_offset = velocity_constraint_builder.Finish(); |
| 306 | } |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 307 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 308 | flatbuffers::Offset< |
| 309 | flatbuffers::Vector<flatbuffers::Offset<frc971::Constraint>>> |
| 310 | constraints_offset = |
| 311 | builder->fbb()->CreateVector<flatbuffers::Offset<frc971::Constraint>>( |
| 312 | {longitudinal_constraint_offset, voltage_constraint_offset, |
| 313 | velocity_constraint_offset}); |
| 314 | |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 315 | constexpr double kLess = 0.06; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 316 | flatbuffers::Offset<flatbuffers::Vector<float>> spline_x_offset = |
| 317 | builder->fbb()->CreateVector<float>( |
| 318 | {1.0, 2.53944573074, 5.75526086906, 6.52583747973 - kLess, |
| 319 | 7.12318661548 - kLess, 7.22595029399 - kLess}); |
| 320 | flatbuffers::Offset<flatbuffers::Vector<float>> spline_y_offset = |
| 321 | builder->fbb()->CreateVector<float>({1.5, 1.48, 2.05178220103, |
| 322 | 2.56666687655, 1.79340280288, |
| 323 | 1.16170693058}); |
| 324 | MaybeFlipSpline(builder, spline_y_offset, is_left); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 325 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 326 | frc971::MultiSpline::Builder multispline_builder = |
| 327 | builder->MakeBuilder<frc971::MultiSpline>(); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 328 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 329 | multispline_builder.add_spline_count(1); |
| 330 | multispline_builder.add_constraints(constraints_offset); |
| 331 | multispline_builder.add_spline_x(spline_x_offset); |
| 332 | multispline_builder.add_spline_y(spline_y_offset); |
| 333 | |
| 334 | return multispline_builder.Finish(); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | // Path from 2nd cargo ship bay to loading station |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 338 | flatbuffers::Offset<frc971::MultiSpline> AutonomousSplines::SecondCargoShipBayToHP( |
| 339 | aos::Sender<frc971::control_loops::drivetrain::Goal>::Builder *builder, |
| 340 | bool is_left) { |
| 341 | flatbuffers::Offset<frc971::Constraint> voltage_constraint_offset; |
| 342 | flatbuffers::Offset<frc971::Constraint> velocity_constraint_offset; |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 343 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 344 | { |
| 345 | frc971::Constraint::Builder voltage_constraint_builder = |
| 346 | builder->MakeBuilder<frc971::Constraint>(); |
| 347 | voltage_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 348 | frc971::ConstraintType::VOLTAGE); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 349 | voltage_constraint_builder.add_value(11.0); |
| 350 | voltage_constraint_offset = voltage_constraint_builder.Finish(); |
| 351 | } |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 352 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 353 | { |
| 354 | frc971::Constraint::Builder velocity_constraint_builder = |
| 355 | builder->MakeBuilder<frc971::Constraint>(); |
| 356 | velocity_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 357 | frc971::ConstraintType::VELOCITY); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 358 | velocity_constraint_builder.add_value(4.0); |
| 359 | velocity_constraint_builder.add_start_distance(0.0); |
| 360 | velocity_constraint_builder.add_end_distance(10.0); |
| 361 | velocity_constraint_offset = velocity_constraint_builder.Finish(); |
| 362 | } |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 363 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 364 | flatbuffers::Offset< |
| 365 | flatbuffers::Vector<flatbuffers::Offset<frc971::Constraint>>> |
| 366 | constraints_offset = |
| 367 | builder->fbb()->CreateVector<flatbuffers::Offset<frc971::Constraint>>( |
| 368 | {voltage_constraint_offset, velocity_constraint_offset}); |
| 369 | |
| 370 | flatbuffers::Offset<flatbuffers::Vector<float>> spline_x_offset = |
| 371 | builder->fbb()->CreateVector<float>({7.22595029399, 7.1892447864, |
| 372 | 6.5373977907, 5.55997590982, |
| 373 | 1.22953437637, 0.32521840905}); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 374 | constexpr double kYShift = 0.1; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 375 | flatbuffers::Offset<flatbuffers::Vector<float>> spline_y_offset = |
| 376 | builder->fbb()->CreateVector<float>( |
| 377 | {1.2, 1.44543230529, 2.00646674662, 3.43762336271 - kYShift, |
| 378 | 3.44125430793 - kYShift, 3.4360348159 - kYShift}); |
| 379 | MaybeFlipSpline(builder, spline_y_offset, is_left); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 380 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 381 | frc971::MultiSpline::Builder multispline_builder = |
| 382 | builder->MakeBuilder<frc971::MultiSpline>(); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 383 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 384 | multispline_builder.add_spline_count(1); |
| 385 | multispline_builder.add_constraints(constraints_offset); |
| 386 | multispline_builder.add_spline_x(spline_x_offset); |
| 387 | multispline_builder.add_spline_y(spline_y_offset); |
| 388 | |
| 389 | return multispline_builder.Finish(); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 390 | } |
| 391 | |
| 392 | // Path from loading station to 3rd cargo ship bay with a hatch panel |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 393 | flatbuffers::Offset<frc971::MultiSpline> AutonomousSplines::HPToThirdCargoShipBay( |
| 394 | aos::Sender<frc971::control_loops::drivetrain::Goal>::Builder *builder, |
| 395 | bool is_left) { |
| 396 | flatbuffers::Offset<frc971::Constraint> voltage_constraint_offset; |
| 397 | flatbuffers::Offset<frc971::Constraint> velocity_constraint_offset; |
| 398 | flatbuffers::Offset<frc971::Constraint> velocity_constraint2_offset; |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 399 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 400 | { |
| 401 | frc971::Constraint::Builder voltage_constraint_builder = |
| 402 | builder->MakeBuilder<frc971::Constraint>(); |
| 403 | voltage_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 404 | frc971::ConstraintType::VOLTAGE); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 405 | voltage_constraint_builder.add_value(10.0); |
| 406 | voltage_constraint_offset = voltage_constraint_builder.Finish(); |
| 407 | } |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 408 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 409 | { |
| 410 | frc971::Constraint::Builder velocity_constraint_builder = |
| 411 | builder->MakeBuilder<frc971::Constraint>(); |
| 412 | velocity_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 413 | frc971::ConstraintType::VELOCITY); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 414 | velocity_constraint_builder.add_value(3.5); |
| 415 | velocity_constraint_builder.add_start_distance(0.0); |
| 416 | velocity_constraint_builder.add_end_distance(10.0); |
| 417 | velocity_constraint_offset = velocity_constraint_builder.Finish(); |
| 418 | } |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 419 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 420 | { |
| 421 | frc971::Constraint::Builder velocity_constraint2_builder = |
| 422 | builder->MakeBuilder<frc971::Constraint>(); |
| 423 | velocity_constraint2_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 424 | frc971::ConstraintType::VELOCITY); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 425 | velocity_constraint2_builder.add_value(2.0); |
| 426 | velocity_constraint2_builder.add_start_distance(6.0); |
| 427 | velocity_constraint2_builder.add_end_distance(10.0); |
| 428 | velocity_constraint2_offset = velocity_constraint2_builder.Finish(); |
| 429 | } |
| 430 | |
| 431 | flatbuffers::Offset< |
| 432 | flatbuffers::Vector<flatbuffers::Offset<frc971::Constraint>>> |
| 433 | constraints_offset = |
| 434 | builder->fbb()->CreateVector<flatbuffers::Offset<frc971::Constraint>>( |
| 435 | {voltage_constraint_offset, velocity_constraint_offset, |
| 436 | velocity_constraint2_offset}); |
| 437 | |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 438 | constexpr double kEndMove = 0.25; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 439 | flatbuffers::Offset<flatbuffers::Vector<float>> spline_x_offset = |
| 440 | builder->fbb()->CreateVector<float>({0.75, 1.112, 5.576, 7.497 - kEndMove, |
| 441 | 7.675 - kEndMove, 7.768 - kEndMove}); |
| 442 | flatbuffers::Offset<flatbuffers::Vector<float>> spline_y_offset = |
| 443 | builder->fbb()->CreateVector<float>( |
| 444 | {3.431, 3.434, 2.712, 2.874, 1.786, 1.168}); |
| 445 | MaybeFlipSpline(builder, spline_y_offset, is_left); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 446 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 447 | frc971::MultiSpline::Builder multispline_builder = |
| 448 | builder->MakeBuilder<frc971::MultiSpline>(); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 449 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 450 | multispline_builder.add_spline_count(1); |
| 451 | multispline_builder.add_constraints(constraints_offset); |
| 452 | multispline_builder.add_spline_x(spline_x_offset); |
| 453 | multispline_builder.add_spline_y(spline_y_offset); |
| 454 | |
| 455 | return multispline_builder.Finish(); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 456 | } |
| 457 | |
| 458 | // Path from 3rd cargo ship bay to near the loading station |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 459 | flatbuffers::Offset<frc971::MultiSpline> AutonomousSplines::ThirdCargoShipBayToNearHP( |
| 460 | aos::Sender<frc971::control_loops::drivetrain::Goal>::Builder *builder, |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 461 | bool is_left) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 462 | flatbuffers::Offset<frc971::Constraint> velocity_constraint_offset; |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 463 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 464 | { |
| 465 | frc971::Constraint::Builder velocity_constraint_builder = |
| 466 | builder->MakeBuilder<frc971::Constraint>(); |
| 467 | velocity_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 468 | frc971::ConstraintType::VELOCITY); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 469 | velocity_constraint_builder.add_value(0.5); |
| 470 | velocity_constraint_builder.add_start_distance(0.0); |
| 471 | velocity_constraint_builder.add_end_distance(10.0); |
| 472 | velocity_constraint_offset = velocity_constraint_builder.Finish(); |
| 473 | } |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 474 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 475 | flatbuffers::Offset< |
| 476 | flatbuffers::Vector<flatbuffers::Offset<frc971::Constraint>>> |
| 477 | constraints_offset = |
| 478 | builder->fbb()->CreateVector<flatbuffers::Offset<frc971::Constraint>>( |
| 479 | {velocity_constraint_offset}); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 480 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 481 | flatbuffers::Offset<flatbuffers::Vector<float>> spline_x_offset = |
| 482 | builder->fbb()->CreateVector<float>({7.75823205276, 7.58356294646, |
| 483 | 5.95536035287, 2.12377989323, |
| 484 | 1.29347361128, 0.598613577531}); |
| 485 | flatbuffers::Offset<flatbuffers::Vector<float>> spline_y_offset = |
| 486 | builder->fbb()->CreateVector<float>({1.16791407107, 1.94564064915, |
| 487 | 2.54565614767, 3.43728005786, |
| 488 | 3.43775494434, 3.43119598027}); |
| 489 | MaybeFlipSpline(builder, spline_y_offset, is_left); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 490 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 491 | frc971::MultiSpline::Builder multispline_builder = |
| 492 | builder->MakeBuilder<frc971::MultiSpline>(); |
| 493 | |
| 494 | multispline_builder.add_spline_count(1); |
| 495 | multispline_builder.add_constraints(constraints_offset); |
| 496 | multispline_builder.add_spline_x(spline_x_offset); |
| 497 | multispline_builder.add_spline_y(spline_y_offset); |
| 498 | |
| 499 | return multispline_builder.Finish(); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 500 | } |
| 501 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 502 | flatbuffers::Offset<frc971::MultiSpline> AutonomousSplines::HabToFarRocketTest( |
| 503 | aos::Sender<frc971::control_loops::drivetrain::Goal>::Builder *builder, |
| 504 | bool is_left) { |
| 505 | flatbuffers::Offset<frc971::Constraint> longitudinal_constraint_offset; |
| 506 | flatbuffers::Offset<frc971::Constraint> lateral_constraint_offset; |
| 507 | flatbuffers::Offset<frc971::Constraint> voltage_constraint_offset; |
| 508 | flatbuffers::Offset<frc971::Constraint> velocity_constraint_offset; |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 509 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 510 | { |
| 511 | frc971::Constraint::Builder longitudinal_constraint_builder = |
| 512 | builder->MakeBuilder<frc971::Constraint>(); |
| 513 | longitudinal_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 514 | frc971::ConstraintType::LONGITUDINAL_ACCELERATION); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 515 | longitudinal_constraint_builder.add_value(2.0); |
| 516 | longitudinal_constraint_offset = longitudinal_constraint_builder.Finish(); |
| 517 | } |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 518 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 519 | { |
| 520 | frc971::Constraint::Builder lateral_constraint_builder = |
| 521 | builder->MakeBuilder<frc971::Constraint>(); |
| 522 | lateral_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 523 | frc971::ConstraintType::LATERAL_ACCELERATION); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 524 | lateral_constraint_builder.add_value(2.0); |
| 525 | lateral_constraint_offset = lateral_constraint_builder.Finish(); |
| 526 | } |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 527 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 528 | { |
| 529 | frc971::Constraint::Builder voltage_constraint_builder = |
| 530 | builder->MakeBuilder<frc971::Constraint>(); |
| 531 | voltage_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 532 | frc971::ConstraintType::VOLTAGE); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 533 | voltage_constraint_builder.add_value(11.0); |
| 534 | voltage_constraint_offset = voltage_constraint_builder.Finish(); |
| 535 | } |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 536 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 537 | { |
| 538 | frc971::Constraint::Builder velocity_constraint_builder = |
| 539 | builder->MakeBuilder<frc971::Constraint>(); |
| 540 | velocity_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 541 | frc971::ConstraintType::VELOCITY); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 542 | velocity_constraint_builder.add_value(1.7); |
| 543 | velocity_constraint_builder.add_start_distance(0.0); |
| 544 | velocity_constraint_builder.add_end_distance(0.8); |
| 545 | velocity_constraint_offset = velocity_constraint_builder.Finish(); |
| 546 | } |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 547 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 548 | flatbuffers::Offset< |
| 549 | flatbuffers::Vector<flatbuffers::Offset<frc971::Constraint>>> |
| 550 | constraints_offset = |
| 551 | builder->fbb()->CreateVector<flatbuffers::Offset<frc971::Constraint>>( |
| 552 | {longitudinal_constraint_offset, lateral_constraint_offset, |
| 553 | voltage_constraint_offset, velocity_constraint_offset}); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 554 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 555 | flatbuffers::Offset<flatbuffers::Vector<float>> spline_x_offset = |
| 556 | builder->fbb()->CreateVector<float>({1.14763818102, 2.53944573074, |
| 557 | 3.74586892131, 5.22352745444, |
| 558 | 6.70255737219, 7.35784750785}); |
| 559 | flatbuffers::Offset<flatbuffers::Vector<float>> spline_y_offset = |
| 560 | builder->fbb()->CreateVector<float>({1.30261224364, 1.28295363394, |
| 561 | 1.27450357714, 2.89953366429, |
| 562 | 3.10734391012, 2.90125929705}); |
| 563 | MaybeFlipSpline(builder, spline_y_offset, is_left); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 564 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 565 | frc971::MultiSpline::Builder multispline_builder = |
| 566 | builder->MakeBuilder<frc971::MultiSpline>(); |
| 567 | |
| 568 | multispline_builder.add_spline_count(1); |
| 569 | multispline_builder.add_constraints(constraints_offset); |
| 570 | multispline_builder.add_spline_x(spline_x_offset); |
| 571 | multispline_builder.add_spline_y(spline_y_offset); |
| 572 | |
| 573 | return multispline_builder.Finish(); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 574 | } |
| 575 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 576 | flatbuffers::Offset<frc971::MultiSpline> AutonomousSplines::FarRocketToHPTest( |
| 577 | aos::Sender<frc971::control_loops::drivetrain::Goal>::Builder *builder) { |
| 578 | flatbuffers::Offset<frc971::Constraint> longitudinal_constraint_offset; |
| 579 | flatbuffers::Offset<frc971::Constraint> lateral_constraint_offset; |
| 580 | flatbuffers::Offset<frc971::Constraint> voltage_constraint_offset; |
| 581 | flatbuffers::Offset<frc971::Constraint> velocity_constraint_offset; |
James Kuszmaul | bc83787 | 2019-04-07 12:01:47 -0700 | [diff] [blame] | 582 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 583 | { |
| 584 | frc971::Constraint::Builder longitudinal_constraint_builder = |
| 585 | builder->MakeBuilder<frc971::Constraint>(); |
| 586 | longitudinal_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 587 | frc971::ConstraintType::LONGITUDINAL_ACCELERATION); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 588 | longitudinal_constraint_builder.add_value(1.5); |
| 589 | longitudinal_constraint_offset = longitudinal_constraint_builder.Finish(); |
| 590 | } |
James Kuszmaul | bc83787 | 2019-04-07 12:01:47 -0700 | [diff] [blame] | 591 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 592 | { |
| 593 | frc971::Constraint::Builder lateral_constraint_builder = |
| 594 | builder->MakeBuilder<frc971::Constraint>(); |
| 595 | lateral_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 596 | frc971::ConstraintType::LATERAL_ACCELERATION); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 597 | lateral_constraint_builder.add_value(1.0); |
| 598 | lateral_constraint_offset = lateral_constraint_builder.Finish(); |
| 599 | } |
James Kuszmaul | bc83787 | 2019-04-07 12:01:47 -0700 | [diff] [blame] | 600 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 601 | { |
| 602 | frc971::Constraint::Builder voltage_constraint_builder = |
| 603 | builder->MakeBuilder<frc971::Constraint>(); |
| 604 | voltage_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 605 | frc971::ConstraintType::VOLTAGE); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 606 | voltage_constraint_builder.add_value(11.0); |
| 607 | voltage_constraint_offset = voltage_constraint_builder.Finish(); |
| 608 | } |
James Kuszmaul | bc83787 | 2019-04-07 12:01:47 -0700 | [diff] [blame] | 609 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 610 | { |
| 611 | frc971::Constraint::Builder velocity_constraint_builder = |
| 612 | builder->MakeBuilder<frc971::Constraint>(); |
| 613 | velocity_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 614 | frc971::ConstraintType::VELOCITY); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 615 | velocity_constraint_builder.add_value(0.5); |
| 616 | velocity_constraint_builder.add_start_distance(9.5); |
| 617 | velocity_constraint_builder.add_end_distance(10.0); |
| 618 | velocity_constraint_offset = velocity_constraint_builder.Finish(); |
| 619 | } |
James Kuszmaul | bc83787 | 2019-04-07 12:01:47 -0700 | [diff] [blame] | 620 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 621 | flatbuffers::Offset< |
| 622 | flatbuffers::Vector<flatbuffers::Offset<frc971::Constraint>>> |
| 623 | constraints_offset = |
| 624 | builder->fbb()->CreateVector<flatbuffers::Offset<frc971::Constraint>>( |
| 625 | {longitudinal_constraint_offset, lateral_constraint_offset, |
| 626 | voltage_constraint_offset, velocity_constraint_offset}); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 627 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 628 | flatbuffers::Offset<flatbuffers::Vector<float>> spline_x_offset = |
| 629 | builder->fbb()->CreateVector<float>({6.53, 7.8, 7.8, 4.0, 2.0, 0.4}); |
| 630 | flatbuffers::Offset<flatbuffers::Vector<float>> spline_y_offset = |
| 631 | builder->fbb()->CreateVector<float>({3.47, 3.0, 1.5, 3.0, 3.4, 3.4}); |
| 632 | |
| 633 | frc971::MultiSpline::Builder multispline_builder = |
| 634 | builder->MakeBuilder<frc971::MultiSpline>(); |
| 635 | |
| 636 | multispline_builder.add_spline_count(1); |
| 637 | multispline_builder.add_constraints(constraints_offset); |
| 638 | multispline_builder.add_spline_x(spline_x_offset); |
| 639 | multispline_builder.add_spline_y(spline_y_offset); |
| 640 | |
| 641 | return multispline_builder.Finish(); |
James Kuszmaul | bc83787 | 2019-04-07 12:01:47 -0700 | [diff] [blame] | 642 | } |
| 643 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 644 | flatbuffers::Offset<frc971::MultiSpline> AutonomousSplines::HPToNearRocketTest( |
| 645 | aos::Sender<frc971::control_loops::drivetrain::Goal>::Builder *builder) { |
| 646 | flatbuffers::Offset<frc971::Constraint> longitudinal_constraint_offset; |
| 647 | flatbuffers::Offset<frc971::Constraint> lateral_constraint_offset; |
| 648 | flatbuffers::Offset<frc971::Constraint> voltage_constraint_offset; |
| 649 | flatbuffers::Offset<frc971::Constraint> velocity_constraint_offset; |
Austin Schuh | 6bcc230 | 2019-03-23 22:28:06 -0700 | [diff] [blame] | 650 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 651 | { |
| 652 | frc971::Constraint::Builder longitudinal_constraint_builder = |
| 653 | builder->MakeBuilder<frc971::Constraint>(); |
| 654 | longitudinal_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 655 | frc971::ConstraintType::LONGITUDINAL_ACCELERATION); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 656 | longitudinal_constraint_builder.add_value(1.0); |
| 657 | longitudinal_constraint_offset = longitudinal_constraint_builder.Finish(); |
| 658 | } |
Austin Schuh | 6bcc230 | 2019-03-23 22:28:06 -0700 | [diff] [blame] | 659 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 660 | { |
| 661 | frc971::Constraint::Builder lateral_constraint_builder = |
| 662 | builder->MakeBuilder<frc971::Constraint>(); |
| 663 | lateral_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 664 | frc971::ConstraintType::LATERAL_ACCELERATION); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 665 | lateral_constraint_builder.add_value(1.0); |
| 666 | lateral_constraint_offset = lateral_constraint_builder.Finish(); |
| 667 | } |
Austin Schuh | 6bcc230 | 2019-03-23 22:28:06 -0700 | [diff] [blame] | 668 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 669 | { |
| 670 | frc971::Constraint::Builder voltage_constraint_builder = |
| 671 | builder->MakeBuilder<frc971::Constraint>(); |
| 672 | voltage_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 673 | frc971::ConstraintType::VOLTAGE); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 674 | voltage_constraint_builder.add_value(11.0); |
| 675 | voltage_constraint_offset = voltage_constraint_builder.Finish(); |
| 676 | } |
James Kuszmaul | bc83787 | 2019-04-07 12:01:47 -0700 | [diff] [blame] | 677 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 678 | { |
| 679 | frc971::Constraint::Builder velocity_constraint_builder = |
| 680 | builder->MakeBuilder<frc971::Constraint>(); |
| 681 | velocity_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 682 | frc971::ConstraintType::VELOCITY); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 683 | velocity_constraint_builder.add_value(0.5); |
| 684 | velocity_constraint_builder.add_start_distance(2.7); |
| 685 | velocity_constraint_builder.add_end_distance(10.0); |
| 686 | velocity_constraint_offset = velocity_constraint_builder.Finish(); |
| 687 | } |
Austin Schuh | 6bcc230 | 2019-03-23 22:28:06 -0700 | [diff] [blame] | 688 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 689 | flatbuffers::Offset< |
| 690 | flatbuffers::Vector<flatbuffers::Offset<frc971::Constraint>>> |
| 691 | constraints_offset = |
| 692 | builder->fbb()->CreateVector<flatbuffers::Offset<frc971::Constraint>>( |
| 693 | {longitudinal_constraint_offset, lateral_constraint_offset, |
| 694 | voltage_constraint_offset, velocity_constraint_offset}); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 695 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 696 | flatbuffers::Offset<flatbuffers::Vector<float>> spline_x_offset = |
| 697 | builder->fbb()->CreateVector<float>({1.5, 2.0, 3.0, 4.0, 4.5, 5.12}); |
| 698 | flatbuffers::Offset<flatbuffers::Vector<float>> spline_y_offset = |
| 699 | builder->fbb()->CreateVector<float>({3.4, 3.4, 3.4, 3.0, 3.0, 3.43}); |
| 700 | |
| 701 | frc971::MultiSpline::Builder multispline_builder = |
| 702 | builder->MakeBuilder<frc971::MultiSpline>(); |
| 703 | |
| 704 | multispline_builder.add_spline_count(1); |
| 705 | multispline_builder.add_constraints(constraints_offset); |
| 706 | multispline_builder.add_spline_x(spline_x_offset); |
| 707 | multispline_builder.add_spline_y(spline_y_offset); |
| 708 | |
| 709 | return multispline_builder.Finish(); |
Austin Schuh | 6bcc230 | 2019-03-23 22:28:06 -0700 | [diff] [blame] | 710 | } |
| 711 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 712 | flatbuffers::Offset<frc971::MultiSpline> AutonomousSplines::BasicSSpline( |
| 713 | aos::Sender<frc971::control_loops::drivetrain::Goal>::Builder *builder) { |
| 714 | flatbuffers::Offset<frc971::Constraint> longitudinal_constraint_offset; |
| 715 | flatbuffers::Offset<frc971::Constraint> lateral_constraint_offset; |
| 716 | flatbuffers::Offset<frc971::Constraint> voltage_constraint_offset; |
Austin Schuh | 6bcc230 | 2019-03-23 22:28:06 -0700 | [diff] [blame] | 717 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 718 | { |
| 719 | frc971::Constraint::Builder longitudinal_constraint_builder = |
| 720 | builder->MakeBuilder<frc971::Constraint>(); |
| 721 | longitudinal_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 722 | frc971::ConstraintType::LONGITUDINAL_ACCELERATION); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 723 | longitudinal_constraint_builder.add_value(1.0); |
| 724 | longitudinal_constraint_offset = longitudinal_constraint_builder.Finish(); |
| 725 | } |
Austin Schuh | 6bcc230 | 2019-03-23 22:28:06 -0700 | [diff] [blame] | 726 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 727 | { |
| 728 | frc971::Constraint::Builder lateral_constraint_builder = |
| 729 | builder->MakeBuilder<frc971::Constraint>(); |
| 730 | lateral_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 731 | frc971::ConstraintType::LATERAL_ACCELERATION); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 732 | lateral_constraint_builder.add_value(1.0); |
| 733 | lateral_constraint_offset = lateral_constraint_builder.Finish(); |
| 734 | } |
Austin Schuh | 6bcc230 | 2019-03-23 22:28:06 -0700 | [diff] [blame] | 735 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 736 | { |
| 737 | frc971::Constraint::Builder voltage_constraint_builder = |
| 738 | builder->MakeBuilder<frc971::Constraint>(); |
| 739 | voltage_constraint_builder.add_constraint_type( |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 740 | frc971::ConstraintType::VOLTAGE); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 741 | voltage_constraint_builder.add_value(6.0); |
| 742 | voltage_constraint_offset = voltage_constraint_builder.Finish(); |
| 743 | } |
Austin Schuh | 6bcc230 | 2019-03-23 22:28:06 -0700 | [diff] [blame] | 744 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 745 | flatbuffers::Offset< |
| 746 | flatbuffers::Vector<flatbuffers::Offset<frc971::Constraint>>> |
| 747 | constraints_offset = |
| 748 | builder->fbb()->CreateVector<flatbuffers::Offset<frc971::Constraint>>( |
| 749 | {longitudinal_constraint_offset, lateral_constraint_offset, |
| 750 | voltage_constraint_offset}); |
| 751 | |
Austin Schuh | 6bcc230 | 2019-03-23 22:28:06 -0700 | [diff] [blame] | 752 | const float startx = 0.4; |
| 753 | const float starty = 3.4; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 754 | flatbuffers::Offset<flatbuffers::Vector<float>> spline_x_offset = |
| 755 | builder->fbb()->CreateVector<float>({0.0f + startx, 0.6f + startx, |
| 756 | 0.6f + startx, 0.4f + startx, |
| 757 | 0.4f + startx, 1.0f + startx}); |
| 758 | flatbuffers::Offset<flatbuffers::Vector<float>> spline_y_offset = |
| 759 | builder->fbb()->CreateVector<float>({starty - 0.0f, starty - 0.0f, |
| 760 | starty - 0.3f, starty - 0.7f, |
| 761 | starty - 1.0f, starty - 1.0f}); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 762 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 763 | frc971::MultiSpline::Builder multispline_builder = |
| 764 | builder->MakeBuilder<frc971::MultiSpline>(); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 765 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 766 | multispline_builder.add_spline_count(1); |
| 767 | multispline_builder.add_constraints(constraints_offset); |
| 768 | multispline_builder.add_spline_x(spline_x_offset); |
| 769 | multispline_builder.add_spline_y(spline_y_offset); |
| 770 | |
| 771 | return multispline_builder.Finish(); |
Austin Schuh | 6bcc230 | 2019-03-23 22:28:06 -0700 | [diff] [blame] | 772 | } |
| 773 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 774 | flatbuffers::Offset<frc971::MultiSpline> AutonomousSplines::StraightLine( |
| 775 | aos::Sender<frc971::control_loops::drivetrain::Goal>::Builder *builder) { |
| 776 | flatbuffers::Offset<flatbuffers::Vector<float>> spline_x_offset = |
| 777 | builder->fbb()->CreateVector<float>( |
| 778 | {-12.3, -11.9, -11.5, -11.1, -10.6, -10.0}); |
| 779 | flatbuffers::Offset<flatbuffers::Vector<float>> spline_y_offset = |
| 780 | builder->fbb()->CreateVector<float>({1.25, 1.25, 1.25, 1.25, 1.25, 1.25}); |
Austin Schuh | 6bcc230 | 2019-03-23 22:28:06 -0700 | [diff] [blame] | 781 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 782 | frc971::MultiSpline::Builder multispline_builder = |
| 783 | builder->MakeBuilder<frc971::MultiSpline>(); |
Austin Schuh | 6bcc230 | 2019-03-23 22:28:06 -0700 | [diff] [blame] | 784 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 785 | multispline_builder.add_spline_count(1); |
| 786 | multispline_builder.add_spline_x(spline_x_offset); |
| 787 | multispline_builder.add_spline_y(spline_y_offset); |
Austin Schuh | b5b79a5 | 2019-05-08 20:32:07 -0700 | [diff] [blame] | 788 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 789 | return multispline_builder.Finish(); |
Austin Schuh | 6bcc230 | 2019-03-23 22:28:06 -0700 | [diff] [blame] | 790 | } |
| 791 | |
| 792 | } // namespace actors |
| 793 | } // namespace y2019 |