34 lines
672 B
C++
34 lines
672 B
C++
#pragma once
|
|
|
|
class Motormixer
|
|
{
|
|
public:
|
|
struct Output
|
|
{
|
|
float leftMotor;
|
|
float rightMotor;
|
|
};
|
|
|
|
struct Scaling
|
|
{
|
|
float throttle;
|
|
float steering;
|
|
};
|
|
|
|
//! @param throttle in [-1, 1]
|
|
//! @param steering in [-1, 1]
|
|
Output calculate(float throttle, float steering);
|
|
|
|
void setInputScale(Scaling scale);
|
|
void setOutputScale(float scale);
|
|
void setDeadzone(float deadzone);
|
|
void setTrimSteering(float trimSteering);
|
|
|
|
Motormixer() = default;
|
|
|
|
private:
|
|
Scaling m_inputScale = {0.3f, 1.0f};
|
|
float m_outputScale = 100.0f;
|
|
float m_deadzone = 0.1;
|
|
float m_trimSteering = 0.0f;
|
|
}; |