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 enum { STATE_DRIVING, STATE_BRAKING } OnePedalDriveState;
28
29typedef struct OpdStorage {
30 OnePedalDriveState drive_state;
34
35typedef enum { PTS_TYPE_LINEAR, PTS_TYPE_EXPONENTIAL, PTS_TYPE_QUADRATIC } PtsRelationType;
36
37typedef enum { CURVE_TYPE_LINEAR, CURVE_TYPE_EXPONENTIAL, CURVE_TYPE_QUADRATIC } CurveType;
38
42StatusCode opd_calculate_handler(float pedal_percentage, PtsRelationType relation_type, float *calculated_reading, CurveType curve_type);
43
47StatusCode opd_linear_calculate(float pedal_percentage, PtsRelationType relation_type, float *calculated_reading);
48
52StatusCode opd_quadratic_calculate(float pedal_percentage, PtsRelationType relation_type, float *calculated_reading);
53
60
68
StatusCode opd_run()
Reads the pedal percentage from AccelPedalStorage and saves an adjusted acceleration percentage to fr...
Definition: opd.c:108
StatusCode opd_linear_calculate(float pedal_percentage, PtsRelationType relation_type, float *calculated_reading)
Perform linear OPD calculation.
Definition: opd.c:57
StatusCode opd_init(FrontControllerStorage *storage)
Initializes the opd, loads front controller storage.
Definition: opd.c:127
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:92
StatusCode opd_quadratic_calculate(float pedal_percentage, PtsRelationType relation_type, float *calculated_reading)
Perform quadratic OPD calculation.
Definition: opd.c:75
StatusCode
StatusCodes for various errors.
Definition: status.h:27
Front Controller storage.
Definition: front_controller.h:66
Definition: opd.h:29
uint32_t max_vehicle_speed_kph
Definition: opd.h:32
float max_braking_percentage
Definition: opd.h:31