def __init__(self, mode='power'): """Run superclass's init, build motor abstraction object.""" super(OmniDriver, self).__init__() # Create motor objects motor_config = self.config['dmcc_drive_motors'] self.motors = DMCCMotorSet(motor_config) self.mode = mode
def setUp(self): """Setup test hardware files and build motor object.""" config = path.dirname(path.realpath(__file__)) + "/test_config.yaml" self.config = lib.get_config(config) self.logger = lib.get_logger() self.logger.info("Running {}()".format(self._testMethodName)) motor_conf = self.config['dmcc_drive_motors'] self.motor_set = DMCCMotorSet(motor_conf)
def test_power_invert(self): """Test the effect of setting inverted power mode""" motor_conf = self.config['dmcc_inverted'] motor_set = DMCCMotorSet(motor_conf) normal = motor_set['normal_motor'] inverted = motor_set['inverted_motor'] normal.power = 25 self.assertEqual(normal._power, 25) inverted.power = 25 self.assertEqual(inverted._power, -25)
def test_bad_config(self): motor_conf = self.config['dmcc_bad_motor_def'] with self.assertRaises(KeyError): DMCCMotorSet(motor_conf)
def test_multiple_config(self): drive_conf = self.config['dmcc_drive_motors'] drive_motor_set = DMCCMotorSet(drive_conf) self.assertEqual(len(drive_motor_set.motors), 4)
def test_instantiate(self): conf = {'a_motor': {'board_num': 0, 'motor_num': 1}} motor_set = DMCCMotorSet(conf) self.assertIsInstance(motor_set['a_motor'], DMCCMotor)