Пример #1
0
    def test_kinmotor_ctrl(self):
        _m13 = kinmotor.KinMotor('AX-12', 13)
        _m17 = kinmotor.KinMotor('AX-12', 17)
        c = kinio.KinCable(_m13.ports[1], _m17.ports[0])

        self.kio.connect(_m13.ports[0])
        ctrl = controller.DynamixelController(self.mcom)
        mids = ctrl.discover_motors(verbose=False)
        ctrl.load_motors(mids)
        ctrl.start()

        for motor in ctrl.motors:
            motor.angle_limits = (-150, 150)
            motor.max_torque = 50
            motor.status_return_level = 1
            motor.torque_limit = 50

        sleep = 0.2
        for motor in ctrl.motors:
            motor.position = -10

        time.sleep(sleep)
        for motor in ctrl.motors:
            self.assertTrue(-10.2 <= motor.position <= -9.8)
            motor.position = 10

        time.sleep(sleep)
        for motor in ctrl.motors:
            self.assertTrue(9.8 <= motor.position <= 10.2)

        ctrl.close()
Пример #2
0
 def setUp(self):
     self.mcom = fakecom.FakeCom()
     self.mcom._add_motor(3, 'AX-12')
     self.mcom._add_motor(17, 'AX-12')
     self.ctrl = controller.DynamixelController(self.mcom)
     mids = self.ctrl.discover_motors(verbose=False)
     self.ctrl.load_motors(mids)
     self.ctrl.start()
Пример #3
0
    def test_copy_motor(self):
        ctrl = controller.DynamixelController(self.mcom)
        mids = ctrl.discover_motors(verbose=False)
        ctrl.load_motors(mids)

        with self.assertRaises(RuntimeError):
            m = copy.copy(ctrl.motors[0])
        with self.assertRaises(RuntimeError):
            m = copy.deepcopy(ctrl.motors[0])
Пример #4
0
    def test_kinmotor_discover(self):
        m13 = kinmotor.KinMotor('AX-12', 13)
        m17 = kinmotor.KinMotor('AX-12', 17)
        c = kinio.KinCable(m13.ports[1], m17.ports[0])

        self.kio.connect(m13.ports[0])
        ctrl = controller.DynamixelController(self.mcom)
        mids = ctrl.discover_motors(verbose=False)
        self.assertEqual(len(mids), 2)
        self.assertEqual(set(mids), set([13, 17]))
Пример #5
0
 def setUp(self):
     self.kio = kinio.KinSerial()
     self.mcom = serialcom.SerialCom(self.kio)
     m13 = kinmotor.KinMotor('AX-12', 13)
     m17 = kinmotor.KinMotor('AX-12', 17)
     c = kinio.KinCable(m13.ports[1], m17.ports[0])
     self.kio.connect(m13.ports[0])
     self.ctrl = controller.DynamixelController(self.mcom)
     mids = self.ctrl.discover_motors(verbose=False)
     self.ctrl.load_motors(mids)
     self.ctrl.start()
Пример #6
0
    def test_setattr(self):
        ctrl = controller.DynamixelController(self.mcom)
        mids = ctrl.discover_motors(verbose=False)
        ctrl.load_motors(mids)
        m = ctrl.motors[0]

        with self.assertRaises(AttributeError):
            m.does_not_exists = 312

        m.cw_angle_limit = 40
        m.compliant = False
Пример #7
0
    def test_kinmotor_ctrl(self):
        m13 = kinmotor.KinMotor('AX-12', 13)
        m17 = kinmotor.KinMotor('AX-12', 17)
        c = kinio.KinCable(m13.ports[1], m17.ports[0])

        self.kio.connect(m13.ports[0])
        ctrl = controller.DynamixelController(self.mcom)
        mids = ctrl.discover_motors(verbose=False)
        ctrl.load_motors(mids)
        ctrl.start()
        time.sleep(0.3)
        ctrl.close()
Пример #8
0
    def test_sync_motor(self):
        ctrl = controller.DynamixelController(self.mcom)
        mids = ctrl.discover_motors(verbose=False)
        ctrl.load_motors(mids)
        ctrl.start()

        m = ctrl.motors[0]
        m.goal_position_bytes = 312
        time.sleep(0.1)
        self.assertEqual(m.goal_position_bytes, 312)
        self.assertEqual(m.present_position, m.position)

        ctrl.stop()
Пример #9
0
    def test_motor(self):
        """DynamixelController"""
        ctrl = controller.DynamixelController(self.mcom)
        mids = ctrl.discover_motors(verbose=False)
        ctrl.load_motors(mids)
        ctrl.start()
        m = ctrl.motors[0]

        time.sleep(0.1)

        # position checks
        m.goal_position = 0
        time.sleep(0.1)
        self.assertEqual(m.goal_position_bytes, 512)
Пример #10
0
    def test_motor(self):
        """DynamixelController"""
        ctrl = controller.DynamixelController(self.mcom)
        mids = ctrl.discover_motors(verbose=False)
        ctrl.load_motors(mids)
        m = ctrl.motors[0]

        # position checks
        m.goal_position_bytes = 0
        m.goal_position_bytes
        m.present_position_bytes
        with self.assertRaises(AttributeError):
            m.present_position_bytes = 0

        with self.assertRaises(ValueError):
            m.goal_position_bytes = 1024
        with self.assertRaises(ValueError):
            m.goal_position_bytes = -1
        with self.assertRaises(ValueError):
            m.max_torque_bytes = 1.3
Пример #11
0
 def test_ctrl(self):
     """DynamixelController"""
     ctrl = controller.DynamixelController(self.mcom)
     mids = ctrl.discover_motors(verbose=False)
     ctrl.load_motors(mids)