LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
slew.hpp
Go to the documentation of this file.
1/*
2This Source Code Form is subject to the terms of the Mozilla Public
3License, v. 2.0. If a copy of the MPL was not distributed with this
4file, You can obtain one at http://mozilla.org/MPL/2.0/.
5*/
6
7#pragma once
8
9#include "LightLib/api.h"
11
21namespace light {
29class slew {
30 public:
33
37 struct Constants {
38 double min_speed = 0;
39 double distance_to_travel = 0;
40 };
42
51 slew(double distance, int minimum_speed);
52
61 void constants_set(double distance, int minimum_speed);
62
65
78 void initialize(bool enabled, double maximum_speed, double target, double current);
79
86 double iterate(double current);
87
91 bool enabled();
92
96 double output();
97
104 void speed_max_set(double speed);
105
110
111 private:
112 int sign = 0;
113 double error = 0;
114 double x_intercept = 0;
115 double y_intercept = 0;
116 double slope = 0;
117 double last_output = 0;
118 bool is_enabled = false;
119 double max_speed = 0;
120};
121}; // namespace light
PROS API header provides high-level user functionality.
Slew-rate limiter that ramps speed up linearly over a configurable distance.
Definition slew.hpp:29
slew(double distance, int minimum_speed)
Sets constants for slew.
Constants constants_get()
slew()
Default constructor.
double speed_max_get()
Returns the max speed the slew can be.
double output()
Returns the last output of iterate.
void constants_set(double distance, int minimum_speed)
Sets constants for slew.
Constants constants
Active slew constants (read/write).
Definition slew.hpp:41
double iterate(double current)
Iterates slew and ramps up speed the farther along the motion the robot gets.
void speed_max_set(double speed)
Sets the max speed the slew can be.
void initialize(bool enabled, double maximum_speed, double target, double current)
Initializes slew for the motion.
bool enabled()
Returns true if slew is enabled, and false if it isn't.
Public LightLib odometry / pose-estimation API.
Definition pid.hpp:22
Slew configuration constants.
Definition slew.hpp:37
double min_speed
Starting speed at the beginning of a motion.
Definition slew.hpp:38
double distance_to_travel
Distance over which speed ramps to max.
Definition slew.hpp:39
Shared types, enums, math helpers, and unit conversions used across LightLib.