赞
踩
Win10 22H2
WSL2_Ubuntu-20.04
ROS-Noetic
Anaconda3
在该网址下载安装英伟达驱动,安装时注意关闭杀毒软件
进入WSL输入 nvidia-smi
查看显卡及驱动信息,若不报错并能成功显示则说明CUDA驱动已经在WSL配置成功
用Anaconda创建一个python版本为3.6的虚拟环境
conda create -n tf python=3.6
激活虚拟环境
conda activate tf
安装cuda、cudnn
#30系以下显卡
conda install cudatoolkit==9.0
conda install cudnn==7.1.2
#30系以上显卡
conda install cudatoolkit==11.2.0
conda install cudnn==8.1.0.77
指定清华源安装ROS依赖包
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade -U rosinstall msgpack empy defusedxml netifaces
安装tensorflow-gpu
#30系以下显卡
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade tensorflow-gpu==1.8
#30系以上显卡
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade tensorflow-gpu==2.5.0
安装keras
#30系以下显卡
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade keras==2.1.6
#30系以上显卡
pip3 install keras-nightly~=2.5.0.dev --trusted-host pypi.org --trusted-host files.pythonhosted.org
安装empy
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade empy==3.3.4
安装画图工具包
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pyqtgraph
conda install pyqt
降低numpy版本
#30系以下显卡
pip install -U numpy==1.14.5 -i https://pypi.tuna.tsinghua.edu.cn/simple
在WSL中输入
python
import tensorflow as tf
print(tf.test.is_gpu_available())
import keras
若结果是True且无警告或报错则表明tensorflow配置成功
mkdir -p catkin_ws/src
cd ~/catkin_ws/src
git clone https://gitee.com/zthcool/turtlebot3_msgs.git
git clone https://gitee.com/zthcool/turtlebot3.git
git clone https://gitee.com/zthcool/turtlebot3_simulations.git
git clone https://gitee.com/oliver_zxh/turtlebot3_machine_learning.git
cd ~/catkin_ws && catkin_make
sudo vim ~/.bashrc
#在文件末尾添加以下内容
source /home/xxx/catkin_ws/devel/setup.bash
export TURTLEBOT3_MODEL=waffle
#刷新环境变量
source ~/.bashrc
(1) 打开源码文件turtlebot3/turtlebot3_description/urdf/turtlebot3_waffle.gazebo.xacro
<xacro:arg name="laser_visual" default="false"/> # 如果想看到激光扫描线,设置成 'true'
<scan>
<horizontal>
<samples>360</samples> # 修改成24
<resolution>1</resolution>
<min_angle>0.0</min_angle>
<max_angle>6.28319</max_angle>
</horizontal>
</scan>
(2) 打开源码文件turtlebot3_simulations/turtlebot3_gazebo/launch/turtlebot3_stage_1.launch
将
<param name="robot_description" command="$(find xacro)/xacro.py '$(find carsim_discription)/urdf/model.urdf'" />
修改为
<param name="robot_description" command="$(find xacro)/xacro '$(find carsim_discription)/urdf/model.urdf'" />
(3) 打开源码文件turtlebot3_machine_learning/turtlebot3_dqn/src/turtlebot3_dqn/environment_stage_1.py
将
from respawnGoal import Respawn
修改为
from src.turtlebot3_dqn.respawnGoal import Respawn
(4) 打开源码文件turtlebot3_machine_learning/turtlebot3_dqn/nodes/turtlebot3_dqn_stage_1
将
from keras.models import Sequential, load_model
from keras.optimizers import RMSprop
from keras.layers import Dense, Dropout, Activation
修改为
from tensorflow.keras.models import Sequential, load_model
from tensorflow.keras.optimizers import RMSprop
from tensorflow.keras.layers import Dense, Dropout, Activation
再次编译工作空间
cd ~/catkin_ws && catkin_make
打开第一个终端,开启仿真环境
conda activate tf
roslaunch turtlebot3_gazebo turtlebot3_stage_1.launch
打开第二个终端,运行DQN算法
conda activate tf
roslaunch turtlebot3_dqn turtlebot3_dqn_stage_1.launch
打开第三个终端,启动数据图形显示节点
conda activate tf
roslaunch turtlebot3_dqn result_graph.launch
gazebo环境可正常打开,但提示一个警告
Node::Advertise(): Error advertising service [/goal/shininess]. Did you forget to start the discovery service?
DQN算法程序可正常加载
训练数小时后,计算图显示结果如图所示:
下一步计划研究提示该警告的原因,并尽量去除警告。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。