示例#1
0
文件: kpilotgui.py 项目: aaaler/k9
 def SetCamera (self):    
   if self.bCam.text == 'Camera off': 
     pilot.send ("CAM OFF")
     self.bVid.state = 'normal'
     self.VideoPlayerButton (self)
     self.log.info (u"Camera off requested")
   else:  
     pilot.send ("CAM RES " + self.bCam.text) 
     self.bVid.state = 'normal'
     self.VideoPlayerButton (self)
     self.bVid.state = 'down'
     Clock.schedule_once(self.VideoPlayerButton, 4)
     self.log.info (u"Camera requested with {} resolution".format(self.bCam.text))
示例#2
0
文件: kpilotgui.py 项目: aaaler/k9
    def gsensor_init(self):
        pilot.send ("GSENSOR ON")
        self.renderer = Renderer(shader_file="3d/simple.glsl")
        scene = Scene()
        # load obj file
        loader = OBJLoader()
        obj = loader.load("3d/k9.obj")
        self.k9obj = obj.children[0]

        scene.add(*obj.children)
        camera = PerspectiveCamera(15, 1, 1, 1000)

        self.renderer.size_hint = (None,None)
        self.renderer.pos_hint = {'right' : .99, 'y': 0.4}
        self.renderer.render(scene, camera)
        self.renderer.size = (300,300)

        self.add_widget(self.renderer)
        Clock.schedule_interval(self.gsensor_3d_update, 1. / 20)
        self.renderer.bind(size=self.gsensor_3d_adjust_aspect)
示例#3
0
文件: kpilotgui.py 项目: aaaler/k9
 def ConsoleCmd (self, data):
     data = unicode (data,'utf-8');
     if data == "" : return False
     self.log.debug (u"Console input {}".format(data))
     request = data.split(' ');
     cmd = request.pop(0).lower() 
     cmd = cmd.strip("\n")
     if (data[0:1] == '-'):
         pilot.send ("SAY "+pickle.dumps(data[1:]))
         self.log.info (u"Pronouncing {}".format(data[1:])) 
     elif cmd == 'q' or cmd == 'quit':
         App.get_running_app().stop()
     elif cmd == 'send':
         pkt = ' '.join(request)
         pilot.send (pkt)
         self.log.info (u"Sent: {}".format(pkt))
     elif cmd == '?' or cmd == 'eval':
         cmd = " ".join(request)
         try:
             output = eval("pprint.pformat({})".format(cmd))
             self.log.info (u"{} = {}".format(cmd, output))
         except Exception, e:
             self.log.error(u"eval \"{}\" raised {} Exception: {}".format(cmd,type(e).__name__ ,e))
示例#4
0
文件: kpilotgui.py 项目: aaaler/k9
 def gsensor_stop(self):
     pilot.send ("GSENSOR OFF")
     self.remove_widget(self.renderer)
     self.renderer = None
     pass
示例#5
0
文件: kpilotgui.py 项目: aaaler/k9
 def SetServo2 (self, smth=""): 
     pilot.send ("SERVO 2 %0d" % self.servo2.value)
示例#6
0
文件: kpilotgui.py 项目: aaaler/k9
 def SetServo1 (self, smth=""): 
     pilot.send ("SERVO 1 %0d" % (180 - int(self.servo1.value)))
示例#7
0
文件: kpilotgui.py 项目: aaaler/k9
 def TracksStop (self):
     pilot.send ("TRACKS 0 0")
示例#8
0
文件: kpilotgui.py 项目: aaaler/k9
 def TracksMove (self, pos, *args):
     pilot.send ("TRACKS %0.2f %0.2f" % (pos[0],pos[1]))       
示例#9
0
文件: kpilotgui.py 项目: aaaler/k9
            try:
                output = eval("pprint.pformat({})".format(cmd))
                self.log.info (u"{} = {}".format(cmd, output))
            except Exception, e:
                self.log.error(u"eval \"{}\" raised {} Exception: {}".format(cmd,type(e).__name__ ,e))
        elif cmd == '!' or cmd == 'exec':
            cmd = " ".join(request)
            try:
                exec(cmd)
                self.log.info (u"Executed: {}".format(cmd))
            except Exception, e:
                self.log.error(u"exec \"{}\" raised {} Exception: {}".format(cmd,type(e).__name__ ,e))

        elif cmd == '??' or cmd == 'reval':
            pkt = ' '.join(request)
            pilot.send ("EVAL {}".format(pkt))

        else:
            self.log.info (u"Unknown command '{}'".format(cmd.encode('unicode_escape')))

        return True

    def TracksMove (self, pos, *args):
        pilot.send ("TRACKS %0.2f %0.2f" % (pos[0],pos[1]))       

    def TracksStop (self):
        pilot.send ("TRACKS 0 0")

    def SetServo1 (self, smth=""): 
        pilot.send ("SERVO 1 %0d" % (180 - int(self.servo1.value)))
#        self.servo1label.text = "Head ^%03dv" % self.servo1.value