ROS2 프로젝트/LLM+ROS2+GAZEBO Control

[프로젝트1] LLM 과 ROS2를 결합한 Turtlesim 컨트롤 (2)

KRBIL 2024. 7. 21. 15:40

LLM을 활용한 Robot 제어 논문을 찾아보던 중, ROS-LLM 이라는 

 

 

github link : https://github.com/Auromix/ROS-LLM/tree/ros2-humble 
 

GitHub - Auromix/ROS-LLM: ROS-LLM is a framework designed for embodied intelligence applications in ROS. It allows natural langu

ROS-LLM is a framework designed for embodied intelligence applications in ROS. It allows natural language interactions and leverages Large Language Models (LLMs) for decision-making and robot contr...

github.com

 

 

프로젝트 논문을 발견하였고, 이 안에 Turtlebot과 ChatGPT를 연동할 수 있게끔 코드를 구현하여 이를 Implementation 하고자 한다. 

 

Github에 명시한 대로 패키지를 설치한다. 

 

mkdir -p /turtlews/src

 

gitclone을 통해 패키지 설치. 

colcon build하고,  dependencies 를 설치하고 openai_api_key를 설정해준다. 

 

그리고 파일들의 목록을 확인해보면 

  • /llm_robot에 turtle_robot.py 파일은 'turtle_robot' 이라는 노드를 만들며 
  • /turtle1/cmd_vel 토픽을 pub하는 코드
  • /ChatGPT_function_call_service 서비스를 생성하는 코드 가 있다. 
  • /llm_interfaces에는 .msg와 .srv 파일이 있으며
  • /llm_model 에는 chatgpt.py 파일이 있으며 이에는 ChatGPT 노드를 생성하며, 
  • /llm_state 토픽을 발행하고 구독하는 코드, /llm_input_audio_to_text를 구독하는 코드, /llm_response_type을 발행하는 코드, /llm_feedback_to_user를 발행하는 코드, /ChatGPT_function_call_service 서비스 클라이언트를 생성하는 코드 
  • /ChatGPT_text_output 을 발행하는 코드, chat_history 를 JSON 형태로 저장하는 코드가 있다. 

 

terminal 1 -> turtlesim 실행

terminal 2 -> /llm_feedback_to_user 토픽을 echo 하는 노드 

terminal 3 -> turtle_robot 노드

terminal 4 -> /llm_input_audio_to_text 토픽을 발행하여 chatgpt에 명령 msg 넘김 

 

 

 

 

테스트 

 

내가 입력한 자연어 명령을 이해하고, turtle bot를 동작시키는지 테스트해보았다. 

 

Message로 'Move the turtle forward and turn it quickly' 라는 명령어를 입력하여 전달하였다.

 

/llm_freedback_to_user 노드에서 다음과 같은 문구를 출력하였다.

 

feedback에서 linear velocity를 2m/s , anuglar velocity를 3rad/s 로 만든다고 명시하였다. 

 

 

큰 원은 /turtle1/cmd_vel 토픽을 직접 publish 했을 때 / 작은 원은 "Move the turtle forward and turn it quickly" 라고 했을때.

 

 

 

다음에는 다양한 명령어와 turtle bot을 2개를 놓으며 테스트 해볼 것.

그리고 코드를 분석하고자 한다.