def _angles2positions(self, alist): plist = [] for a in alist: if 'position' not in a.keys(): if a['servo'] in self.inverted: a['position'] = int(round( MathTools.interpolate(a['angle'], 180, -180, MY_DRIVE_SPEED_MIN, MY_DRIVE_SPEED_MAX) )) else: a['position'] = int(round( MathTools.interpolate(a['angle'], -180, 180, MY_DRIVE_SPEED_MIN, MY_DRIVE_SPEED_MAX) )) plist.append(a) return plist
def _on_left_down(self, event): #TODO: change event to fire with mouse key down, not only at the moment press dxy = event.GetPosition() dc = wx.ClientDC(self.canvas) dc.SetPen(wx.Pen('WHITE', 1)) self.canvas.Draw(True) dc.DrawLine(self.canvas_size / 2, self.canvas_size / 2, dxy[0], dxy[1]) dc.DrawCircle(dxy[0], dxy[1], 3) coordinates = event.GetCoords() angle = MathTools.interpolate(MathTools.vector_length(coordinates[0], coordinates[1]), 0, self.canvas_size, 0, 30) self.runner(self.bot.rotate_body, angle, (coordinates[1], -coordinates[0], 0)) self.runner(self.bot.sleep, 0.5)