def test_convert_from(self): self.assertEqual(Infinity.convert_from(Infinity.PLUS), float('inf')) self.assertEqual(Infinity.convert_from(Infinity.MINUS), float('-inf')) self.assertEqual(Infinity.convert_from(10e20), 10e20) self.assertEqual(Infinity.convert_from(-10e20), -10e20) self.assertEqual(Infinity.convert_from(float('inf')), float('inf')) self.assertEqual(Infinity.convert_from(float('-inf')), float('-inf')) self.assertEqual(Infinity.convert_from(0.3333), 0.3333) self.assertEqual(Infinity.convert_from(128), 128)
def test_convert_to(self): self.assertEqual(Infinity.convert_to(1e100), Infinity.PLUS) self.assertEqual(Infinity.convert_to(-1e100), Infinity.MINUS) self.assertEqual(Infinity.convert_to(10e20), 10e20) self.assertEqual(Infinity.convert_to(-10e20), -10e20) self.assertEqual(Infinity.convert_to(float('inf')), Infinity.PLUS) self.assertEqual(Infinity.convert_to(float('-inf')), Infinity.MINUS) self.assertEqual(Infinity.convert_to(0.3333), 0.3333) self.assertEqual(Infinity.convert_to(128), 128)
def change_param(self, param, value): """Attempt to set a parameter is servo. :rtype: bool :return: True if change request was sent successfuly """ self.logger.debug('change param %s to %s', param, value) value = Infinity.convert_to(value) pa = ParamApplyRequest(param, value) return self._apply_param(pa)
def _servo_value_changed(self, parameter, motor, limit, in_progress, value): """pl.ros3d.servo.valueChanged signal handler""" self.logger.debug('got signal for parameter %s, value: %d', parameter, value) value = Infinity.convert_from(value) ParametersStore.set(parameter, value) self.logger.debug('parameter value updated')