blob: 2dd99b732be7aa88813dad703a4c7eb457e15a0c [file] [log] [blame]
Stephan Massaltd021f972020-01-05 20:41:23 -08001#ifndef y2020_ACTORS_AUTO_SPLINES_H_
2#define y2020_ACTORS_AUTO_SPLINES_H_
3
4#include "aos/events/event_loop.h"
Ravago Jonesc2a08022021-02-06 17:40:54 -08005#include "aos/flatbuffer_merge.h"
Stephan Massaltd021f972020-01-05 20:41:23 -08006#include "frc971/control_loops/control_loops_generated.h"
7#include "frc971/control_loops/drivetrain/drivetrain_goal_generated.h"
James Kuszmaul7077d342021-06-09 20:23:58 -07008#include "frc971/input/joystick_state_generated.h"
Stephan Massaltd021f972020-01-05 20:41:23 -08009/*
10
11 The cooridinate system for the autonomous splines is the same as the spline
12 python generator and drivetrain spline systems.
13
14*/
15
16namespace y2020 {
17namespace actors {
18
19class AutonomousSplines {
20 public:
Ravago Jonesc2a08022021-02-06 17:40:54 -080021 AutonomousSplines()
22 : test_spline_(aos::JsonFileToFlatbuffer<frc971::MultiSpline>(
kyle96c406e2021-02-27 14:07:22 -080023 "splines/test_spline.json")),
Ravago Jonesa7b3c822021-08-26 12:36:03 -070024 target_aligned_1_(aos::JsonFileToFlatbuffer<frc971::MultiSpline>(
25 "splines/target_aligned_1.json")),
26 target_aligned_2_(aos::JsonFileToFlatbuffer<frc971::MultiSpline>(
27 "splines/target_aligned_2.json")),
milind-u0e203782021-10-30 21:57:20 -070028 target_aligned_3_(aos::JsonFileToFlatbuffer<frc971::MultiSpline>(
29 "splines/target_aligned_3.json")),
Ravago Jonesa7b3c822021-08-26 12:36:03 -070030 target_offset_1_(aos::JsonFileToFlatbuffer<frc971::MultiSpline>(
31 "splines/target_offset_1.json")),
32 target_offset_2_(aos::JsonFileToFlatbuffer<frc971::MultiSpline>(
33 "splines/target_offset_2.json")) {}
Ravago Jonesc2a08022021-02-06 17:40:54 -080034
Stephan Massaltd021f972020-01-05 20:41:23 -080035 static flatbuffers::Offset<frc971::MultiSpline> BasicSSpline(
James Kuszmaul75a18c52021-03-10 22:02:07 -080036 aos::Sender<frc971::control_loops::drivetrain::SplineGoal>::Builder
37 *builder,
James Kuszmaulddd2ba62020-03-08 22:17:13 -070038 aos::Alliance alliance);
Stephan Massaltd021f972020-01-05 20:41:23 -080039 static flatbuffers::Offset<frc971::MultiSpline> StraightLine(
James Kuszmaul75a18c52021-03-10 22:02:07 -080040 aos::Sender<frc971::control_loops::drivetrain::SplineGoal>::Builder
41 *builder);
Ravago Jonesc2a08022021-02-06 17:40:54 -080042
43 flatbuffers::Offset<frc971::MultiSpline> TestSpline(
James Kuszmaul75a18c52021-03-10 22:02:07 -080044 aos::Sender<frc971::control_loops::drivetrain::SplineGoal>::Builder
45 *builder) {
Ravago Jonesc2a08022021-02-06 17:40:54 -080046 return aos::CopyFlatBuffer<frc971::MultiSpline>(test_spline_,
47 builder->fbb());
48 }
49
Ravago Jonesa7b3c822021-08-26 12:36:03 -070050 flatbuffers::Offset<frc971::MultiSpline> TargetAligned1(
51 aos::Sender<frc971::control_loops::drivetrain::SplineGoal>::Builder
Austin Schuhd0e9e062021-10-24 17:40:58 -070052 *builder,
53 aos::Alliance alliance);
Ravago Jonesa7b3c822021-08-26 12:36:03 -070054 flatbuffers::Offset<frc971::MultiSpline> TargetAligned2(
55 aos::Sender<frc971::control_loops::drivetrain::SplineGoal>::Builder
Austin Schuhd0e9e062021-10-24 17:40:58 -070056 *builder,
57 aos::Alliance alliance);
milind-u0e203782021-10-30 21:57:20 -070058 flatbuffers::Offset<frc971::MultiSpline> TargetAligned3(
59 aos::Sender<frc971::control_loops::drivetrain::SplineGoal>::Builder
60 *builder,
61 aos::Alliance alliance);
Ravago Jonesa7b3c822021-08-26 12:36:03 -070062 flatbuffers::Offset<frc971::MultiSpline> TargetOffset1(
63 aos::Sender<frc971::control_loops::drivetrain::SplineGoal>::Builder
64 *builder) {
65 return aos::CopyFlatBuffer<frc971::MultiSpline>(target_offset_1_,
66 builder->fbb());
67 }
68 flatbuffers::Offset<frc971::MultiSpline> TargetOffset2(
69 aos::Sender<frc971::control_loops::drivetrain::SplineGoal>::Builder
70 *builder) {
71 return aos::CopyFlatBuffer<frc971::MultiSpline>(target_offset_2_,
72 builder->fbb());
73 }
74
Ravago Jonesc2a08022021-02-06 17:40:54 -080075 private:
76 aos::FlatbufferDetachedBuffer<frc971::MultiSpline> test_spline_;
Ravago Jonesa7b3c822021-08-26 12:36:03 -070077 aos::FlatbufferDetachedBuffer<frc971::MultiSpline> target_aligned_1_;
78 aos::FlatbufferDetachedBuffer<frc971::MultiSpline> target_aligned_2_;
milind-u0e203782021-10-30 21:57:20 -070079 aos::FlatbufferDetachedBuffer<frc971::MultiSpline> target_aligned_3_;
Ravago Jonesa7b3c822021-08-26 12:36:03 -070080 aos::FlatbufferDetachedBuffer<frc971::MultiSpline> target_offset_1_;
81 aos::FlatbufferDetachedBuffer<frc971::MultiSpline> target_offset_2_;
Stephan Massaltd021f972020-01-05 20:41:23 -080082};
83
84} // namespace actors
85} // namespace y2020
86
87#endif // y2020_ACTORS_AUTO_SPLINES_H_