一、ubuntu 20.04+python3.7安装教程
1、下载carla_ros_bridge并配置环境
mkdir -p ~/carla-ros-bridge/catkin_ws/src
cd ~/carla-ros-bridge
git clone --recurse-submodules https://github.com/carla-simulator/ros-bridge.git catkin_ws/src/ros-bridge
source /opt/ros/noetic/setup.bash
cd catkin_ws
2、安装ros依赖项目
rosdep update
rosdep install --from-paths src --ignore-src -r
3、激活anaconda环境
conda activate carla37
4、安装conda依赖项目
conda install -c conda-forge empy
5、安装python依赖项目
pip install pyyaml
pip install opencv-python
pip install catkin_pkg
pip install rospkg -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install pygame=1.9.6 #(0.9.10的carla版本建议装pygame的1.9.6版本)
6、编译ros包
catkin build
二、ubuntu 18.04+python2.7安装教程
1、下载carla_ros_bridge并配置环境(指定0.9.10版本)
mkdir -p ~/carla-ros-bridge/catkin_ws/src
cd ~/carla-ros-bridge
#要下载 ros-bridge 的 0.9.10 版本,你需要在克隆时指定标签(tag)。可以使用以下命令:
git clone --recurse-submodules -b 0.9.10.1 https://github.com/carla-simulator/ros-bridge.git catkin_ws/src/ros-bridge
source /opt/ros/melodic/setup.bash
cd catkin_ws
2、不用安装ros依赖项,直接创建conda环境并安装依赖项
conda create -n carla27 python=2.7
conda install -c conda-forge empy
pip install catkin_pkg
#(确保当前的conda环境是py2.7的环境,# 验证当前环境是否正确(应显示Python 2.7)
#python --version # 预期输出:Python 2.7.x
#which python # 预期输出:/anaconda3/envs/carla27/bin/python
#which pip # 预期输出:/anaconda3/envs/carla27/bin/pip
3、编译ros空间
catkin_make

4、安装依赖项
pip install pyyaml
pip install rospkg
pip install numpy
pip install pygame==1.9.6
pip install opencv-python==4.2.0.32 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install pyyaml
pip install rospkg
pip install numpy
pip install pygame==1.9.6
pip install opencv-python==4.2.0.32 -i https://pypi.tuna.tsinghua.edu.cn/simple
5、运行carla_ros_bridge
source devel/setup.bash
roslaunch carla_ros_bridge carla_ros_bridge_with_example_ego_vehicle.launch

一些bug解决,比如catkin_make:Command ‘catkin_make‘ not found
source /opt/ros/melodic/setup.bash
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
比如当Python 解释器仍然在加载 Python 3.7 版本的 CARLA 库时,可以清除 Python 缓存
rm -rf __pycache__/
#比如在终端临时设置 PYTHONPATH
export PYTHONPATH=~/CARLA_0.9.10.1/PythonAPI/carla/dist/carla-0.9.10-py2.7-linux-x86_64.egg
python
import carla
常用命令
sudo gedit ~/.bashrc
source ~/.bashrc
# anaconda源
sudo gedit ~/.condarc
编辑源配置文件
sudo gedit /etc/apt/sources.list
pkg-config --modversion python/ eigen3/eigen3 #查看环境版本
rm -rf install/ build/ log/ #清除之前编译的旧文件
bashrc环境

最低0.47元/天 解锁文章
4325

被折叠的 条评论
为什么被折叠?



