def LogData(self): if (self.logging): acc = MiroAPI.GetBodyAcceleration(self.GetBody()) g = -9.8 # Rescales so all instances of momentary acceleration act under 1/300 seconds if hasattr(self, 'Hz'): acc = acc * (self.Hz * self.dt) g = g * (self.Hz * self.dt) data = str(acc[0]) + ' ' + str(acc[1] - g) + ' ' + str( acc[2]) + '\n' self.filestream.write(data)
def CheckTrigger(self): if not self.triggered: if not self.trigger: self.triggered = True else: position = MiroAPI.GetBodyPosition(self.GetBody()) velocity = MiroAPI.GetBodyVelocity(self.GetBody()) acceleration = MiroAPI.GetBodyAcceleration(self.GetBody()) if self.trigger(position, velocity, acceleration): self.triggered = True self.F = MiroAPI.AddBodyForce(self.GetBody(), self.force, [0, 1, 0], new=True) elif self.fuel > 0: MiroAPI.AddBodyForce(self.GetBody(), self.force, [0, 1, 0], new=False) self.fuel = self.fuel - self.cons * self.dt elif not self.expended: MiroAPI.RemoveBodyForce(self.GetBody(), self.F) self.expended = True