Skip to content

Commit e560548

Browse files
committed
initial commit
0 parents  commit e560548

File tree

297 files changed

+76341
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

297 files changed

+76341
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.vscode
2+
*.pyc

README.md

Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
# AI Control Room with VLLM
2+
3+
4+
5+
# 1. 개요
6+
- 해양드론의 카메라 영상을 ChatGPT로 분석하고 어떤 행동을 취할지 Action을 도출해 해양드론 자율제어
7+
- Visual-LLM : 사진을 인식하고 그에 대한 질문에 응답을 생성하는 언어모델 (ChatGPT 4.0이상 기본 탑재)
8+
- 대상 수상드론 : 수상드론 WAM-V(자료 많음)에 카메라를 설치해 Gazebo에서 구현
9+
- 대상 환경 : 전방에 색이 다른 3개의 부유꼬깔콘
10+
- 목표 명령 : 어느 꼬깔콘 사이를 지나갈지를 명령하면 그에 따라 이동
11+
12+
# 2. 구현환경 설치 및 설정
13+
14+
## 2.1 ROS-Gazebo 설치
15+
16+
- 환경 : 맥북 네이티브 (VMWare X)
17+
18+
### 2.1.1 ROS-Gazebo 설치
19+
> 참고자료 : https://github.com/IOES-Lab/ROS_GZ_MacOS_Native_AppleSilicon/tree/macos_patch
20+
- ROS는 소스코드로부터 직접 컴파일, Gazebo는 brew 패키지 매니저로 컴파일된 binary 설치
21+
- 설치명령어
22+
23+
```bash
24+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/IOES-Lab/ROS2_Jazzy_MacOS_Native_AppleSilicon/main/install.sh)"
25+
```
26+
27+
- 설치 후 설치환경 로딩하려면,
28+
29+
```bash
30+
source ~/ros2_jazzy/activate_ros
31+
```
32+
33+
- 매번 새로운 Terminal 창을 켤때마다 실행시켜야 함, 단축어로 만들어서 저장해두면 편함
34+
- `nano ~/.zprofile` 로 매번 터미널을 켤때마다 실행되는 파일 `.zprofile` 을 nano 메모장어플로 실행
35+
- 아래 내용을 맨 아래 추가
36+
37+
```bash
38+
# Activate ROS-Gazebo
39+
alias ros='source ~/ros2_jazzy/activate_ros'
40+
```
41+
42+
- `Ctrl-X` , `Y` 로 수정사항 저장
43+
- 현재 터미널을 종료하고 새로운 터미널 실행
44+
- `ros` 만 입력하면 자동으로 `source ~/ros2_jazzy/activate_ros` 실행됨 (매 터미널을 켤때마다 `ros` 입력 필요)
45+
46+
### 2.1.2 ROS_GZ 설치
47+
> 참고자료 : https://github.com/IOES-Lab/ROS_GZ_MacOS_Native_AppleSilicon/tree/macos_patch
48+
- SIP 비활성화
49+
- 맥북을 재시작하고 켜질때 파워버튼을 오래 누르기
50+
- 선택 창에서 `Options` 를 선택해 recovery mode로 부팅
51+
- Use `Utilities` -> `Terminal` 으로 터미널 창을 열고 아래 명령어를 입력
52+
53+
```bash
54+
csrutil disable
55+
```
56+
57+
- `ROS_GZ`(맥 패치버전) 설치
58+
- 필요 소스코드 다운로드
59+
60+
```bash
61+
mkdir -p $HOME/ros_gz_ws/src
62+
cd $HOME/ros_gz_ws/src
63+
git clone https://github.com/IOES-Lab/ROS_GZ_MacOS_Native_AppleSilicon.git
64+
git clone https://github.com/swri-robotics/gps_umd.git
65+
git clone https://github.com/rudislabs/actuator_msgs.git
66+
git clone https://github.com/ros-perception/vision_msgs.git
67+
cd $HOME/ros_gz_ws
68+
```
69+
70+
- Set environment variables
71+
72+
```bash
73+
export CMAKE_PREFIX_PATH=$(brew --prefix qt@5)/lib:$(brew --prefix qt@5)/lib/cmake:/opt/homebrew/opt:${CMAKE_PREFIX_PATH}
74+
export PATH=$(brew --prefix qt@5)/bin:$PATH
75+
# This is rough.. but works
76+
ln -s $(brew --prefix qt@5)/mkspecs /opt/homebrew/mkspecs
77+
ln -s $(brew --prefix qt@5)/plugins /opt/homebrew/plugins
78+
```
79+
80+
- `gz-msgs10` cmake 파일에서 `TINYXML2:TINYXML2` 수정
81+
- `/opt/homebrew/opt/gz-msgs10/lib/cmake/gz-msgs10/gz-msgs10-targets.cmake` 파일을 nano 메모장으로 열기
82+
83+
```bash
84+
sudo nano /opt/homebrew/opt/gz-msgs10/lib/cmake/gz-msgs10/gz-msgs10-targets.cmake
85+
```
86+
87+
- 파일 내용 중 `TINYXML2:TINYXML2` 를 찾아 `tinyxml2::tinyxml2` 로 수정
88+
- 찾는건 `Ctrl-W`, 찾는 문자열, 엔터로 다음으로 넘어가기
89+
- 수정후 `Ctrl-X` , `Y` 로 수정사항 저장
90+
91+
- `ROS_GZ` 컴파일
92+
93+
```bash
94+
source $HOME/ros2_jazzy/activate_ros
95+
96+
python3.11 -m colcon build --symlink-install \
97+
--packages-skip-by-dep python_qt_binding \
98+
--cmake-args \
99+
-DBUILD_TESTING=OFF \
100+
-DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk \
101+
-Wno-dev --event-handlers console_cohesion+
102+
```
103+
104+
- `ROS_GZ` 환경설정 스크립트 설정
105+
- `ROS_GZ` 환경설정 스크립트를 `$HOME/ros2_jazzy/activate_ros` 에 추가
106+
- 자동으로 맨 아래줄에 추가하는 명령어
107+
108+
```bash
109+
echo "" >> $HOME/ros2_jazzy/activate_ros
110+
echo "# Activate ros_gz" >> $HOME/ros2_jazzy/activate_ros
111+
echo "source $HOME/ros_gz_ws/install/setup.bash" >> $HOME/ros2_jazzy/activate_ros
112+
```
113+
114+
- 원상복귀!
115+
- `gz-msgs10` cmake 파일에서 `tinyxml2:tinyxml2` 수정
116+
- `/opt/homebrew/opt/gz-msgs10/lib/cmake/gz-msgs10/gz-msgs10-targets.cmake` 파일을 nano 메모장으로 열기
117+
118+
```bash
119+
sudo nano /opt/homebrew/opt/gz-msgs10/lib/cmake/gz-msgs10/gz-msgs10-targets.cmake
120+
```
121+
122+
- 파일 내용 중 `tinyxml2:tinyxml2` 를 찾아 `TINYXML2::TINYXML2` 로 수정
123+
- 찾는건 `Ctrl-W`, 찾는 문자열, 엔터로 다음으로 넘어가기
124+
- 수정후 `Ctrl-X` , `Y` 로 수정사항 저장
125+
126+
- SIP 재활성화 (옵션, 권장)
127+
- 맥북을 재시작하고 켜질때 파워버튼을 오래 누르기
128+
- 선택 창에서 `Options` 를 선택해 recovery mode로 부팅
129+
- Use `Utilities` -> `Terminal` 으로 터미널 창을 열고 아래 명령어를 입력
130+
131+
```bash
132+
csrutil enable
133+
```
134+
135+
136+
## 2.2 `AI-Control-Room-VLLM` 설치
137+
138+
- 깃허브 설정
139+
- SSH키 발급 : https://docs.github.com/ko/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent?platform=mac
140+
- SSH키 등록 : https://docs.github.com/ko/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account
141+
142+
- `AI-Control-Room-VLLM` 소스코드 다운로드
143+
144+
```bash
145+
mkdir -p $HOME/vllm_control_ws/src
146+
cd $HOME/vllm_control_ws/src
147+
git clone git@github.com:IOES-Lab/AI-Control-Room-VLLM.git
148+
```
149+
150+
- 필요 라이브러리 설치
151+
- 패키지 매니저 `homebrew` 설치
152+
153+
```bash
154+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
155+
```
156+
157+
- `cgal`, `fftw` 설치
158+
159+
```bash
160+
brew update
161+
brew install cgal fftw gz-math7
162+
```
163+
164+
- 컴파일
165+
```bash
166+
cd $HOME/vllm_control_ws
167+
168+
mv $HOME/ros2_jazzy/install/gz_math_vendor/opt/gz_math_vendor/include/gz/math7/gz $HOME/ros2_jazzy/install/gz_math_vendor/opt/gz_math_vendor/include/gz/math7/gz_old
169+
ln -s /opt/homebrew/opt/gz-math7/include/gz/math7/gz $HOME/ros2_jazzy/install/gz_math_vendor/opt/gz_math_vendor/include/gz/math7/gz
170+
171+
colcon build --symlink-install --merge-install --cmake-args \
172+
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
173+
-DBUILD_TESTING=ON \
174+
-DCMAKE_CXX_STANDARD=17 \
175+
-DCMAKE_MACOSX_RPATH=FALSE \
176+
-DCMAKE_CXX_FLAGS=-Wno-duplicate-libraries \
177+
-DCMAKE_INSTALL_NAME_DIR=$(pwd)/install/lib \
178+
-DCMAKE_INCLUDE_PATH=$HOME/ros2_jazzy/install/gz_math_vendor/opt/gz_math_vendor/include/gz/math7/gz/math
179+
```
180+
181+
- `AI-Control-Room-VLLM` 환경설정 스크립트 설정
182+
- `AI-Control-Room-VLLM` 환경설정 스크립트를 `$HOME/ros2_jazzy/activate_ros` 에 추가
183+
- 자동으로 맨 아래줄에 추가하는 명령어
184+
185+
```bash
186+
echo "" >> $HOME/ros2_jazzy/activate_ros
187+
echo "# ---- Activate AI-Control-Room-VLLM ----- " >> $HOME/ros2_jazzy/activate_ros
188+
echo "source $HOME/vllm_control_ws/install/setup.bash" >> $HOME/ros2_jazzy/activate_ros
189+
```
190+
191+
- 모델, 플러그인 파일들 위치 환경변수 설정
192+
- `nano $HOME/ros2_jazzy/activate_ros` 로 열어서 맨 아래에 아래 내용 추가
193+
194+
```bash
195+
# FOR MODEL AND PLUGIN FILES
196+
# not usually required as should default to localhost address
197+
export GZ_IP=127.0.0.1
198+
199+
# ensure the model and world files are found
200+
export GZ_SIM_RESOURCE_PATH=\
201+
$GZ_SIM_RESOURCE_PATH:\
202+
$HOME/vllm_control_ws/src/AI-Control-Room-VLLM/gz-waves-models/models:\
203+
$HOME/vllm_control_ws/src/AI-Control-Room-VLLM/gz-waves-models/world_models:\
204+
$HOME/vllm_control_ws/src/AI-Control-Room-VLLM/gz-waves-models/worlds
205+
206+
# ensure the system plugins are found
207+
export GZ_SIM_SYSTEM_PLUGIN_PATH=\
208+
$GZ_SIM_SYSTEM_PLUGIN_PATH:\
209+
$HOME/vllm_control_ws/install/lib
210+
211+
# ensure the gui plugin is found
212+
export GZ_GUI_PLUGIN_PATH=\
213+
$GZ_GUI_PLUGIN_PATH:\
214+
$HOME/vllm_control_ws/src/AI-Control-Room-VLLM/gz-waves/src/gui/plugins/waves_control/build
215+
```
216+
217+
218+
## 2.3 `AI-Control-Room-VLLM` 실행 테스트
219+
220+
### 2.3.1 기본 실행 테스트 : 파도 위의 모델들
221+
222+
```bash
223+
# 환경변수 로드 (source ~/ros2_jazzy/activate_ros의 단축어)
224+
ros
225+
# waves.sdf 실행
226+
ros2 launch ros_gz_ai_control ai_control.launch.py world:=waves robot:=wamv
227+
```
228+
229+
- 종료하려면 창에 `Ctrl-C` 입력
230+
- `waves` world 외에 `waves_high`도 있음
231+
232+
- 추력 제어 테스트
233+
- 100으로 왼쪽 엔진에 Thrust 발생 (10Hz 주기로 지속적으로 전송)
234+
235+
```bash
236+
ros2 topic pub /model/wamv/joint/left_propeller_joint/cmd_thrust std_msgs/msg/Float64 '{data: 100.0}' -r 10
237+
```
238+
239+
### 참고사항
240+
- 원래 WAM-V는 엔진이 돌아가나 그러면 문제가 너무 어려워지므로 여기서는 engine-joint를 fixed로 고정시켜 놓음
241+
- 왼쪽 오른쪽 추력 조절로면 방향조절 시도
242+
- 필요하다면 `wamv.sdf` 파일을 수정해서 `Joint state and force plugins`을 사용하고 `right_engine_joint`를 fixed에서 revolute로 수정 후 사용
243+
244+
### 앞으로 해야 할 것 (제안, 물론 맘대로 다르게 진행해도 됩니다)
245+
- wamv에 카메라 달기
246+
- 카메라 가제보 메시지 토픽을 ROS로 변환하는 것 만들어야함
247+
- `gz-waves-models>models>wamv>config>robot_config.py` 파일에 카메라 이미지 메시지 추가
248+
- `rviz2`로 카메라 이미지 확인
249+
- 추력 명령어 파이썬 스크립트 만들기
250+
- 카메라의 이미지를 추력 명령어 스크립트에서 받아오기
251+
- LLM으로 전달해서 사진에 대한 설명 받아보기
252+
- LLM으로 추력 명령어 보내보기
253+
- 모든걸 연결하기
254+
- wave_high와 비교해서 난이도 올라갔을때 성능 비교하기
255+
256+

gz-waves-models/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
cmake_minimum_required(VERSION 3.8)
2+
project(waves_models)
3+
4+
find_package(ament_cmake REQUIRED)
5+
6+
install(
7+
DIRECTORY models world_models worlds
8+
DESTINATION share/${PROJECT_NAME}
9+
)
10+
11+
ament_environment_hooks(
12+
"${CMAKE_CURRENT_SOURCE_DIR}/hooks/${PROJECT_NAME}.dsv.in")
13+
14+
ament_package()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
prepend-non-duplicate;GZ_SIM_RESOURCE_PATH;@CMAKE_INSTALL_PREFIX@/share/@PROJECT_NAME@
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0"?>
2+
<model>
3+
<name>Barrage</name>
4+
<version>1.0</version>
5+
<sdf version="1.6">model.sdf</sdf>
6+
7+
<author>
8+
<name>Rhys Mainwaring</name>
9+
<email>rhys.mainwaring@me.com</email>
10+
</author>
11+
12+
<description>
13+
A collection of barrage buoys connected by universal joints.
14+
</description>
15+
16+
</model>

0 commit comments

Comments
 (0)