def test_radio(self): data = b'radio X30F60R [0, 100, 30]\n' bus = MagicMock() r = ROSMsgParser(config={}, bus=bus) r.slot_raw(timestamp=None, data=data) bus.publish.assert_called_with('radio', [b'X30F60R', b'[0, 100, 30]\n'])
def test_publish_desired_speed(self): data = b'\x08\x00\x00\x00\x02\x00\x00\x00\x00\x06\x81\x14' # clock as 8 bytes bus = MagicMock() r = ROSMsgParser(config={}, bus=bus) r.slot_raw(timestamp=None, data=data) bus.publish.assert_called_with('sim_time_sec', 2) clock_data = b'\x08\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00' # clock 3s r.slot_raw(timestamp=None, data=clock_data) bus.publish.assert_called_with( 'sim_time_sec', 3) # initially desired speed is None -> no cmd r.slot_desired_speed(timestamp=None, data=[0, 0]) r.slot_raw(timestamp=None, data=clock_data) # ... asserting that the last call has been made in a particular way bus.publish.assert_called_with('cmd', b'cmd_vel 0.000000 0.000000') # after update from 3D desired speed only extended cmd_vel_3d should be used r.slot_desired_speed_3d(timestamp=None, data=[[1, 2, 3], [4, 5, 6]]) r.slot_raw(timestamp=None, data=clock_data) bus.publish.assert_called_with( 'cmd', b'cmd_vel_3d 1.000000 2.000000 3.000000 4.000000 5.000000 6.000000' )