32 lines
593 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);
Motormixer() = default;
private:
Scaling m_inputScale = {0.3f, 1.0f};
float m_outputScale = 100.0f;
float m_deadzone = 0.1;
};