23 lines
541 B
C++
23 lines
541 B
C++
#include "engine.h"
|
|
|
|
void Engine::step(double dt, double load_torque_nm) {
|
|
// TODO: replace with real combustion/friction torque model driven
|
|
// by throttle position and crank angle. For now: seek idle rpm
|
|
// and just track the applied load so downstream pieces have
|
|
// something to wire against.
|
|
m_rpm += (kIdleRpm - m_rpm) * dt;
|
|
m_torque_nm = -load_torque_nm;
|
|
}
|
|
|
|
double Engine::rpm() const {
|
|
return m_rpm;
|
|
}
|
|
|
|
double Engine::torque_nm() const {
|
|
return m_torque_nm;
|
|
}
|
|
|
|
void Engine::reset() {
|
|
m_rpm = 0;
|
|
}
|