1#ifndef TORQUECONTROLLERMUX
2#define TORQUECONTROLLERMUX
4#include <unordered_map>
59template <std::
size_t num_controllers>
62 static_assert(num_controllers > 0,
"Must create TC mux with at least 1 controller");
73 {TorqueLimit_e::TCMUX_MID_TORQUE, 15.0f},
74 {TorqueLimit_e::TCMUX_LOW_TORQUE, 10.0f}};
117 std::array<bool, num_controllers> mux_bypass_limits,
128 static_assert(num_controllers > 0,
"Must create TC mux with at least 1 controller");
148#include "TorqueControllerMux.tpp"
TorqueLimit_e
Defines modes of torque limit to be processed in torque limit map for exact values.
TorqueControllerMuxError
Defines errors for TC Mux to use to maintain system safety.
const int number_of_controllers
DrivetrainCommand_s apply_torque_limit_(const DrivetrainCommand_s &command, float max_torque)
Ensure torque is at most at the specified limit. If exceeding, then limit it in the returned Drivetra...
DrivetrainCommand_s getDrivetrainCommand(ControllerMode_e requested_controller_type, TorqueLimit_e controller_command_torque_limit, const SharedCarState_s &input_state)
function that evaluates the mux, controllers and gets the active command
std::array< Controller *, num_controllers > controller_pointers_
DrivetrainCommand_s apply_regen_limit_(const DrivetrainCommand_s &command, const DrivetrainDynamicReport_s &drivetrain_data)
begin limiting regen at noRegenLimitKPH (hardcoded in func) and completely limit regen at fullRegenLi...
DrivetrainCommand_s prev_command_
DrivetrainCommand_s apply_power_limit_(const DrivetrainCommand_s &command, const DrivetrainDynamicReport_s &drivetrain, float power_limit, float max_torque)
Apply power limit (watts) such that the mechanical power of all wheels never exceeds the preset mecha...
DrivetrainCommand_s apply_positive_speed_limit_(const DrivetrainCommand_s &command)
Clamps negative rpms to 0f.
std::array< bool, num_controllers > mux_bypass_limits_
std::unordered_map< TorqueLimit_e, float > torque_limit_map_
TorqueControllerMuxError can_switch_controller_(DrivetrainDynamicReport_s active_drivetrain_data, DrivetrainCommand_s previous_controller_command, DrivetrainCommand_s desired_controller_out)
float max_torque_pos_change_delta_
const TorqueControllerMuxStatus & get_tc_mux_status()
TorqueControllerMux(std::array< Controller *, num_controllers > controller_pointers, std::array< bool, num_controllers > mux_bypass_limits, float max_change_speed=TC_MUX_DEFAULT_PARAMS::MAX_SPEED_FOR_MODE_CHANGE, float max_torque_pos_change_delta=TC_MUX_DEFAULT_PARAMS::MAX_TORQUE_DELTA_FOR_MODE_CHANGE, float max_power_limit=TC_MUX_DEFAULT_PARAMS::MAX_POWER_LIMIT)
constructor for the TC mux
TorqueControllerMuxStatus active_status_
TorqueControllerMux()=delete
const float AMK_MAX_TORQUE
Contains a max speed for mode changes(5 m/s), a max torque delta for mode change(....
constexpr const float MAX_POWER_LIMIT
constexpr const float MAX_SPEED_FOR_MODE_CHANGE
constexpr const float MAX_TORQUE_DELTA_FOR_MODE_CHANGE
Stores setpoints for a command to the Drivetrain, containing speed and torque setpoints for each moto...
car state struct that contains state of everything about the car including
packages TC Mux indicators: errors, mode, torque limit, bypass