def __call__(self, command): p_status = ModeProgram.__call__(self, command) if p_status: return p_status if command.startswith(POINTS_PREFIX): json_str = command[len(POINTS_PREFIX):] self.new_points = self.transform_points(json.loads(json_str)) return "received {} points".format(str(len(self.new_points))) if command == 'short:trace': if self.mode == 0: return "0 {}".format(self.heading) if self.mode == 'halt': return "{} {}".format(len(self.points)-1, self.heading) t = self.mode_time() T = self.go_for i = self.index - 1 delta_i = 1 theta = self.heading delta_theta = 0 if self.mode == 'rotate': delta_i = 0 delta_theta = self.delta_angle theta -= delta_theta vals = [t, T, i, delta_i, theta, delta_theta] return ' '.join(map(str, vals));
def __call__(self, command): p_status = ModeProgram.__call__(self, command) if p_status: return p_status if command.startswith(POINTS_PREFIX): json_str = command[len(POINTS_PREFIX):] self.new_points = self.transform_points(json.loads(json_str)) return "received {} points".format(str(len(self.new_points))) if command == 'short:trace': if self.mode == 0: return "0 {}".format(self.heading) if self.mode == 'halt': return "{} {}".format(len(self.points) - 1, self.heading) t = self.mode_time() T = self.go_for i = self.index - 1 delta_i = 1 theta = self.heading delta_theta = 0 if self.mode == 'rotate': delta_i = 0 delta_theta = self.delta_angle theta -= delta_theta vals = [t, T, i, delta_i, theta, delta_theta] return ' '.join(map(str, vals))
def __call__(self, command): p_status = ModeProgram.__call__(self, command) if p_status: return p_status if command == 'short:att': if self.running: t = self.mode_time() s = self.speed angle = self.params['calib_angle'] return str(t * s / angle) else: return "program not running"