!REDIRECT “https://docs.px4.io/master/ko/middleware/micrortps_throughput_test.html

Micro RTPS 처리량 테스트

이 간단한 테스트는PX4-FastRTPS Bridge의 처리량을 특정하는 테스트입니다. 최고 속도로 256바이트의 메시지를 동시에 주고 받는 것을 측정합니다.

Tip 이 예는 수동으로 클라이언트와 에이전트 코드 생성해야 합니다.

uORB 메시지 만들기

First create a new uORB message for this test in the folder /PX4-Autopilot/msg/. 이 메시지를 throughput_256.msg로 하고 아래의 내용을 가질 것입니다.

  1. uint8[256] data

아래와 같은 명령어를 통해 수행됩니다.

  1. cd /path/to/PX4/PX4-Autopilot/msg
  2. echo uint8[256] data > throughput_256.msg

Register the new message adding it to the list of messages in the file: /PX4-Autopilot/msg/CMakeLists.txt:

  1. ...
  2. wind_estimate.msg
  3. throughput_256.msg
  4. )
  5. ...

Give the message a topic id by adding a line in the /PX4-Autopilot/Tools/message_id.py script:

  1. ...
  2. 'wind_estimate': 94,
  3. 'throughput_256': 95,
  4. }
  5. ...

자동 브릿지 코드 생성 비활성화하기

목표하는 플랫폼(cmake/configs/)의 .cmake 파일의 GENERATE_RTPS_BRIDGE 변수를 off로 설정함으로써 PX4의 빌드 과정에서 브릿지 코드의 자동 생성을 비활성화 할 수 있습니다.

  1. set(GENERATE_RTPS_BRIDGE off)

브릿지 코드의 생성

generate_microRTPS_bridge.py를 사용하여 브릿지 코드를 수동으로 생성합니다(이 코드는 오로지 throughput_256 uORB 토픽만 송수신함).

  1. cd /path/to/PX4/PX4-Autopilot
  2. python Tools/generate_microRTPS_bridge.py --send msg/throughput_256.msg --receive msg/throughput_256.msg

Client 소스코드와 Agentsrc/modules/micrortps_bridge/micrortps_client/src/modules/micrortps_bridge/micrortps_agent/에 생성됩니다.

클라이언트 코드 수정하기

이제는 Client가 매 루프마다 throughput_256 메시지를 생성하도록 수정할 것입니다. 토픽이 사실상 PX4에 의해 퍼블리시되지 않고, 가능한 빠른 속도로 보내기 위해 이 작업이 필요합니다.

src/modules/micrortps_bridge/micrortps_client/microRTPS_client.cpp 파일을 여세요. send() 함수의 while 루프를 수정하세요.

  1. ...
  2. while (!_should_exit_task)
  3. {
  4. //bool updated;
  5. //orb_check(fds[0], &updated);
  6. //if (updated)
  7. {
  8. // obtained data for the file descriptor
  9. struct throughput_256_s data = {};
  10. // copy raw data into local buffer
  11. //orb_copy(ORB_ID(throughput_256), fds[0], &data);
  12. data.data[0] = loop%256;
  13. serialize_throughput_256(&data, data_buffer, &length, &microCDRWriter);
  14. if (0 < (read = transport_node->write((char)95, data_buffer, length)))
  15. {
  16. total_sent += read;
  17. ++sent;
  18. }
  19. }
  20. usleep(_options.sleep_ms*1000);
  21. ++loop;
  22. }
  23. ...

Note 여러분은 지금 작업이 양방향 처리량 테스트를 위한 것임을 알아야합니다, 메시지는 Agent에서 Client로도 송신되어야 합니다. 그것을 위해 에이전트 코드를 수정할 필요는 없습니다. Agent는 하나의 RTPS 퍼블리셔이자 구독자입니다. 자동으로 공지한 RTPS 메시지를 수신하고, 클라언트로 미러링할 것입니다.

컴파일하고 ClientAgent를 실행하세요.

결과

이 테스트는 Pixracer에서 수행중인 PX4와 우분투 16.04의 일반적인 PC가 UART로 연결된 상태에서 수행되었습니다. Client/Agent를 위해 기본적인 설정이 사용되었습니다.

끝난 후에 클라이언트 쉘창에서 관찰한 처리량은 아래와 같습니다.

  1. SENT: 13255 messages in 13255 LOOPS, 3512575 bytes in 30.994 seconds - 113.33KB/s
  2. RECEIVED: 13251 messages in 10000 LOOPS, 3511515 bytes in 30.994 seconds - 113.30KB/s