27 lines
910 B
C++
27 lines
910 B
C++
#pragma once
|
|
|
|
#include "FluidSim/Engine.hpp"
|
|
#include "FluidSim/Vehicle.hpp"
|
|
#include <algorithm>
|
|
|
|
namespace fluidsim::port {
|
|
// Shared longitudinal load and clutch integration for motorcycle/car presets.
|
|
class MotorcycleTest {
|
|
public:
|
|
Vehicle vehicle{};
|
|
float load{}, clutch{1.0f};
|
|
float starter_torque{18.f}; // N m at the crankshaft while held
|
|
bool starter_engaged{};
|
|
void set_starter(bool engaged) { starter_engaged=engaged; }
|
|
|
|
protected:
|
|
void step_motorcycle(Crankshaft& crank, float dt, float maximum_load_torque) {
|
|
crank.load_torque = std::clamp(load, 0.0f, 1.0f) * maximum_load_torque;
|
|
vehicle.clutch_input = std::clamp(clutch, 0.0f, 1.0f);
|
|
if(starter_engaged) crank.add_torque(std::max(starter_torque,0.f));
|
|
crank.step(dt);
|
|
crank.drivetrain_torque = vehicle.update(crank.omega, crank.inertia, dt);
|
|
}
|
|
};
|
|
} // namespace fluidsim::port
|