Midnight Sun Firmware
Loading...
Searching...
No Matches
opd.h
1#pragma once
2
3/************************************************************************************************
4 * @file opd.h
5 *
6 * @brief Header file for one pedal drive manager
7 *
8 * @date 2025-09-14
9 * @author Midnight Sun Team #24 - MSXVI
10 ************************************************************************************************/
11
12/* Standard library Headers */
13#include <stdint.h>
14
15/* Inter-component Headers */
16#include "status.h"
17
18/* Intra-component Headers */
19#include "front_controller.h"
20
27typedef struct OpdStorage {
31
32typedef enum PtsRelationType { PTS_TYPE_LINEAR, PTS_TYPE_EXPONENTIAL, PTS_TYPE_QUADRATIC } PtsRelationType;
33
34typedef enum CurveType { CURVE_TYPE_LINEAR, CURVE_TYPE_EXPONENTIAL, CURVE_TYPE_QUADRATIC } CurveType;
35
39StatusCode opd_calculate_handler(float pedal_percentage, PtsRelationType relation_type, float *calculated_reading, CurveType curve_type);
40
44StatusCode opd_linear_calculate(float pedal_percentage, PtsRelationType relation_type, float *calculated_reading);
45
49StatusCode opd_quadratic_calculate(float pedal_percentage, PtsRelationType relation_type, float *calculated_reading);
50
57
65
StatusCode opd_run()
Reads the pedal percentage from AccelPedalStorage and saves an adjusted acceleration percentage to fr...
Definition: opd.c:136
StatusCode opd_linear_calculate(float pedal_percentage, PtsRelationType relation_type, float *calculated_reading)
Perform linear OPD calculation.
Definition: opd.c:89
StatusCode opd_init(FrontControllerStorage *storage)
Initializes the opd, loads front controller storage.
Definition: opd.c:166
StatusCode opd_calculate_handler(float pedal_percentage, PtsRelationType relation_type, float *calculated_reading, CurveType curve_type)
handler for opd_calculate command, runs either linear or quadratic calculation based on CurveType enu...
Definition: opd.c:120
StatusCode opd_quadratic_calculate(float pedal_percentage, PtsRelationType relation_type, float *calculated_reading)
Perform quadratic OPD calculation.
Definition: opd.c:105
StatusCode
StatusCodes for various errors.
Definition: status.h:27
Front Controller storage.
Definition: front_controller.h:72
Definition: opd.h:27
uint32_t max_vehicle_speed_kph
Definition: opd.h:29
float max_braking_percentage
Definition: opd.h:28