YOPO环境配置

系统环境:Ubuntu20.04

1. 安装 ROS 及配置

1.1. ROS 安装

在终端中输入命令

wget http://fishros.com/install -O fishros && . fishros

输入 1,回车

输入 1,回车

输入 2,回车

选择安装的版本,选择 noetic 对应的数字回车进行安装。

安装桌面版,回车。等待安装,大概15分钟(看网速),出现如下界面安装完成。

1.2. ROS 配置(rosdepc 安装)

在终端中输入命令

wget http://fishros.com/install -O fishros && . fishros

输入 3,回车。安装完成后,在终端中输入命令

rosdepc update

2. 显卡驱动、CUDA、Miniconda 安装

2.1. 显卡驱动安装

打开 《软件与更新》 ,选择合适的驱动。选择 driver 驱动,不要选择 server 驱动

2.2. CUDA11.8 安装

去 nvidia 官网https://developer.nvidia.com/cuda-toolkit-archive 寻找所需版本

这里安装 CUDA11.8 版本

如配置一样,则在终端执行下载安装命令

wget https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run
sudo sh cuda_11.8.0_520.61.05_linux.run

安装完成后在终端中输入nvcc -V​命令,如果出现11.4就说明成功安装。

2.3. Miniconda 安装

1.下载文件

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

安装的时候可能会出现下面的情况:

退出终端把刚才下好的miniconda的.sh文件删除(一般在主目录下就能找到),重新输入命令即可。成功情况如下:

2.添加可执行权限

sudo chmod +x Miniconda3-latest-Linux-x86_64.sh

之后输入密码即可。

3.运行安装脚本

sudo ./Miniconda3-latest-Linux-x86_64.sh

4.运行后:

点击ENTER进入即可。之后会出现一个用户协议,按空格键直到协议最底部,然后输入“yes”接受协议,开始安装。之后需要确认想要安装的目录。

一般就是安在主目录下就行(如上图那种格式),我就是将它安装在主目录下,如果你想更改路径请输入路径后在按回车键。

之后输入yes即可,之后就显示安装成功了!

5.将miniconda加入PATH路径

a.打开~/.bashrc文件

gedit ~/.bashrc

b.如果没有vim请输入下列命令进行下载:

sudo apt-get install gedit

c.打开后在代码最后加入这样一段代码,保存并退出。

<<< conda initialize <<<
// 在上述代码后插入下列代码
export PATH="/home/workspace_name/miniconda3/bin:$PATH"
// 注意workspace_name是你自己系统的名字请要修改,注释不用复制进去啊
// 注意:路径要与你之前的路径相对应,请酌情修改。

6.执行以下命令生效

source  ~/.bashrc
  1. 安装成功

关闭当前的命令行窗口,重新打开后即可使用miniconda

3. UAV_Simulator 安装

在终端输入

mkdir ~/UAV_Simulator/src && cd ~/UAV_Simulator/src
git clone https://github.com/TJU-Aerial-Robotics/UAV_Simulator
cd ../
catkin_make
source devel/setup.bash
roslaunch so3_quadrotor_simulator simulator.launch

4. YOPO 安装

4.1. 拷贝代码

git clone https://github.com/TJU-Aerial-Robotics/YOPO.git

4.2. 安装 Fightmare 依赖项

确保已经安装基础的依赖项(ROS,CUDA,Conda)

终端中输入

sudo apt-get update && sudo apt-get install -y --no-install-recommends \
   build-essential \
   cmake \
   libzmqpp-dev \
   libopencv-dev \
   libpcl-dev

4.3. 将工作空间添加到环境变量中

# modify "~/YOPO" to your path
echo "export FLIGHTMARE_PATH=~/YOPO" >> ~/.bashrc
source ~/.bashrc

4.4. 下载 RPG_Flightmare 解压后放入 flightrender 文件夹

文件位置链接:https://pan.baidu.com/s/1c2OI5V2UzbB1jKwh3XKvPw?pwd=ena9 提取码:ena9

flightrender/
├── CMakeLists.txt
└── RPG_Flightmare/
    ├── flightmare.x86_64
    └── ...

注意可执行文件flightmare.x86_64名称是否与run_yopo.py文件中os.system打开的可执行文件同名

4.5. 创建 conda 虚拟环境

conda create --name yopo python=3.8
conda activate yopo

conda install pytorch==2.4.1 torchvision==0.19.1 torchaudio==2.4.1  pytorch-cuda=11.8 -c pytorch -c nvidia
pip install opencv-python
pip install gym==0.21.0 stable-baselines3==1.5.0 
pip install scipy==1.10.1 scikit-build==0.18.1 ruamel-yaml==0.17.21 numpy==1.22.3 tensorboard==2.8.0 empy catkin_pkg

此处安装会报错,依次输入以下命令

pip install pip==24.0
pip install setuptools==65.5.0
pip install wheel==0.38.0

在继续执行之前报错的命令

4.6. 编译 flightlib

conda activate yopo
cd YOPO/flightlib/build
cmake ..
make -j8
pip install . //如果提示进程锁,则在前面添加sudo权限

4.7. 可能存在一些问题

4.7.1. No module named ‘flightpolicy’

# modify "~/YOPO/flightpolicy" to your path
echo "export PYTHONPATH=$PYTHONPATH:~/YOPO" >> ~/.bashrc
source ~/.bashrc

4.7.2. No module named ‘flightgym’

cd YOPO/flightlib/build
pip install -e .

5. YOPO_Test2

以下是 github 原文,可参考​**https://github.com/TJU-Aerial-Robotics/YOPO**

2.1 Start the simulation environment with Unity and the ROS interface (It will take some time to load Unity and randomly generate a new environment)

cd ~/YOPO/flightrender/RPG_Flightmare
./flightmare.x86_64
cd ~/YOPO/flightlib/build
./flightros_node

Besides, you can refer to quadrotor_ros.yaml for some modifications of the environment.

2.2 Start the dynamics simulation and controller of UAV

cd ~/UAV_Simulator
source devel/setup.bash
roslaunch so3_quadrotor_simulator simulator.launch

2.3 Start the YOPO inference and the Planner. You can refer to traj_opt.yaml for modification of the flight speed (The given weights are pretrained at 6 m/s and perform smoothly at speeds between 0 – 6 m/s).

cd ~/YOPO/run
conda activate yopo
python test_yopo_ros.py --trial=1 --epoch=0 --iter=0
cd ~/YOPO/flightlib/build
./yopo_planner_node

The implementation of **yopo\_planner\_node**​ and **test\_yopo\_ros.py**​ are merged into **test\_yopo\_ros\_new.py**​ (just python test\_yopo\_ros\_new.py).

2.4 Visualization: start the RVIZ and publish the map. Then you can click the **2D Nav Goal**​ on RVIZ as the goal at will, just like the following GIF.

cd ~/YOPO/
rviz -d yopo.rviz

(optional) Wait for the map to be saved by **flightros\_node**​ and then:

cd ~/YOPO/flightlib/build
./map_visual_node

https://github.com/TJU-Aerial-Robotics/YOPO/blob/main/docs/click_in_rviz.gif


评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注