Пример #1
0
 def doLimits(self, e=None):
     if self.doChecks(["project","port"]) == 0:
         return
     else:
         print "Relax servos for capture..."
         self.parent.doRelax()
         print "Capturing limits..."
         self.parent.project.poses["ik_min"] = project.pose("",self.parent.project.count)
         self.parent.project.poses["ik_max"] = project.pose("",self.parent.project.count)
         self.parent.project.save = True
         self.captureLimits(1)
Пример #2
0
 def doLimits(self, e=None):
     if self.doChecks(["project","port"]) == 0:
         return
     else:
         print "Relax servos for capture..."
         self.parent.doRelax()
         print "Capturing limits..."
         self.parent.project.poses["ik_min"] = project.pose("",self.parent.project.count)
         self.parent.project.poses["ik_max"] = project.pose("",self.parent.project.count)
         self.parent.project.save = True
         self.captureLimits(1)
Пример #3
0
 def doNeutral(self, e=None):
     """ Capture the Neutral Position. """
     if self.doChecks(["project", "port"]) > 0:
         print "Relax servos for capture..."
         self.parent.doRelax()
         print "Capturing neutral..."
         # show dialog with what neutral should like for this bot
         modelClassName = iKmodels[self.ikType.GetValue()].folder
         dlg = NeutralDialog(
             self.parent, 'Capture Neutral Position',
             "tools/models/" + modelClassName + "/neutral.jpg")
         #dlg = wx.MessageDialog(self.parent, 'Click OK when ready!', 'Capture Neutral Position', wx.OK | wx.CANCEL)
         if dlg.ShowModal() == wx.ID_OK:
             self.parent.project.poses["ik_neutral"] = project.pose(
                 "", self.parent.project.count)
             errors = "could not read servos: "
             for servo in range(self.parent.project.count):
                 pos = self.port.getReg(servo + 1, P_PRESENT_POSITION_L, 2)
                 if pos != -1:
                     self.parent.project.poses["ik_neutral"][
                         servo] = pos[0] + (pos[1] << 8)
                 else:
                     errors = errors + str(servo + 1) + ", "
             if errors != "could not read servos: ":
                 self.parent.sb.SetStatusText(errors[0:-2], 0)
Пример #4
0
 def addPose(self, e=None):
     """ Add a new pose. """
     if self.parent.project.name != "":
         dlg = wx.TextEntryDialog(self,'Pose Name:', 'New Pose Settings')
         dlg.SetValue("")
         if dlg.ShowModal() == wx.ID_OK:
             self.posebox.Append(dlg.GetValue()) 
             self.parent.project.poses[dlg.GetValue()] = project.pose("",self.parent.project.count)
             dlg.Destroy()
         self.parent.project.save = True
     else:
         dlg = wx.MessageDialog(self, 'Please create a new robot first.', 'Error', wx.OK|wx.ICON_EXCLAMATION)
         dlg.ShowModal()
         dlg.Destroy()
Пример #5
0
 def advancePose(self, e=None):
     """ Create a new pose, with a default name. """
     if self.parent.project.name != "":
         i = 0
         while True:
             if "pose"+str(i) in self.parent.project.poses.keys():
                 i = i + 1
             else:
                 break
         # have name, create pose
         self.parent.project.poses["pose"+str(i)] = project.pose("",self.parent.project.count)
         self.posebox.Append("pose"+str(i))
         # select pose
         self.loadPose("pose"+str(i))
         self.posebox.SetSelection(self.posebox.FindString("pose"+str(i)))
Пример #6
0
 def advancePose(self, e=None):
     """ Create a new pose, with a default name. """
     if self.parent.project.name != "":
         i = 0
         while True:
             if "pose" + str(i) in self.parent.project.poses.keys():
                 i = i + 1
             else:
                 break
         # have name, create pose
         self.parent.project.poses["pose" + str(i)] = project.pose(
             "", self.parent.project.count)
         self.posebox.Append("pose" + str(i))
         # select pose
         self.loadPose("pose" + str(i))
         self.posebox.SetSelection(self.posebox.FindString("pose" + str(i)))
Пример #7
0
 def addPose(self, e=None):
     """ Add a new pose. """
     if self.parent.project.name != "":
         dlg = wx.TextEntryDialog(self, 'Pose Name:', 'New Pose Settings')
         dlg.SetValue("")
         if dlg.ShowModal() == wx.ID_OK:
             self.posebox.Append(dlg.GetValue())
             self.parent.project.poses[dlg.GetValue()] = project.pose(
                 "", self.parent.project.count)
             dlg.Destroy()
         self.parent.project.save = True
     else:
         dlg = wx.MessageDialog(self, 'Please create a new robot first.',
                                'Error', wx.OK | wx.ICON_EXCLAMATION)
         dlg.ShowModal()
         dlg.Destroy()
Пример #8
0
 def doNeutral(self, e = None):
     """ Capture the Neutral Position. """
     if self.doChecks(["project","port"]) > 0:
         print "Relax servos for capture..."
         self.parent.doRelax()
         print "Capturing neutral..."
         # show dialog with what neutral should like for this bot
         modelClassName = iKmodels[self.ikType.GetValue()].folder
         dlg = NeutralDialog(self.parent, 'Capture Neutral Position', "tools/models/"+modelClassName+"/neutral.jpg")
         #dlg = wx.MessageDialog(self.parent, 'Click OK when ready!', 'Capture Neutral Position', wx.OK | wx.CANCEL)
         if dlg.ShowModal() == wx.ID_OK:
             self.parent.project.poses["ik_neutral"] = project.pose("",self.parent.project.count)
             errors = "could not read servos: "
             for servo in range(self.parent.project.count):
                 pos = self.port.getReg(servo+1,P_PRESENT_POSITION_L, 2)
                 if pos != -1:
                     self.parent.project.poses["ik_neutral"][servo] = pos[0] + (pos[1]<<8)
                 else:
                     errors = errors + str(servo+1) + ", "
             if errors != "could not read servos: ":
                 self.parent.sb.SetStatusText(errors[0:-2],0)