当前位置:网站首页>ROS Bridge 笔记(01)— apt 安装、源码编译安装、安装依赖、运行显示
ROS Bridge 笔记(01)— apt 安装、源码编译安装、安装依赖、运行显示
2022-06-30 02:03:00 【wohu1104】
官网:https://carla.readthedocs.io/projects/ros-bridge/en/latest/ros_installation_ros1/
1. 安装前提
Ubuntu 18.04ROS已安装CARLA 0.9.8+已安装
可以使用 apt 安装(仅支持 Ubuntu 18.04),或者使用源码编译安装,建议源码编译安装。
2. apt 安装
2.1 添加镜像源
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1AF1527DE64CB8D9
sudo add-apt-repository "deb [arch=amd64] http://dist.carla.org/carla $(lsb_release -sc) main"
2.2 安装 ROS bridge
- 安装最新版本
sudo apt-get update # Update the Debian package index
sudo apt-get install carla-ros-bridge # Install the latest ROS bridge version, or update the current installation
- 安装指定版本
apt-cache madison carla-ros-bridge # List the available versions of the ROS bridge
sudo apt-get install carla-ros-bridge=0.9.10-1 # In this case, "0.9.10" refers to the ROS bridge version, and "1" to the Debian revision
安装成功后,可以在 /opt 目录看到安装的文件。
3. 源码编译安装
3.1 创建工作空间
mkdir -p ~/carla-ros-bridge/catkin_ws/src
3.2 克隆ROS Bridge库和子模块
cd ~/carla-ros-bridge
git clone --recurse-submodules https://github.com/carla-simulator/ros-bridge.git catkin_ws/src/ros-bridge
3.3 导入 ROS 环境变量
source /opt/ros/melodic/setup.bash
注意:默认此处安装的 ROS 版本为 melodic
3.4 安装依赖
cd catkin_ws
rosdep update
rosdep install --from-paths src --ignore-src -r
3.5 编译安装
catkin build
# 或者
catkin_make
4. 运行
4.1 启动 CARLA
根据 CARLA 安装方式不同,选择对应的命令启动 CARLA:
# Package version in carla root folder
./CarlaUE4.sh
# Debian installation in `opt/carla-simulator/`
./CarlaUE4.sh
# Build from source version in carla root folder
make launch
4.2 创建虚拟环境
安装 miniconda ,访问地址:https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
conda 的环境安装好后,创建 Python 虚拟环境
conda create -n py27 python=2.7
conda create -n py37 python=3.7
此处可以选择安装不同的版本,注意:
ros-bridge需要安装到python2.7的环境中。
通过如下命令查看当前环境已经拥有的虚拟环境
conda info -e
可选命令:
conda config --set auto_activate_base false
conda config --set report_errors false
激活、去激活某个版本的环境
conda activate py27
conda deactivate
基于 Python2.7 环境,配置 ROS Bridge 需要的 Python 依赖库
conda create -n py27 python=2.7
conda activate py27
在虚拟环境中永久设置 pip 源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
安装依赖库
pip install opencv-python==4.2.0.32
pip install networkx
pip install rospkg
pip install rospy
pip install simple_pid
pip install transforms3d
pip install networkx
pip install enum
pip install pygame
4.3 将 CARLA 路径加入到 Python 环境变量中
export CARLA_ROOT=<path-to-carla>
export PYTHONPATH=$PYTHONPATH:$CARLA_ROOT/PythonAPI/carla/dist/carla-<carla_version_and_arch>.egg:$CARLA_ROOT/PythonAPI/carla
其中:
<path-to-carla>为CARLA的安装路径;<carla_version_and_arch>为CARLA对应的Python版本包;
在上一步创建的 Python2.7 虚拟环境中执行如下命令:
(py27) [email protected]:~/tool$ export PYTHONPATH=$PYTHONPATH:/home/wohu/tool/CARLA_0.9.13/PythonAPI/carla/dist/carla-0.9.13-py2.7-linux-x86_64.egg:/home/wohu/tool/CARLA_0.9.13/PythonAPI/carla
(py27) [email protected]:~/tool$ python -c 'import carla;print("Success")'
Success
(py27) [email protected]:~/tool$
说明 Python 相关的依赖库安装正常。
4.4 导入 ROS bridge 环境变量
根据安装方式的不同,选择对应的命令导入 ros bridge 环境变量
# For debian installation of ROS bridge. Change the command according to your installed version of ROS.
source /opt/carla-ros-bridge/<melodic/noetic>/setup.bash
# For GitHub repository installation of ROS bridge
source ./carla-ros-bridge/catkin_ws/devel/setup.bash
每次运行 ROS bridge 时都需要执行以上命令,也可以将上面的命令加入到 ~/.bashrc 中。
4.5 运行 ROS Bridge
以下两个命令任意选择一个,不能同时执行。
# Option 1: start the ros bridge
roslaunch carla_ros_bridge carla_ros_bridge.launch

# Option 2: start the ros bridge together with an example ego vehicle
roslaunch carla_ros_bridge carla_ros_bridge_with_example_ego_vehicle.launch

边栏推荐
猜你喜欢

Cookie encryption 9

JS reverse request parameter encryption:

C language irony

Share the source code of the website of graduation student record

什么是幂等性?四种接口幂等性方案详解!

Using grpcui to test asp Net core grpc service

(4) Blender source code analysis flash window display process

Mobaihe cm201-2-ch-hi3798mv300-300h-emmc and NAND_ Infrared Bluetooth voice_ Brush firmware package

Using face_ Recognition library reports an error reason: cudnn_ STATUS_ NOT_ SUPPORTED

Application features and functions of painting Aquarium
随机推荐
210. Schedule II - depth traversal
Copy entire directory to output folder maintain folder structure- Copy entire directory to output folder maintaining the folder structure?
Fake divorce turns into real divorce. What about property
CTF入门学习(Web方向)
云存储架构能解决 DevOps 的什么问题?
Pytoch modifies the hook source code to obtain per layer output parameters (with layer name)
[graph neural network] overview of graph classification learning [2]: graph classification based on graph neural network
Varnish foundation overview 6
A keepalived high availability accident made me learn it again!
Varnish foundation overview 7
C语言 继续(3n+1)猜想
Some practical knowledge about PR
Pytorch中transforms的用法整理
MySQL monitoring 2
scp远程拷贝命令记录
8 — router
Write this number in C
[protection mode] segment descriptor
Conjecture of prime pairs in C language
想转行,但不知道自己要做什么工作比较好?