一、安装过程
1.重装ubuntu 16.04
特性化的点:
一、进入启动项选择界面:按F10
二、分区设置:
选择分区类型均为主分区【Primary】,分区位置为空间起始位置【Beginning of this sapce】
1.swap分区用于【swap area】,设置大小为16G(内存大小),用于【swap area】
2.“/boot”分区,即Ubuntu启动引导分区,设置大小为200Mb即可。
3.“/”分区,即Ubuntu启动引导分区,设置大小为70G。
4.“/home”分区,用于存储用户的个人文件(重装系统后,可以重新挂载到新系统),将剩余全部未分配空间都分给它。
5.注意,在分配完swap、/boot、/和/home四个分区后,要选择安装启动引导器的设备【Device for boot loader installation】为“/boot”所在分区,此处为“/dev/sda4”(不确定是不是这个了)。
2.安装ROS
参考资料:古月居——ROS入门21讲_5.安装ROS系统
1. 添加ROS软件源
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
2. 添加密钥
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
3. 安装ROS
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-get update
sudo apt install ros-kinetic-desktop-full
(这一步我安装了两个小时)
4.初始化rosdep
sudo rosdep init
rosdep update
rosdep update超时的解决方案:
解决ROS系统 rosdep update超时问题的新方法_leida_wt的博客-CSDN博客_rosdep update 超时
5. 设置环境变量
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
6. 安装rosinstall
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential
7.安装完成,检测一下成果吧
roscore
3.安装pip3 20.3.4
sudo apt-get install python3-pip
python3 -m pip install --user --upgrade pip==20.3.4
4.安装pytorch 1.4.0
pip3 install torch==1.4.0+cpu torchvision==0.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
5.安装pyyaml(代码里需要)
6.git clone turtlebot3相关包
参考文章:
ROS开发笔记(8)——Turtlebot3 Gazebo仿真环境下深度强化学习DQN(Deep Q-Learning)开发环境构建_天涯0508的博客-CSDN博客_gazebo 强化学习
cd ~/catkin_ws/src/
git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
git clone https://github.com/ROBOTIS-GIT/turtlebot3.git
git clone https://github.com/ROBOTIS-GIT/turtlebot3_simulations
git clone https://github.com/ROBOTIS-GIT/turtlebot3_machine_learning
cd ~/catkin_ws && catkin_make
配置环境变量:
gedit ~/.bashrc
在最下面添加
source ~/catkin_ws/devel/setup.bash
export TURTLEBOT3_MODEL=burger
7.下载gazebo模型
cd ~/.gazebo/
git clone https://github.com/osrf/gazebo_models.git models
git clone速度极慢,可以直接去网站下载,大小约为700Mb,下载完成后解压到~/.gazebo下(ctrl+h查看隐藏文件),命名为models
8.安装rospkg
pip3 install rospkg -i https://pypi.tuna.tsinghua.edu.cn/simple
二、测试
1.登录一个环境
roslaunch turtlebot3_gazebo turtlebot3_empty_world.launch
2.运行算法
python SAC.py
3.gazebo可视化
gzclient
ps:文件里有中文的话,开头加
# -*- coding: utf-8 python