https://blog.csdn.net/qq2650326396/article/details/124801005
安装ros
wget http://fishros.com/install -O fishros && . fishros
安装conda
wget https://repo.anaconda.com/archive/Anaconda3-2021.11-Linux-x86_64.sh
bash Anaconda3-2021.11-Linux-x86_64.sh
安装vim 更新源
apt-get update
apt install vim
关于报错 这里是找不到对应的安装包 但是其已经有了pytorch1.0 在py2.yaml中删掉无法定位的包就可以了
(base) root@f281de310469:~/turtlebot3_DQN# conda env create -f py2.yaml
Collecting package metadata (repodata.json): done
Solving environment: failed
ResolvePackageNotFound:
- pytorch==1.4.0=py2.7_cpu_0
- torchaudio==0.4.0=py27
- torchvision==0.5.0=py27_cpu
在安装好的环境下 安装torch
pip install torch1.4.0 torchvision0.5.0
报错
CMake Error at /opt/ros/melodic/share/catkin/cmake/test/gtest.cmake:180 (add_executable):
add_executable cannot create target "test_transform_datatypes" because
another target with the same name already exists. The existing target is
an executable created in source directory
"/root/catkin_ws/src/geometry2/tf2". See documentation for policy CMP0002
for more details.
解决办法
cd /root/catkin_ws/src/geometry2/tf2
vim CMakeLists.txt
重命名 53-55行
报错
ImportError: "from catkin_pkg.package import parse_package" failed: No module named 'catkin_pkg'
Make sure that you have installed "catkin_pkg", it is up to date and on the PYTHONPATH.
CMake Error at /opt/ros/melodic/share/catkin/cmake/safe_execute_process.cmake:11 (message):
execute_process(/usr/bin/python3
"/opt/ros/melodic/share/catkin/cmake/parse_package_xml.py"
"/opt/ros/melodic/share/catkin/cmake/../package.xml"
"/root/catkin_ws/build/catkin/catkin_generated/version/package.cmake")
returned error code 1
解决办法 链接的路径不对
echo $PYTHONPATH 查看当前链接的路径
which python3 查看python3路径
catkin_make -DPYTHON_EXECUTABLE=/root/anaconda3/bin/python3 由于import需要使用python3 链接到python3路径即可
报错
AttributeError: module 'em' has no attribute 'RAW_OPT'
解决办法 版本太高 降版本
pip install empy==3.3.4
创建工作空间
mkdir -p catkin_ws/src
cd catkin_ws/src
git clone https://gitclone.com/github.com/ros/geometry.git
git clone https://gitclone.com/github.com/ros/geometry2.git
git clone https://gitee.com/fangxiaosheng666/PPO-SAC-DQN-DDPG
cd ..
catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python3
创建工作空间
mkdir -p ws/src
cd ws/src
git clone https://gitclone.com/github.com/ROBOTIS-GIT/turtlebot3.git
git clone https://gitclone.com/github.com/ROBOTIS-GIT/turtlebot3_simulations.git
git clone https://gitclone.com/github.com/ROBOTIS-GIT/turtlebot3_msgs.git
cd ..
source /opt/ros/melodic/setup.bash
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
catkin_make
运行gazebo仿真环境 机器人的环境
source ~/ws/devel/setup.bash
export TURTLEBOT3_MODEL=burger
roslaunch turtlebot3_gazebo turtlebot3_stage_2.launch
工作空间的程序 使用的是python3
source ~/catkin_ws/devel/setup.bash
python3 PPO.py
运行dqn 使用的是python2 不能在环境变量中用python3 会产生混用的错误
export TURTLEBOT3_MODEL=burger
conda activate py2
cd ~/turtlebot3_DQN/DQN
python DQN2.py
export TURTLEBOT3_MODEL=burger
roslaunch turtlebot3_fake turtlebot3_fake.launch #rviz仿真
roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch #控制节点
roslaunch turtlebot3_gazebo turtlebot3_world.launch
相关网址
https://zhuanlan.zhihu.com/p/265184095