Example #1
0
    def testCritical(self):
        # Subscribe to the warning event
        self._string = ""

        def _critical_handler(event):
            self._string = event.string

        self._called = False

        def _warning_handler(event):
            self._called = True

        self.qeventHub.subscribeToType(monitor.Monitor.WARNING,
                                       _warning_handler)
        self.qeventHub.subscribeToType(monitor.Monitor.CRITICAL,
                                       _critical_handler)

        # Publish an event that does not reach the warning value
        event = math.NumericEvent()
        event.number = 2
        self.qeventHub.publish(TestMonitor.TESTEVENT, event)
        self.qeventHub.publishEvents()

        self.assertEqual("", self._string)

        # Publish the event with the critical value
        # Critical value should outprioritize the warning value
        event = math.NumericEvent()
        event.number = 10
        self.qeventHub.publish(TestMonitor.TESTEVENT, event)
        self.qeventHub.publishEvents()

        self.assertEqual(
            "ram.test.monitor.TestMonitor.TESTEVENT:"
            "number:testing123:10.0", self._string)
Example #2
0
    def testWarning(self):
        # Subscribe to the warning event
        self._string = ""

        def _handler(event):
            self._string = event.string

        self.qeventHub.subscribeToType(monitor.Monitor.WARNING, _handler)

        # Publish an event that does not reach the warning value
        event = math.NumericEvent()
        event.number = 4
        self.qeventHub.publish(TestMonitor.TESTEVENT, event)
        self.qeventHub.publishEvents()

        self.assertEqual("", self._string)

        # Publish the event with the warning value
        event = math.NumericEvent()
        event.number = 5
        self.qeventHub.publish(TestMonitor.TESTEVENT, event)
        self.qeventHub.publishEvents()

        self.assertEqual(
            "ram.test.monitor.TestMonitor.TESTEVENT:"
            "number:testing123:5.0", self._string)
Example #3
0
    def update(self, time):
        """
        Sends out events using the current estimated values
        """
        self.depthFilter.addValue(
            -3.281 * self.robot._main_part._node.position.z)

        self.posXFilter.addValue(
            self.robot._main_part._node.position.x)

        self.posYFilter.addValue(
            -self.robot._main_part._node.position.y)
        
        self.position = math.Vector2(
            self.posXFilter.getValue(),
            self.posYFilter.getValue())

        self.velocity = math.Vector2(
            self.posXFilter.getValue(1, time),
            self.posYFilter.getValue(1, time))

        self.depth = self.depthFilter.getValue()
        self.depthRate = self.depthFilter.getValue(1, time)

        # Package all events
        devent = math.NumericEvent()
        devent.number = self.getEstimatedDepth()
        
        drevent = math.NumericEvent()
        drevent.number = self.getEstimatedDepthRate()

        pevent = math.Vector2Event()
        pevent.vector2 = self.getEstimatedPosition()

        vevent = math.Vector2Event()
        vevent.vector2 = self.getEstimatedVelocity()

        oevent = math.OrientationEvent()
        oevent.orientation = self.getEstimatedOrientation()

        # Send all events at the same time
        self.publish(estimation.IStateEstimator.ESTIMATED_DEPTH_UPDATE, devent)
        self.publish(estimation.IStateEstimator.ESTIMATED_DEPTHRATE_UPDATE,
                     drevent)
        self.publish(estimation.IStateEstimator.ESTIMATED_POSITION_UPDATE,
                     pevent)
        self.publish(estimation.IStateEstimator.ESTIMATED_VELOCITY_UPDATE,
                     vevent)
        self.publish(estimation.IStateEstimator.ESTIMATED_ORIENTATION_UPDATE,
                     oevent)
Example #4
0
 def update(self, time):
     event = math.NumericEvent()
     event.number = self.getDepth()
     self.publish(device.IDepthSensor.UPDATE, event)
     rawEvent = vehicle.RawDepthSensorDataEvent()
     rawEvent.rawDepth = self.getDepth()
     rawEvent.sensorLocation = self.getLocation()
     self.publish(device.IDepthSensor.RAW_UPDATE, rawEvent)
Example #5
0
        def testNumericEvent(self):
            def handler(event):
                self.number = event.number

            self.epub.subscribe("TEST", handler)

            newEvent = math.NumericEvent()
            newEvent.number = 5
            self.epub.publish("TEST", newEvent)
            self.assertEquals(5, self.number)

            # Try with the hub
            self.qeventHub.subscribeToType("TEST", handler)

            newEvent = math.NumericEvent()
            newEvent.number = 8
            self.epub.publish("TEST", newEvent)
            self.qeventHub.publishEvents()
            self.assertEquals(8, self.number)
Example #6
0
    def testNominal(self):
        # Set the monitor to be at critical value
        self.monitor._signals['Test']._lastValue = 10

        self._string = ""

        def _nominal_handler(event):
            self._string = event.string

        self.qeventHub.subscribeToType(monitor.Monitor.NOMINAL,
                                       _nominal_handler)

        # Set the system back to a non-warning value
        event = math.NumericEvent()
        event.number = 3
        self.qeventHub.publish(TestMonitor.TESTEVENT, event)
        self.qeventHub.publishEvents()

        self.assertEqual(
            "ram.test.monitor.TestMonitor.TESTEVENT:"
            "number:testing123:3.0", self._string)
Example #7
0
 def setForce(self, force):
     self._simThruster.force = force
     
     event = math.NumericEvent()
     event.number = self._simThruster.force
     self.publish(device.IThruster.FORCE_UPDATE, event)
Example #8
0
 def publishDepthUpdate(self, vehicleDepth):
     event = math.NumericEvent()
     event.number = vehicleDepth
     self.publish(estimation.IStateEstimator.ESTIMATED_DEPTH_UPDATE, event)
Example #9
0
 def _createEvent(self, perc):
     event = math.NumericEvent()
     event.number = perc
     return event