#ifndef FRC_REVLIB_SRC_MAIN_DRIVER_INCLUDE_REV_SIM_MAXMOTION_H_
#define FRC_REVLIB_SRC_MAIN_DRIVER_INCLUDE_REV_SIM_MAXMOTION_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
typedef enum {
TRAPEZOIDAL = 0,
SCURVE = 1,
NUM_ACCEL_MODES
} maxmotion_accel_mode_t;
typedef struct {
float kMAXMotionMaxVelocity;
float kMAXMotionMaxAccel;
float kMAXMotionMaxJerk;
float kAllowedClosedLoopError;
maxmotion_accel_mode_t kMAXMotionPositionMode;
float positionConversionFactor;
float velocityConversionFactor;
} maxmotion_constants_t;
typedef struct {
float position;
float velocity;
float acceleration;
float jerk;
} maxmotion_state_t;
typedef struct {
float velocity;
float acceleration;
} maxmotion_velocity_state_t;
typedef struct {
maxmotion_state_t state;
int time;
bool is_valid;
} maxmotion_profile_point_t;
typedef struct {
maxmotion_profile_point_t points[8];
maxmotion_constants_t motion_params;
float unwrapped_setpoint;
int current_time;
bool is_valid;
} maxmotion_profile_t;
void maxmotion_profile_generate(maxmotion_profile_t* profile,
const maxmotion_constants_t motion_params,
maxmotion_state_t start, maxmotion_state_t end);
bool maxmotion_profile_check(maxmotion_profile_t* profile,
const maxmotion_constants_t motion_params,
maxmotion_state_t current_state,
maxmotion_state_t end_state);
maxmotion_state_t maxmotion_profile_get_point(maxmotion_profile_t* profile,
int time);
#define VELOCITY_MARGIN(maxAccel) maxAccel / 20.0f
#define SECONDS_PER_MINUTE 60.0f
extern maxmotion_velocity_state_t smartervelocity_calculate_output_velocity(
maxmotion_constants_t* motion_params, float setpoint, float prev_vel,
float dt);
#ifdef __cplusplus
} #endif
#endif