Skip to content

Commit

Permalink
shared data types, casesystem, and casewrapper docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Comerm28 committed Sep 22, 2024
1 parent 8475adb commit f809063
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
6 changes: 6 additions & 0 deletions lib/shared_data/include/SharedDataTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "SysClock.h"
#include "SharedFirmwareTypes.h"

/// @brief defines modes of torque limit to be processed in torque limit map for exact values
enum class TorqueLimit_e
{
TCMUX_FULL_TORQUE = 0,
Expand Down Expand Up @@ -49,12 +50,15 @@ struct DrivetrainDynamicReport_s
float measuredTorqueCurrents[NUM_MOTORS];
float measuredMagnetizingCurrents[NUM_MOTORS];
};
/// @brief stores two arrays of size equal to the amount of motors: speed setpoints and necessary torque to reach those setpoints
struct DrivetrainCommand_s
{
float speeds_rpm[NUM_MOTORS];
float torqueSetpoints[NUM_MOTORS]; // FIXME: misnomer. This represents the magnitude of the torque the inverter can command to reach the commanded speed setpoint
};

/// @brief Packages drivebrain command with ready boolean
///@note returned by all car controllers evaluate method
struct TorqueControllerOutput_s
{
DrivetrainCommand_s command;
Expand All @@ -80,6 +84,7 @@ struct VectornavData_s
xyz_vec<float> angular_rates;
};

/// @brief Defins errors for TC Mux to use to maintain system safety
enum class TorqueControllerMuxError
{
NO_ERROR = 0,
Expand All @@ -89,6 +94,7 @@ enum class TorqueControllerMuxError
ERROR_CONTROLLER_NULL_POINTER =4
};

/// @brief packages TC Mux indicators: errors, mode, torque limit, bypass
struct TorqueControllerMuxStatus
{
TorqueControllerMuxError current_error;
Expand Down
11 changes: 9 additions & 2 deletions lib/systems/include/CASESystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,17 @@ class CASESystem

DrivetrainCommand_s get_current_drive_command() { return current_command_; }

/// @brief uses pedal data to determine the requested torque by the car
/// @param PedalsSystemData_s &pedals_data
/// @param float max_torque
/// @param float max_regen_torque
/// @param float max_rpm
/// @return float representing the calculated request
float calculate_torque_request(const PedalsSystemData_s &pedals_data, float max_torque, float max_regen_torque, float max_rpm);
/// @brief configuration function to determine what CASE is using / turn on and off different features within CASE
/// @param config the configuration struct we will be setting

/// @brief retrieves rpm setpoint based on final torque value
/// @param float final_torque
/// @return The maximum RPM from the configuration if torque is positive, otherwise 0.
float get_rpm_setpoint(float final_torque)
{
if (final_torque > 0)
Expand Down
6 changes: 5 additions & 1 deletion lib/systems/include/Controllers/CASEControllerWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ class TorqueControllerCASEWrapper : public virtual Controller
{
public:
TorqueControllerCASEWrapper() = delete;

/// @brief makes CASE system apart of Controller hierarchy for use in TC Mux
/// @param case_instance
TorqueControllerCASEWrapper(CASESystem<message_queue> *case_instance) : case_instance_(case_instance)
{
}
/// @brief packages CASE system command into Torque Controller Output
/// @param SharedCarState_s &state
/// @return TorqueControllerOutput_s
TorqueControllerOutput_s evaluate(const SharedCarState_s &state) override
{
DrivetrainCommand_s curr_cmd = case_instance_->get_current_drive_command();
Expand Down

0 comments on commit f809063

Please sign in to comment.