def test_should_return_led(self): expected_led = Pin(21) led = Pin(21) arm = Arm_partial(None, None, None, None, None, led) current_led = arm.get_motor("l") self.assertEquals(expected_led.value, current_led.value) self.assertEquals(expected_led.number, current_led.number)
def test_should_return_gripper_motor(self): expected_motor = Motor(5, 6) gripper = Motor(5, 6) arm = Arm_partial(None, None, None, None, gripper, None) current_waist = arm.get_motor("g") self.assertEquals(expected_motor.pin_a.number, current_waist.pin_a.number) self.assertEquals(expected_motor.pin_b.number, current_waist.pin_b.number) self.assertEquals(expected_motor.pin_a.value, current_waist.pin_a.value) self.assertEquals(expected_motor.pin_b.value, current_waist.pin_b.value)
def test_should_return_wrist_motor(self): expected_motor = Motor(16, 20) wrist = Motor(16, 20) arm = Arm_partial(None, None, None, wrist, None, None) current_waist = arm.get_motor("u") self.assertEquals(expected_motor.pin_a.number, current_waist.pin_a.number) self.assertEquals(expected_motor.pin_b.number, current_waist.pin_b.number) self.assertEquals(expected_motor.pin_a.value, current_waist.pin_a.value) self.assertEquals(expected_motor.pin_b.value, current_waist.pin_b.value)
def test_should_return_elbow_motor(self): expected_motor = Motor(17, 27) elbow = Motor(17, 27) arm = Arm_partial(None, None, elbow, None, None, None) current_waist = arm.get_motor("e") self.assertEquals(expected_motor.pin_a.number, current_waist.pin_a.number) self.assertEquals(expected_motor.pin_b.number, current_waist.pin_b.number) self.assertEquals(expected_motor.pin_a.value, current_waist.pin_a.value) self.assertEquals(expected_motor.pin_b.value, current_waist.pin_b.value)
shoulder = Motor(23, 24) elbow = Motor(17, 27) wrist = Motor(16, 20) gripper = Motor(5, 6) led = Pin(21) arm = Arm_partial(waist, shoulder, elbow, wrist, gripper, led) while True: primitive_joints = raw_input("enter a joints <(name direction value) ... > : ") parser = Parser() joints = parser.get_joints(primitive_joints) for joint in joints: motor = arm.get_motor(joint.name) print "direction :" + joint.direction control = Control(motor, executor, led) if joint.direction == "l": control.turn_left(float(joint.value)) elif joint.direction == "r": control.turn_right(float(joint.value)) if joint.direction == "u": control.turn_left(float(joint.value)) elif joint.direction == "d": control.turn_right(float(joint.value)) if joint.direction == "o": control.turn_left(float(joint.value))
def test_should_return_none_motor(self): waist = Motor(13, 19) arm = Arm_partial(waist, None, None, None, None, None) current_waist = arm.get_motor("x") self.assertIsNone(current_waist)