Gazebo, Ros, Yolov5를 활용한 군집 드론추적 - 2(실패) | Notion

군집 드론 추적 알고리즘 이론적 설계 | Notion

yolo5 커스텀 데이터 openCV에서 사용법 | Notion

Yolov5를 활용한 드론 탐지 | Notion

1. 드론 시뮬레이션 환경 구축

우분투 실행 환경 준비

1.16 GB USB와 rufus를 활용하여 우분투 os 다운 후

부트로더 → C드라이브

우분투 파일디렉토리 → USB(128GB)

듀얼부팅 환경을 사용.

GAZEBO에서 PX4-Autopilot, QGroundControl을 사용

//PX4설치

sudo apt install git 

git clone <https://github.com/PX4/Firmware.git>

git clone <https://github.com/PX4/PX4-Autopilot.git> --recursive
//git clone [email protected]:PX4/PX4-Autopilot.git --recursive //(SSH)

bash ./PX4-Autopilot/Tools/setup/ubuntu.sh

sudo apt update
sudo apt install gazebo11(아마 이미 다운되있을거임)

-------------------------------------------------

//ROS1 설치
//설치전 세팅
sudo sh -c 'echo "deb <http://packages.ros.org/ros/ubuntu> $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

sudo apt install curl
curl -s <https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc> | sudo apt-key add -

sudo apt update

//주요 설치 코드

sudo apt install ros-noetic-desktop-full
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
source ~/.bashrc

// ROS Package를 구축하기 위한 도구 및 기타 종속성을 설치sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential python3-roslaunch

sudo apt install python3-rosdep
sudo rosdep init
rosdep update
//설치확인, 오류없이 작동화면 성공
roscore

<https://velog.io/@jdja2004/SITL-%ED%99%98%EA%B2%BD%EA%B5%AC%EC%B6%95>

--------------------------------------------------------

//QGC설치

sudo usermod -a -G dialout (사용자이름)
sudo apt-get remove modemmanager -y 
sudo apt install gstreamer1.0-plugins-bad gstreamer1.0-libav gstreamer1.0-gl -y

아래 링크로 이동
<https://docs.qgroundcontrol.com/master/en/qgc-user-guide/getting_started/download_and_install.html>
QGC APPIMAGE 다운

cd (appimage다운받은 파일경로)

chmod +x ./QGroundControl.AppImage

//QGC가 실행될것임
./QGroundControl.AppImage (or double click)

  1. 1번에서 QGC만 실행해놓기.

2. 드론에 소형 카메라 부착

Screenshot from 2024-03-18 15-06-22.png

Px4드론의 Iris.sdf를 수정 해주면 Px4드론을 로드 할 때 작은 카메라를 부착 할 수 있음. 아래는 해당 코드

위치: PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_gazebo-classic/models/iris.sdf

<?xml version='1.0'?>
<!-- DO NOT EDIT: Generated from iris.sdf.jinja -->
<sdf version='1.6'>
  <model name='iris_camera'>
    <link name='camera::link'>
      <pose frame=''>0 0 -0.1 0 0.523599 0</pose>
      <inertial>
        <pose frame=''>0.01 0.025 0.025 0 -0 0</pose>
        <mass>0.01</mass>
        <inertia>
          <ixx>4.15e-06</ixx>
          <ixy>0</ixy>
          <ixz>0</ixz>
          <iyy>2.407e-06</iyy>
          <iyz>0</iyz>
          <izz>2.407e-06</izz>
        </inertia>
      </inertial>
      <self_collide>0</self_collide>
      <kinematic>0</kinematic>
      <sensor name='PX4Flow' type='camera'>
        <update_rate>30</update_rate>
        <camera name='__default__'>
          <horizontal_fov>0.6</horizontal_fov>
          <image>
            <width>256</width>
            <height>256</height>
          </image>
          <clip>
            <near>0.1</near>
            <far>100</far>
          </clip>
          <noise>
            <type>gaussian</type>
            <mean>0</mean>
            <stddev>0.001</stddev>
          </noise>
        </camera>
        <plugin name='camera_controller' filename='libgazebo_ros_camera.so'>
	    <robotNamespace/>
	    <cameraName>flow_camera</cameraName>
	    <imageTopicName>image_raw</imageTopicName>
	    <cameraInfoTopicName>camera_info</cameraInfoTopicName>
	    <frameName>camera::link</frameName>
	    <hackBaseline>0.07</hackBaseline>
	    <distortionK1>0.0</distortionK1>
	    <distortionK2>0.0</distortionK2>
	    <distortionK3>0.0</distortionK3>
	    <distortionT1>0.0</distortionT1>
	    <distortionT2>0.0</distortionT2>
	</plugin>

      .
      .
      .
      <중략> 
      

해당 내용을 기존 파일 내용을 삭제하고 그대로 복붙 후 저장

3. Ros토픽을 yolov5를 활용하여 객체 탐지 수행