• 欢迎访问开心洋葱网站,在线教程,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站,欢迎加入开心洋葱 QQ群
  • 为方便开心洋葱网用户,开心洋葱官网已经开启复制功能!
  • 欢迎访问开心洋葱网站,手机也能访问哦~欢迎加入开心洋葱多维思维学习平台 QQ群
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏开心洋葱吧~~~~~~~~~~~~~!
  • 由于近期流量激增,小站的ECS没能经的起亲们的访问,本站依然没有盈利,如果各位看如果觉着文字不错,还请看官给小站打个赏~~~~~~~~~~~~~!

ROS2机器人应用简明教程4工区

人工智能 zhangrelay 1969次浏览 0个评论

工区/工作区/工作空间(workspace简写为ws)是机器人操作系统核心概念之一。  

工作空间是包含ROS 2软件的文件夹。在使用ROS 2之前,必须在正在使用的终端中配置ROS 2工作区(包括系统和局部),使ROS 2的软件包可在此终端中使用。  

  如上图所示,foxy/noetic分别为ros2和ros1的系统工作区,使用如下命令可以顺利加载配置:

  • source /opt/ros/foxy/setup.bash

 
  如上文件夹下都是使用apt安装在系统目录下的软件包。 如果自定义机器人软件程序,通常在home文件夹下,新建诸如ros_ws/src文件夹,然后编写代码,编译生成可执行文件使用。 以博客中之前讲解过的mobot为例,此案例正在dashing/eloquent/foxy进行测试。 如果需要编译工区源码,需要使用如下命令安装所需功能包:

  • rosdep install -i –from-path src –rosdistro foxy -y

接着使用colcon build:

  • colcon build

 
  这样就完成了一个自定义工区的编译,使用如下命令加载环境:

  • source install/setup.bash

 
  install:  
  如果没有正确加载的话,此工区的功能包是无法发现和使用的!  
  其他注意事项:

  1. You also have the option of sourcing an “overlay” – a secondary workspace where you can add new packages without interfering with the existing ROS 2 workspace that you’re extending, or “underlay”. Your underlay must contain the dependencies of all the packages in your overlay. Packages in your overlay will override packages in the underlay. It’s also possible to have several layers of underlays and overlays, with each successive overlay using the packages of its parent underlays.
  2. Sourcing the local_setup of the overlay will only add the packages available in the overlay to your environment. setup sources the overlay as well as the underlay it was created in, allowing you to utilize both workspaces.So, sourcing your main ROS 2 installation’s setup and then the dev_ws overlay’s local_setup, like you just did, is the same as just sourcing dev_ws’s setup, because that includes the environment of the underlay it was created in.

  如果自定义包和系统包重名,或者下载了系统包源码自定义,请掌握环境配置方法,确保启动的是需要的节点和应用,而非系统默认的应用。   参考视频教程链接如下:

  • https://www.bilibili.com/video/bv1dv411B7KY

 


开心洋葱 , 版权所有丨如未注明 , 均为原创丨未经授权请勿修改 , 转载请注明ROS2机器人应用简明教程4工区
喜欢 (0)

您必须 登录 才能发表评论!

加载中……