-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
making tests run and integrating new pedals system stuff
- Loading branch information
Showing
20 changed files
with
299 additions
and
1,672 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,47 @@ | ||
#ifndef AMSINTERFACE | ||
#define AMSINTERFACE | ||
#ifndef __AMS_INTERFACE_H__ | ||
#define __AMS_INTERFACE_H__ | ||
|
||
#include "SysClock.h" | ||
|
||
const unsigned long HEARTBEAT_INTERVAL = 20; // milliseconds | ||
const unsigned long PACK_CHARGE_CRIT_TOTAL_THRESHOLD = 420; | ||
const unsigned long PACK_CHARGE_CRIT_LOWEST_CELL_THRESHOLD = 35000; | ||
|
||
const float DEFAULT_INIT_TEMP = 40.0; | ||
const float DEFAULT_INIT_VOLTAGE = 3.5; | ||
const float DEFAULT_TEMP_ALPHA = 0.8; | ||
const float DEFAULT_VOLTAGE_ALPHA = 0.8; | ||
|
||
class AMSInterface | ||
{ | ||
public: | ||
bool ok_high_; | ||
bool heartbeat_status_; | ||
AMSInterface() {} | ||
bool ok_high() { return ok_high_; }; | ||
bool heartbeat_check(unsigned long curr_time) { return heartbeat_status_; }; | ||
AMSInterface(int sw_ok_pin, float init_temp, float init_volt, float temp_alpha, float volt_alpha){ | ||
// Set pin mode | ||
}; | ||
/* Initialize interface pin mode */ | ||
void init(const SysTick_s &tick); | ||
|
||
/* Write to Main ECU */ | ||
// Initialize output value | ||
void set_start_state(); | ||
// Set output value | ||
void set_state_ok_high(bool ok_high); | ||
|
||
/* Monitor AMS state */ | ||
void set_heartbeat(const SysTick_s &tick); | ||
bool heartbeat_received(const SysTick_s &tick); | ||
bool is_below_pack_charge_critical_low_thresh(); | ||
bool is_below_pack_charge_critical_total_thresh(); | ||
bool pack_charge_is_critical(); | ||
|
||
/* IIR filtered AMS readings */ | ||
float get_filtered_max_cell_temp(); | ||
float get_filtered_min_cell_voltage(); | ||
|
||
/* Retrieve CAN */ | ||
private: | ||
/* AMS CAN messages */ | ||
// Outbound | ||
}; | ||
|
||
#endif /* AMSINTERFACE */ | ||
#endif /* __AMS_INTERFACE_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#ifndef __ANALOGSENSOR_H__ | ||
#define __ANALOGSENSOR_H__ | ||
|
||
#include <tuple> | ||
#include <algorithm> | ||
|
||
enum class AnalogSensorStatus_e | ||
{ | ||
ANALOG_SENSOR_GOOD = 0, | ||
ANALOG_SENSOR_CLAMPED = 1, | ||
}; | ||
|
||
struct AnalogConversion_s | ||
{ | ||
int raw; | ||
float conversion; | ||
AnalogSensorStatus_e status; | ||
}; | ||
|
||
template <int N> | ||
struct AnalogConversionPacket_s | ||
{ | ||
AnalogConversion_s conversions[N]; | ||
}; | ||
|
||
class AnalogChannel | ||
{ | ||
public: | ||
// Data | ||
AnalogChannel(); | ||
// Functions | ||
/// @brief Calculate sensor output and whether result is in sensor's defined bounds. DOES NOT SAMPLE. | ||
/// @return Sensor's calculated output in real units, whether the result was clamped (AnalogSensorStatus_s) | ||
AnalogConversion_s convert(); | ||
}; | ||
|
||
template <int N> | ||
class AnalogMultiSensor | ||
{ | ||
public: | ||
AnalogConversionPacket_s<N> data; | ||
// Functions | ||
|
||
/// @brief Used by systems to get data out of this device when it's self-actualizing sampling & conversion. | ||
/// @return Const ref to last data conversion. | ||
const AnalogConversionPacket_s<N>& get() | ||
{ | ||
return data; | ||
} | ||
|
||
/// @brief Performs unit conversions on all channels | ||
void convert() | ||
{ | ||
// for (int i = 0; i < N; i++) | ||
// { | ||
// data.conversions[i] = channels_[i].convert(); | ||
// } | ||
} | ||
|
||
/// @brief Commands the underlying device to sample all channels and internally store the results | ||
void sample(); | ||
}; | ||
|
||
#endif /* __ANALOGSENSOR_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,48 @@ | ||
#ifndef DASHBOARDINTERFACE | ||
#define DASHBOARDINTERFACE | ||
/* Enum for the modes on the dial, corresponds directly to dial index pos. */ | ||
enum DialMode_e | ||
{ | ||
MODE_1, | ||
MODE_2, | ||
ACCEL_LAUNCH_CONTROL, | ||
SKIDPAD, | ||
AUTOCROSS, | ||
ENDURANCE, | ||
}; | ||
|
||
/* Enum for defined LED colors. ON will be LED's default color on dashboard*/ | ||
enum LEDColors_e | ||
{ | ||
OFF, | ||
ON, | ||
YELLOW, | ||
RED, | ||
}; | ||
|
||
/* Enum to index the LED array. Each LED in the CAN message is represented in no particular order. */ | ||
enum DashLED_e | ||
{ | ||
BOTS_LED, | ||
LAUNCH_CONTROL_LED, | ||
MODE_LED, | ||
MECH_BRAKE_LED, | ||
COCKPIT_BRB_LED, | ||
INERTIA_LED, | ||
GLV_LED, | ||
CRIT_CHARGE_LED, | ||
START_LED, | ||
MC_ERROR_LED, | ||
IMD_LED, | ||
AMS_LED, | ||
}; | ||
|
||
class DashboardInterface | ||
{ | ||
private: | ||
public: | ||
bool start_button_status_; | ||
bool start_button_pressed() { return start_button_status_; }; | ||
bool startButtonPressed() { return start_button_status_; }; | ||
}; | ||
|
||
#endif /* DASHBOARDINTERFACE */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#ifndef __UPPERSTEERINGSENSOR_H__ | ||
#define __UPPERSTEERINGSENSOR_H__ | ||
|
||
#include <tuple> | ||
|
||
enum class SteeringEncoderStatus_e | ||
{ | ||
STEERING_ENCODER_NOMINAL = 0, | ||
STEERING_ENCODER_MARGINAL = 1, | ||
STEERING_ENCODER_ERROR = 2, | ||
}; | ||
|
||
struct SteeringEncoderConversion_s | ||
{ | ||
float angle; | ||
SteeringEncoderStatus_e status; | ||
}; | ||
|
||
class SteeringEncoderInterface | ||
{ | ||
public: | ||
// Functions | ||
/// @brief Commands the underlying steering sensor to sample and hold the result | ||
virtual void sample(); | ||
/// @brief Calculate steering angle and whether result is in sensor's defined bounds. DOES NOT SAMPLE. | ||
/// @return Calculated steering angle in degrees, upperSteeringStatus_s | ||
virtual SteeringEncoderConversion_s convert(); | ||
/// @brief Set the upper steering sensor's offset. 0 degrees should be centered. | ||
/// @param newOffset | ||
virtual void setOffset(float newOffset); | ||
}; | ||
|
||
#endif /* __UPPERSTEERINGSENSOR_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#ifndef __WATCHDOG_INTERFACE_H__ | ||
#define __WATCHDOG_INTERFACE_H__ | ||
|
||
#include "SysClock.h" | ||
const unsigned long WATCHDOG_KICK_INTERVAL = 7; // milliseconds | ||
|
||
class WatchdogInterface | ||
{ | ||
private: | ||
/* Watchdog last kicked time */ | ||
unsigned long watchdog_time; | ||
|
||
/* Watchdog output state */ | ||
bool watchdog_state; | ||
|
||
/* Hardware interface pins */ | ||
int pin_watchdog_input_; | ||
|
||
public: | ||
WatchdogInterface(int wd_input_pin){}; | ||
|
||
/* Initialize interface pin mode */ | ||
void init(const SysTick_s &tick); | ||
|
||
/* Write to Main ECU */ | ||
// Initialize output value | ||
void set_start_state(); | ||
|
||
/* Kick watchdog */ | ||
void kick_watchdog(const SysTick_s &tick); | ||
|
||
}; | ||
|
||
#endif /* __WATCHDOG_INTERFACE_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.