def test_set(self): ms = MotorSet(motors=self.ctrl.motors) ms.goal_position_bytes = 150 time.sleep(0.05) self.assertEqual(ms.motors[0].goal_position_bytes, 150) self.assertEqual(ms.motors[1].goal_position_bytes, 150) ms.position_bytes = (100, 200) time.sleep(0.05) self.assertEqual(ms.motors[0].goal_position_bytes, 100) self.assertEqual(ms.motors[1].goal_position_bytes, 200) with self.assertRaises(AttributeError): ms.does_not_exist = 100
def test_get(self): ms = MotorSet(motors=self.ctrl.motors) self.assertEqual(len(ms.position), len(self.ctrl.motors)) self.assertEqual(len(ms.position), 2) with self.assertRaises(AttributeError): ms.does_not_exist
def test_expand_values(self): ms = MotorSet(motors=self.ctrl.motors) ms.moving_speed = 0 ms.moving_speed = [0, 10] ms.angle_limits = [0, 10] ms.angle_limits = [[-100, 100], [-150, 150]] ms.angle_limits = (-150, 150)
def test_empty(self): ms = MotorSet(motors=[]) ms.pose = [] with self.assertRaises(AttributeError): ms.punch with self.assertRaises(AttributeError): ms.punch = 50 ms.punch = [] ms.does_not_exist = []
def test_motor_properties(self): ms = MotorSet(motors=self.ctrl.motors) ms.moving_speed = 0 ms.moving_speed
def test_properties(self): ms = MotorSet(motors=self.ctrl.motors) ms.zero_pose = -150 ms.zero_pose ms.pose = 0 ms.pose
def test_iadd(self): ms = MotorSet(motors=self.ctrl.motors) ms.position += 10
def test_dir(self): ms = MotorSet(motors=self.ctrl.motors) self.assertTrue('compliant' in dir(ms)) self.assertTrue('present_temperature_bytes' in dir(ms)) self.assertTrue('request_write' in dir(ms))
def test_bundles(self): ms = MotorSet(motors=self.ctrl.motors) ms.cw_angle_limit = 150 ms.angle_limits = (-150, 150)
def test_error(self): ms = MotorSet(motors=self.ctrl.motors) ms.cw_angle_limit = 150 time.sleep(0.1) with self.assertRaises(exc.MotorError): ms.cw_angle_limit = 100