当前位置:网站首页>ROS2——工作空间(五)
ROS2——工作空间(五)
2022-07-05 06:35:00 【我与nano】
ROS2机器人操作系统
前言
前面大致了解了ROS2是什么,也做好了学习的准备,ROS2的核心概念大概分为以下几点
一、工作空间
在ROS机器人开发中,我们针对机器人某些功能进行代码开始时,各种编写的代码、参数、脚本等文件,也需要放置在某一个文件夹里进行管理,这个文件夹在ROS系统中就叫做工作空间。
所以工作空间是一个存放项目开发相关文件的文件夹,也是开发过程中存放所有资料的大本营。
ROS系统中一个典型的工作空间结构如图所示,这个dev_ws就是工作空间的根目录,里边会有四个子目录,或者叫做四个子空间。
src,代码空间,未来编写的代码、脚本,都需要人为的放置到这里;
build,编译空间,保存编译过程中产生的中间文件;
install,安装空间,放置编译得到的可执行文件和脚本;
log,日志空间,编译和运行过程中,保存各种警告、错误、信息等日志。
总体来讲,这四个空间的文件夹,我们绝大部分操作都是在src中进行的,编译成功后,就会执行install里边的结果,build和log两个文件夹用的很少。
工作空间的名称我们可以自己定义,数量也并不是唯一的,比如:
工作空间1:dev_w_a,用于A机器人的开发;
工作空间2:dev_ws_b,用于B机器人的一部分功能;
工作空间3:dev_ws_b2,用于开发B机器人另外一些功能。
二、工作空间具体操作
1.创建工作空间
接下来我们可以使用如下命令创建一个工作空间,并且下载代码:
mkdir -p ~/dev_ws/src
cd ~/dev_ws/src
git clone https://gitee.com/guyuehome/ros2_21_tutorials.git
2.自动安装依赖
我们从社区中下载的各种代码,多少都会有一些依赖,我们可以手动一个一个安装,也可以使用rosdep工具自动安装:
sudo apt install -y python3-pip
sudo pip3 install rosdepc
sudo rosdepc init
rosdepc update
cd ..
rosdepc install -i --from-path src --rosdistro humble -y
这里如果Pip安装失败,可以使用脚本安装
wget https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py
这些操作是在src中进行的,也就是初始化,然后更新,最后安装依赖实在src前一级进行的,记得cd …
3.编译工作空间
依赖安装完成后,就可以使用如下命令编译工作空间啦,如果有缺少的依赖,或者代码有错误,编译过程中会有报错,否则编译过程应该不会出现任何错误:
sudo apt install python3-colcon-ros
cd ~/dev_ws/
colcon build
编译成功后你就会看到四个文件都出来了
4.设置环境变量
编译成功后,为了让系统能够找到我们的功能包和可执行文件,还需要设置环境变量:
source install/local_setup.sh # 仅在当前终端生效
echo " source ~/dev_ws/install/local_setup.sh" >> ~/.bashrc # 所有终端均生效
总结
至此,我们就完成了工作空间的创建、编译和配置。
边栏推荐
- 微信小程序路由再次跳转不触发onload
- AE tutorial - path growth animation
- 2022 winter vacation training game 5
- RecyclerView的应用
- H5 module suspension drag effect
- Use the Paping tool to detect TCP port connectivity
- Rehabilitation type force deduction brush question notes D2
- The “mode“ argument must be integer. Received an instance of Object
- The problem of Chinese garbled code in the vscode output box can be solved once for life
- LSA Type Explanation - detailed explanation of lsa-2 (type II LSA network LSA) and lsa-3 (type III LSA network Summary LSA)
猜你喜欢
The problem of Chinese garbled code in the vscode output box can be solved once for life
【MySQL8.0不支持表名大写-对应方案】
【高德地图POI踩坑】AMap.PlaceSearch无法使用
A brief introduction to heading/pitch/roll and omega/phi/kappa
Page type
how to understand the “model independent.“
MPLS experiment
5. Oracle tablespace
Vscode configures the typera editor for MD
.net core踩坑实践
随机推荐
Design specification for mobile folding screen
Genesis builds a new generation of credit system
Marvell 88e1515 PHY loopback mode test
In C language, int a= 'R'
ethtool 原理介绍和解决网卡丢包排查思路(附ethtool源码下载)
namespace
kata container
Game theory acwing 891 Nim games
La redirection de l'applet Wechat ne déclenche pas onload
Xavier CPU & GPU 高负载功耗测试
Relevant information of National Natural Science Foundation of China
Cookie、Session、JWT、token四者间的区别与联系
[nvidia] CUDA_ VISIBLE_ DEVICES
All English in the code
7. Oracle table structure
H5内嵌App适配暗黑模式
2. Addition and management of Oracle data files
What is linting
Redis-01. First meet redis
[QT] QT multithreading development qthread