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_turn_off_led(self): executor = RPiExecutor() pin = Pin(21) pin.off = MagicMock() executor.go = MagicMock() control = Control(None, executor, pin) control.turn_off_led() pin.off.assert_called_with() executor.go.assert_called_with(pin)
def pi_arm_configuration(self): Configuration().configure() self._executor = RPiExecutor() waist = Motor(13, 19) 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) self._arm = arm self._led = led control = Control(None, self._executor, self._led) pi_arm = PiArm(control) return control, pi_arm
def __init__(self, control): Configuration().configure() self._executor = RPiExecutor() waist = Motor(13, 19) 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) self._arm = arm self._led = led if control == None: print "runtime constructor" self._control = Control(None, self._executor, self._led) else: print "test constructor" self._control = control
def should_be_call_parser_with_joint(self): Configuration().configure() self._executor = RPiExecutor() waist = Motor(13, 19) 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) self._arm = arm self._led = led control = Control(None, self._executor, self._led) pi_arm = PiArm(control) input_primitive_joints = "g c 10" pi_arm.execute_joint = MagicMock() expected_joint = Joint_partial("g", "c", 10) pi_arm.parse_joints(input_primitive_joints) pi_arm.execute_joint.assert_called_with(expected_joint)
def test_should_configure_arm(self): expected_waist = Motor(13, 19) expected_shoulder = Motor(23, 24) expected_elbow = Motor(17, 27) expected_wrist = Motor(16, 20) expected_gripper = Motor(5, 6) expected_led = Pin(21) expected_arm = Arm_partial(expected_waist, expected_shoulder, expected_elbow, expected_wrist, expected_gripper, expected_led) pi_arm = PiArm(None) current_arm = pi_arm._arm self.assertEquals(current_arm.waist.pin_a.number, expected_arm.waist.pin_a.number) self.assertEquals(current_arm.waist.pin_b.number, expected_arm.waist.pin_b.number) self.assertEquals(current_arm.shoulder.pin_a.number, expected_arm.shoulder.pin_a.number) self.assertEquals(current_arm.shoulder.pin_b.number, expected_arm.shoulder.pin_b.number) self.assertEquals(current_arm.elbow.pin_a.number, expected_arm.elbow.pin_a.number) self.assertEquals(current_arm.elbow.pin_b.number, expected_arm.elbow.pin_b.number) self.assertEquals(current_arm.wrist.pin_a.number, expected_arm.wrist.pin_a.number) self.assertEquals(current_arm.wrist.pin_b.number, expected_arm.wrist.pin_b.number) self.assertEquals(current_arm.gripper.pin_a.number, expected_arm.gripper.pin_a.number) self.assertEquals(current_arm.gripper.pin_b.number, expected_arm.gripper.pin_b.number) self.assertEquals(current_arm.led.number, expected_arm.led.number)
from src.main.logic.parser import Parser from src.main.Infra.rpiexecutor import RPiExecutor from src.main.logic.control import Control from src.main.domain.motor import Motor from src.main.configuration.configuration import Configuration from src.main.domain.arm_partial import Arm_partial Configuration().configure() executor = RPiExecutor() waist = Motor(13, 19) 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)
def __init__(self, pin_a, pin_b): self._pin_a = Pin(pin_a) self._pin_b = Pin(pin_b) self._is_on = False
def test_should_return_pin_led(self): expected_pin = 1 pin = Pin(1) current_pin = pin.number self.assertEquals(current_pin, expected_pin)
def test_should_return_true_when_call_off(self): pin = Pin(1) pin.off() self.assertFalse(pin.value)
def test_should_return_true_when_call_on(self): pin = Pin(1) pin.on() self.assertTrue(pin.value)
def test_should_return_true(self): expected_value = False pin = Pin(1) current_value = pin.value self.assertEquals(current_value, expected_value)