2023-Robot
Robot code for 2023 FRC season by Argos, FRC team #1756
Loading...
Searching...
No Matches
swerve_trapezoidal_profile.h
Go to the documentation of this file.
1
4
5#pragma once
6
7#include <frc/geometry/Pose2d.h>
8#include <frc/trajectory/Trajectory.h>
9#include <frc/trajectory/TrapezoidProfile.h>
10#include <units/angle.h>
11#include <units/angular_velocity.h>
12#include <units/length.h>
13#include <units/time.h>
14#include <units/velocity.h>
15
16enum class SegmentType { start, middle, end };
17
19 public:
21 SwerveTrapezoidalProfileSegment(const frc::Pose2d initialPosition,
22 const units::degree_t initialAngle,
23 const frc::Translation2d relativeTranslation,
24 const units::degree_t relativeRotation,
25 const frc::TrapezoidProfile<units::inches>::Constraints linearConstraints,
26 const units::feet_per_second_t initialVelocity = 0_fps,
27 const units::feet_per_second_t finalVelocity = 0_fps);
28 SwerveTrapezoidalProfileSegment(const frc::Pose2d initialPosition,
29 const units::degree_t initialAngle,
30 const frc::Pose2d finalPosition,
31 const units::degree_t finalAngle,
32 const frc::TrapezoidProfile<units::inches>::Constraints linearConstraints,
33 const units::feet_per_second_t initialVelocity = 0_fps,
34 const units::feet_per_second_t finalVelocity = 0_fps);
37
40
41 frc::Trajectory::State Calculate(units::second_t time) const;
42 bool IsFinished(units::second_t time) const;
43 units::degree_t GetEndAngle() const;
44 units::degree_t GetOdometryOffset() const;
45
46 units::feet_per_second_t GetXVelocity(const frc::Trajectory::State& state) const;
47 units::feet_per_second_t GetYVelocity(const frc::Trajectory::State& state) const;
48
49 private:
50 frc::Pose2d m_initialPosition;
51 units::degree_t m_initialAngle;
52 const frc::Translation2d m_relativeTranslation;
53 units::degree_t m_relativeRotation;
54 const frc::TrapezoidProfile<units::inches> m_linearProfile;
55 const units::degree_t m_motionAngle;
56
57 units::degree_t m_odometryOffsetAngle;
58};
59
Definition swerve_trapezoidal_profile.h:60
Definition swerve_trapezoidal_profile.h:18
bool IsFinished(units::second_t time) const
Definition swerve_trapezoidal_profile.cpp:89
frc::Trajectory::State Calculate(units::second_t time) const
Definition swerve_trapezoidal_profile.cpp:72
frc::Pose2d m_initialPosition
Definition swerve_trapezoidal_profile.h:50
const frc::Translation2d m_relativeTranslation
Definition swerve_trapezoidal_profile.h:52
units::degree_t GetEndAngle() const
Definition swerve_trapezoidal_profile.cpp:93
const units::degree_t m_motionAngle
Definition swerve_trapezoidal_profile.h:55
SwerveTrapezoidalProfileSegment & operator=(const SwerveTrapezoidalProfileSegment &)=delete
SwerveTrapezoidalProfileSegment(const SwerveTrapezoidalProfileSegment &other)=default
units::feet_per_second_t GetXVelocity(const frc::Trajectory::State &state) const
Definition swerve_trapezoidal_profile.cpp:101
SwerveTrapezoidalProfileSegment(SwerveTrapezoidalProfileSegment &&other)=default
units::degree_t m_initialAngle
Definition swerve_trapezoidal_profile.h:51
units::degree_t m_relativeRotation
Definition swerve_trapezoidal_profile.h:53
units::degree_t m_odometryOffsetAngle
Definition swerve_trapezoidal_profile.h:57
units::degree_t GetOdometryOffset() const
Definition swerve_trapezoidal_profile.cpp:97
units::feet_per_second_t GetYVelocity(const frc::Trajectory::State &state) const
Definition swerve_trapezoidal_profile.cpp:105
const frc::TrapezoidProfile< units::inches > m_linearProfile
Definition swerve_trapezoidal_profile.h:54
SwerveTrapezoidalProfileSegment & operator=(SwerveTrapezoidalProfileSegment &&)=delete
SwerveTrapezoidalProfileSegment()
Definition swerve_trapezoidal_profile.cpp:11
SegmentType
Definition swerve_trapezoidal_profile.h:16