From c59543a8499943c6cf7546cde32cc363a982a4d4 Mon Sep 17 00:00:00 2001 From: John Aughey Date: Thu, 7 May 2015 03:35:18 +0000 Subject: [PATCH 1/3] This is noisy, but does talk to the CC3D --- ground/pyuavtalk/examples/example.py | 40 +++++++++---------- .../openpilot/uavtalk/objectManager.py | 3 ++ ground/pyuavtalk/openpilot/uavtalk/uavtalk.py | 2 +- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/ground/pyuavtalk/examples/example.py b/ground/pyuavtalk/examples/example.py index 344525c479a..18ee09edaab 100644 --- a/ground/pyuavtalk/examples/example.py +++ b/ground/pyuavtalk/examples/example.py @@ -69,12 +69,12 @@ def setup(self, port): print "Starting UavTalk" self.uavTalk.start() - print "Starting ConnectionManager" - self.connMan = ConnectionManager(self.uavTalk, self.objMan) + #print "Starting ConnectionManager" + #self.connMan = ConnectionManager(self.uavTalk, self.objMan) - print "Connecting...", - self.connMan.connect() - print "Connected" + #print "Connecting...", + #self.connMan.connect() + #print "Connected" print "Getting all Data" self.objMan.requestAllObjUpdate() @@ -89,31 +89,31 @@ def stop(self): self.uavTalk.stop() def showAttitudeViaObserver(self): - print "Request fast periodic updates for AttitudeActual" - self.objMan.AttitudeActual.metadata.telemetryUpdateMode.value = UAVMetaDataObject.UpdateMode.PERIODIC - self.objMan.AttitudeActual.metadata.telemetryUpdatePeriod.value = 50 - self.objMan.AttitudeActual.metadata.updated() + print "Request fast periodic updates for AttitudeState" + self.objMan.AttitudeState.metadata.telemetryUpdateMode.value = UAVMetaDataObject.UpdateMode.PERIODIC + self.objMan.AttitudeState.metadata.telemetryUpdatePeriod.value = 50 + self.objMan.AttitudeState.metadata.updated() - print "Install Observer for AttitudeActual updates\n" - self.objMan.regObjectObserver(self.objMan.AttitudeActual, self, "_onAttitudeUpdate") + print "Install Observer for AttitudeState updates\n" + self.objMan.regObjectObserver(self.objMan.AttitudeState, self, "_onAttitudeUpdate") # Spin until we get interrupted while True: time.sleep(1) def showAttitudeViaWait(self): - print "Request fast periodic updates for AttitudeActual" - self.objMan.AttitudeActual.metadata.telemetryUpdateMode.value = UAVMetaDataObject.UpdateMode.PERIODIC - self.objMan.AttitudeActual.metadata.telemetryUpdatePeriod.value = 50 - self.objMan.AttitudeActual.metadata.updated() + print "Request fast periodic updates for AttitudeState" + self.objMan.AttitudeState.metadata.telemetryUpdateMode.value = UAVMetaDataObject.UpdateMode.PERIODIC + self.objMan.AttitudeState.metadata.telemetryUpdatePeriod.value = 50 + self.objMan.AttitudeState.metadata.updated() while True: - self.objMan.AttitudeActual.waitUpdate() - self._onAttitudeUpdate(self.objMan.AttitudeActual) + self.objMan.AttitudeState.waitUpdate() + self._onAttitudeUpdate(self.objMan.AttitudeState) def showAttitudeViaGet(self): while True: - self.objMan.AttitudeActual.getUpdate() - self._onAttitudeUpdate(self.objMan.AttitudeActual) + self.objMan.AttitudeState.getUpdate() + self._onAttitudeUpdate(self.objMan.AttitudeState) def _onAttitudeUpdate(self, args): self.nbUpdates += 1 @@ -131,7 +131,7 @@ def _onAttitudeUpdate(self, args): print " %s Rate: %02.1f Hz " % (dot, self.updateRate), - roll = self.objMan.AttitudeActual.Roll.value + roll = self.objMan.AttitudeState.Roll.value print "Roll: %-4d " % roll, i = roll/90 if i<-1: i=-1 diff --git a/ground/pyuavtalk/openpilot/uavtalk/objectManager.py b/ground/pyuavtalk/openpilot/uavtalk/objectManager.py index 0849c57ce0c..0065d0674b9 100644 --- a/ground/pyuavtalk/openpilot/uavtalk/objectManager.py +++ b/ground/pyuavtalk/openpilot/uavtalk/objectManager.py @@ -130,9 +130,12 @@ def requestAllObjUpdate(self): #print "GetMeta %s" % obj try: logging.debug("Getting %s" % obj) + print("Getting %s" % obj) self.waitObjUpdate(obj, request=True, timeout=.1) logging.debug(" Getting %s" % obj.metadata) + print(" Getting %s" % obj.metadata) self.waitObjUpdate(obj.metadata, request=True, timeout=.1) + print(" Done Getting %s" % obj.metadata) except TimeoutException: logging.debug(" TIMEOUT") pass diff --git a/ground/pyuavtalk/openpilot/uavtalk/uavtalk.py b/ground/pyuavtalk/openpilot/uavtalk/uavtalk.py index 9465589c0aa..64dba548bd8 100644 --- a/ground/pyuavtalk/openpilot/uavtalk/uavtalk.py +++ b/ground/pyuavtalk/openpilot/uavtalk/uavtalk.py @@ -201,7 +201,7 @@ def _consumeByte(self, rx): logging.error("packet Size MISMATCH") self.rxState = UavTalkRecThread.STATE_SYNC else: - print "Object: %s" % self.obj + # print "Object: %s" % self.obj self.rxCount = 0 self.rxData = [] From e4df8818ba9fe2acca8a7036f796c2a88b095d6a Mon Sep 17 00:00:00 2001 From: John Aughey Date: Thu, 7 May 2015 03:50:27 +0000 Subject: [PATCH 2/3] Don't need to request all the data first, just start read. --- ground/pyuavtalk/examples/example.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ground/pyuavtalk/examples/example.py b/ground/pyuavtalk/examples/example.py index 18ee09edaab..4f0225a5efd 100644 --- a/ground/pyuavtalk/examples/example.py +++ b/ground/pyuavtalk/examples/example.py @@ -76,12 +76,12 @@ def setup(self, port): #self.connMan.connect() #print "Connected" - print "Getting all Data" - self.objMan.requestAllObjUpdate() + #print "Getting all Data" + #self.objMan.requestAllObjUpdate() - print "SN:", - sn = self.objMan.FirmwareIAPObj.CPUSerial.value - print "".join(map(_hex02, sn)) + #print "SN:", + #sn = self.objMan.FirmwareIAPObj.CPUSerial.value + #print "".join(map(_hex02, sn)) def stop(self): if self.uavTalk: From e3117df6a80136f1b6b558134bd7ab2420d0f6ff Mon Sep 17 00:00:00 2001 From: John Aughey Date: Thu, 7 May 2015 03:56:33 +0000 Subject: [PATCH 3/3] Printing RPY for testing --- ground/pyuavtalk/examples/example.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ground/pyuavtalk/examples/example.py b/ground/pyuavtalk/examples/example.py index 4f0225a5efd..9df03f94705 100644 --- a/ground/pyuavtalk/examples/example.py +++ b/ground/pyuavtalk/examples/example.py @@ -132,7 +132,9 @@ def _onAttitudeUpdate(self, args): print " %s Rate: %02.1f Hz " % (dot, self.updateRate), roll = self.objMan.AttitudeState.Roll.value - print "Roll: %-4d " % roll, + print "RPY: %f %f %f " % (self.objMan.AttitudeState.Roll.value,self.objMan.AttitudeState.Pitch.value,self.objMan.AttitudeState.Yaw.value)+" \r", + return + print "Roll: %f " % roll, i = roll/90 if i<-1: i=-1 if i>1: i= 1