forked from bobsayshilol/engine-sim
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstarter_motor.cpp
More file actions
39 lines (29 loc) · 890 Bytes
/
starter_motor.cpp
File metadata and controls
39 lines (29 loc) · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "../include/starter_motor.h"
#include "../include/units.h"
StarterMotor::StarterMotor() : atg_scs::Constraint(1, 1) {
m_ks = 10.0;
m_kd = 1.0;
m_maxTorque = units::torque(80.0, units::ft_lb);
m_rotationSpeed = -units::rpm(200.0);
m_enabled = false;
}
StarterMotor::~StarterMotor() {
/* void */
}
void StarterMotor::connectCrankshaft(Crankshaft *crankshaft) {
m_bodies[0] = &crankshaft->m_body;
}
void StarterMotor::calculate(Output *output, atg_scs::SystemState *state) {
output->J[0][0] = 0;
output->J[0][1] = 0;
output->J[0][2] = 1;
output->J_dot[0][0] = 0;
output->J_dot[0][1] = 0;
output->J_dot[0][2] = 0;
output->ks[0] = m_ks;
output->kd[0] = m_kd;
output->C[0] = 0;
output->v_bias[0] = -m_rotationSpeed;
output->limits[0][0] = m_enabled ? -m_maxTorque : 0.0;
output->limits[0][1] = 0.0;
}