2020-03-23 17:44:34 -07:00
|
|
|
/*
|
|
|
|
* @file launch_control.h
|
|
|
|
*
|
|
|
|
* @date Mar 23, 2020
|
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-12-16 11:47:00 -08:00
|
|
|
#include "launch_control_state_generated.h"
|
2020-03-23 17:44:34 -07:00
|
|
|
|
2021-11-16 01:15:29 -08:00
|
|
|
void initLaunchControl();
|
2021-11-15 11:40:35 -08:00
|
|
|
|
2024-03-09 05:39:58 -08:00
|
|
|
enum class LaunchCondition {
|
2024-05-21 00:06:17 -07:00
|
|
|
PreLaunch,
|
2024-03-09 05:39:58 -08:00
|
|
|
Launch,
|
|
|
|
NotMet
|
|
|
|
};
|
|
|
|
|
2021-12-16 11:47:00 -08:00
|
|
|
class LaunchControlBase : public launch_control_state_s {
|
2020-11-19 05:15:56 -08:00
|
|
|
public:
|
2021-12-16 11:47:00 -08:00
|
|
|
LaunchControlBase();
|
2020-11-19 05:15:56 -08:00
|
|
|
// Update the state of the launch control system
|
|
|
|
void update();
|
|
|
|
|
2024-02-29 19:33:37 -08:00
|
|
|
float getFuelCoefficient() const;
|
2020-11-19 05:15:56 -08:00
|
|
|
bool isInsideSpeedCondition() const;
|
|
|
|
bool isInsideTpsCondition() const;
|
2021-11-15 17:09:03 -08:00
|
|
|
bool isInsideSwitchCondition();
|
2024-09-25 00:20:18 -07:00
|
|
|
LaunchCondition calculateRPMLaunchCondition(float rpm);
|
|
|
|
LaunchCondition calculateLaunchCondition(float rpm);
|
2021-11-15 16:54:34 -08:00
|
|
|
|
|
|
|
bool isLaunchSparkRpmRetardCondition() const;
|
|
|
|
bool isLaunchFuelRpmRetardCondition() const;
|
|
|
|
|
2024-06-07 04:55:15 -07:00
|
|
|
float getSparkSkipRatio() const { return sparkSkipRatio; }
|
|
|
|
|
2020-11-19 05:15:56 -08:00
|
|
|
private:
|
2021-11-15 16:54:34 -08:00
|
|
|
bool isLaunchRpmRetardCondition() const;
|
|
|
|
|
2024-09-25 21:34:00 -07:00
|
|
|
float calculateSparkSkipRatio(float rpm) const;
|
2024-06-07 04:55:15 -07:00
|
|
|
|
|
|
|
|
|
|
|
float sparkSkipRatio = 0.0f;
|
2020-11-19 05:15:56 -08:00
|
|
|
};
|
2021-11-16 10:15:12 -08:00
|
|
|
|
2021-11-17 20:34:49 -08:00
|
|
|
/**
|
|
|
|
* See also SoftLimiterSandbox.java
|
|
|
|
*/
|
2021-11-16 10:15:12 -08:00
|
|
|
class SoftSparkLimiter {
|
|
|
|
public:
|
2024-06-06 06:33:23 -07:00
|
|
|
SoftSparkLimiter(bool p_allowHardCut);
|
2021-11-16 10:15:12 -08:00
|
|
|
/**
|
|
|
|
* targetSkipRatio of '0' means 'do not skip', would always return false
|
|
|
|
*/
|
2024-06-07 04:55:15 -07:00
|
|
|
void updateTargetSkipRatio(
|
|
|
|
float luaSoftSparkSkip,
|
|
|
|
float tractionControlSparkSkip,
|
2024-10-04 15:19:48 -07:00
|
|
|
float launchOrShiftTorqueReductionControllerSparkSkipRatio = 0.0f
|
2024-06-07 04:55:15 -07:00
|
|
|
);
|
2024-05-17 09:30:22 -07:00
|
|
|
[[nodiscard]] float getTargetSkipRatio() const { return targetSkipRatio; }
|
2021-11-16 10:15:12 -08:00
|
|
|
|
|
|
|
bool shouldSkip();
|
|
|
|
private:
|
2024-06-06 06:33:23 -07:00
|
|
|
const bool allowHardCut;
|
2021-11-16 10:15:12 -08:00
|
|
|
bool wasJustSkipped = false;
|
|
|
|
float targetSkipRatio = 0;
|
|
|
|
};
|