Beispiel #1
0
    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)
Beispiel #2
0
    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)
Beispiel #3
0
    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)
Beispiel #4
0
    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)
Beispiel #5
0
    def test_should_return_waist(self):
        expected_motor = Motor(13, 19)
        waist = Motor(13, 19)
        arm = Arm_partial(waist, None, None, None, None, None)

        self.assertEquals(expected_motor.pin_a.number, arm.waist.pin_a.number)
        self.assertEquals(expected_motor.pin_b.number, arm.waist.pin_b.number)
        self.assertEquals(expected_motor.pin_a.value, arm.waist.pin_a.value)
        self.assertEquals(expected_motor.pin_b.value, arm.waist.pin_b.value)
Beispiel #6
0
    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
Beispiel #7
0
    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
Beispiel #8
0
    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)
Beispiel #9
0
    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)
Beispiel #10
0
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)

        if joint.direction == "l":
Beispiel #11
0
    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)