Example #1
0
 def test_dynamixel_scan(self, mock_robot_init):
     robot = BaseRobot(**mock_robot_init['dynamixel'])
     robot.start()
     ids = robot.buses['ttys1'].scan()
     assert 11 in ids
     assert 12 in ids
     robot.stop()
Example #2
0
 def test_dynamixel_bus_closed(self, mock_robot_init, caplog):
     robot = BaseRobot(**mock_robot_init['dynamixel'])
     bus = robot.buses['ttys1']
     # ping
     caplog.clear()
     bus.ping(11)
     assert len(caplog.records) == 1
     assert 'Ping invoked with a bus not opened' in caplog.text
     # scan
     caplog.clear()
     bus.scan(range(10))
     assert len(caplog.records) == 1
     assert 'Scan invoked with a bus not opened' in caplog.text
     # read
     dev = robot.devices['d11']
     caplog.clear()
     bus.read(dev.return_delay_time)
     assert len(caplog.records) == 1
     assert 'Attempt to use closed bus "ttys1"' in caplog.text
     # write
     caplog.clear()
     bus.write(dev.return_delay_time, 10)
     assert len(caplog.records) == 1
     assert 'Attempt to use closed bus "ttys1"' in caplog.text
     robot.stop()
Example #3
0
 def test_open_device_with_sync_items(self, mock_robot_init):
     robot = BaseRobot(**mock_robot_init['dynamixel'])
     robot.start()
     dev = robot.devices['d11']
     dev.present_position_deg.sync = True
     dev.open()
     robot.stop()
Example #4
0
 def test_dynamixel_write(self, mock_robot_init):
     robot = BaseRobot(**mock_robot_init['dynamixel'])
     robot.start()
     dev = robot.devices['d11']
     for _ in range(100):           # so that we also hit some comm errors
         dev.temperature_limit.value = 85
         assert dev.temperature_limit.value == 85
         dev.cw_angle_limit_deg.value = 10
         assert (dev.cw_angle_limit_deg.value - 10) < 0.2
     robot.stop()
Example #5
0
 def test_i2c_robot(self, mock_robot_init, caplog):
     robot = BaseRobot(**mock_robot_init['i2crobot'])
     robot.start()
     dev = robot.devices['imu']
     # 1 Byte registers
     for _ in range(5):              # to account for possible comm errs
         dev.byte_xl_x.value = 20
         assert dev.byte_xl_x.value == 20
         # word register
         dev.word_xl_x.value = 12345
         assert dev.word_xl_x.value == 12345      
     robot.stop()
Example #6
0
 def test_dynamixel_bus_acquire_bulkread(self, mock_robot_init, caplog):
     # syncs
     robot = BaseRobot(**mock_robot_init['dynamixel'])
     robot.start()
     robot.buses['ttys1'].can_use()      # lock the bus
     caplog.clear()
     robot.syncs['bulkread'].start()
     time.sleep(1)
     assert len(caplog.records) >= 1
     assert 'failed to acquire bus ttys1' in caplog.text
     robot.syncs['bulkread'].stop()
     # release bus
     robot.buses['ttys1'].stop_using()
     robot.stop()
Example #7
0
 def test_dynamixel_bus_acquire(self, mock_robot_init, caplog):
     robot = BaseRobot(**mock_robot_init['dynamixel'])
     robot.start()
     dev = robot.devices['d11']
     bus = robot.buses['ttys1']
     bus.can_use()      # lock the bus
     # read
     caplog.clear()
     bus.read(dev.return_delay_time)
     assert len(caplog.records) >= 1
     assert 'failed to acquire bus ttys1' in caplog.text
     # write
     caplog.clear()
     bus.write(dev.return_delay_time, 10)
     assert len(caplog.records) >= 1
     assert 'failed to acquire bus ttys1' in caplog.text
     # release bus
     bus.stop_using()
     robot.stop()
Example #8
0
 def test_dynamixel_bus_params(self, mock_robot_init):
     robot = BaseRobot(**mock_robot_init['dynamixel'])
     assert robot.buses['ttys1'].baudrate == 19200
     assert not robot.buses['ttys1'].rs485
     robot.stop()
Example #9
0
 def test_dynamixel_ping(self, mock_robot_init):
     robot = BaseRobot(**mock_robot_init['dynamixel'])
     robot.start()
     assert robot.buses['ttys1'].ping(11) == True
     robot.stop()
Example #10
0
 def test_dynamixel_rangeread(self, mock_robot_init):
     robot = BaseRobot(**mock_robot_init['dynamixel'])
     robot.start()
     robot.syncs['rangeread'].start()
     time.sleep(1)
     robot.stop()
Example #11
0
 def test_dynamixel_bulkwrite(self, mock_robot_init):
     robot = BaseRobot(**mock_robot_init['dynamixel'])
     robot.start()
     robot.syncs['bulkwrite'].start()
     time.sleep(1)
     robot.stop()
Example #12
0
 def test_dynamixel_robot(self, mock_robot_init):
     for name, init_dict in mock_robot_init.items():
         break
     robot = BaseRobot(name=name, **init_dict)
     robot.start()
     robot.stop()
Example #13
0
 def test_i2c_write_loop(self, mock_robot_init):
     robot = BaseRobot(**mock_robot_init['i2crobot'])
     robot.start()
     robot.syncs['write_xl'].start()
     time.sleep(1)
     robot.stop()
Example #14
0
 def test_i2c_read_loop(self, mock_robot_init):
     robot = BaseRobot(**mock_robot_init['i2crobot'])
     robot.start()
     robot.syncs['read_g'].start()
     time.sleep(1)
     robot.stop()