14 if (_sopen_s(&f,
"motion.dat", _O_RDONLY | _O_BINARY, _SH_DENYNO, _S_IREAD) != 0)
16 logger->
Log(
"Module::MCU could not load motion.dat", Logger::Level::Fatal, errno);
20 _lseek(f, SEEK_SET, 0L);
46 if (command.
delay != 0.0f)
continue;
48 if (command.
name ==
"MotionStartStop")
62 else if (command.
name ==
"MotionStart")
71 else if (command.
name ==
"MotionStop")
80 else if (command.
name ==
"MotionTest")
95 command.
name =
"MCURideHalted";
133 #pragma region Platform Responds to NormalAccelleration 134 static float counteri = 0.0f, counterj = 0.0f, counterk = 0.0f;
140 if (limitacc.x > 4.0f)
142 else if (limitacc.x < -4.0f)
144 if (limitacc.y < -4.0f)
146 else if (limitacc.y > 4.0f)
148 if (limitacc.z > 4.0f)
150 else if (limitacc.z < -4.0f)
153 float igs = limitacc.x - counteri;
154 float jgs = limitacc.y - counterj;
155 float kgs = limitacc.z - counterk;
159 counteri += igs * fElapsedTime * 0.1f;
160 counterj += jgs * fElapsedTime * 0.1f;
161 counterk += kgs * fElapsedTime * 0.1f;
173 float currentPressure = 0.0f;
174 Nullable<float> pneumaticPressure =
bus->GetComponentStateFloat(
"0E1C068F-F901-4C1A-AC12-10F53E894579");
175 if (pneumaticPressure.
is_set())
176 currentPressure = pneumaticPressure.
get();
177 float modulate = currentPressure / 50.0f - 1.0f;
178 if (modulate > 1.0f) modulate = 1.0f;
179 else if (modulate < 0.0f) modulate = 0.0f;
187 timer -= fElapsedTime;
195 command.
name =
"MotionPlatformCautionLights";
197 command.
delay = 0.0f;
206 command.
name =
"Motion Power";
208 command.
delay = 0.0f;
223 if (roll <= 0.0f && pitch <= 0.0f)
225 float newflF = 0.0f, newfrF = 0.0f, newblF = 0.0f, newbrF = 0.0f;
235 float newflM = 0.0f, newfrM = 0.0f, newblM = 0.0f, newbrM = 0.0f;
246 current.
fl = newflF * fabs(pitch) + newflM * (pitch + 1.0f);
247 current.
fr = newfrF * fabs(pitch) + newfrM * (pitch + 1.0f);
248 current.
bl = newblF * fabs(pitch) + newblM * (pitch + 1.0f);
249 current.
br = newbrF * fabs(pitch) + newbrM * (pitch + 1.0f);
251 else if (roll >= 0.0f && pitch <= 0.0f)
253 float newflF = 0.0f, newfrF = 0.0f, newblF = 0.0f, newbrF = 0.0f;
263 float newflM = 0.0f, newfrM = 0.0f, newblM = 0.0f, newbrM = 0.0f;
274 current.
fl = newflF * fabs(pitch) + newflM * (pitch + 1.0f);
275 current.
fr = newfrF * fabs(pitch) + newfrM * (pitch + 1.0f);
276 current.
bl = newblF * fabs(pitch) + newblM * (pitch + 1.0f);
277 current.
br = newbrF * fabs(pitch) + newbrM * (pitch + 1.0f);
279 else if (roll <= 0.0f && pitch >= 0.0f)
281 float newflF = 0.0f, newfrF = 0.0f, newblF = 0.0f, newbrF = 0.0f;
291 float newflM = 0.0f, newfrM = 0.0f, newblM = 0.0f, newbrM = 0.0f;
302 current.
fl = newflF * pitch + newflM * (1.0f - pitch);
303 current.
fr = newfrF * pitch + newfrM * (1.0f - pitch);
304 current.
bl = newblF * pitch + newblM * (1.0f - pitch);
305 current.
br = newbrF * pitch + newbrM * (1.0f - pitch);
307 else if (roll >= 0.0f && pitch >= 0.0f)
309 float newflF = 0.0f, newfrF = 0.0f, newblF = 0.0f, newbrF = 0.0f;
319 float newflM = 0.0f, newfrM = 0.0f, newblM = 0.0f, newbrM = 0.0f;
330 current.
fl = newflF * pitch + newflM * (1.0f - pitch);
331 current.
fr = newfrF * pitch + newfrM * (1.0f - pitch);
332 current.
bl = newblF * pitch + newblM * (1.0f - pitch);
333 current.
br = newbrF * pitch + newbrM * (1.0f - pitch);
340 float mag = max(fabsf(pitch), fabsf(roll));
343 heave *= (1.0f - mag);
380 command.
name =
"Motion Power";
382 command.
delay = 0.0f;
389 command.
name =
"MotionPlatformCautionLights";
391 command.
delay = 0.0f;
double PlatformFrontRightBellow
float * emergencyStopGetPtr
std::vector< Command > commandStream
double PlatformFrontLeftBellow
std::string name
command name
D3DXVECTOR3 NormalAcceleration
(5) vertical (11) longitudinal (18) lateral
Abstract base class for modules By definition, instruments don't do any of the work (they don't modif...
Mcu(Bus *prmBus, Logger *prmLogger)
double PlatformBackLeftBellow
void Log(const char *msg, Level level=Info, int errorCode=0)
These have to be in this order.
int PlatformMotionSequencer
void FrameMove(float fElapsedTime) override
float delay
wait number of seconds before executing command
double PlatformBackRightBellow