ROS机器人操作系统入门笔记(一、二节)

ROS机器人操作系统入门-中国大学MOOC

讲义:https://github.com/kaixindelele/ros_demo_mooc/blob/master/ros-tutorial-icourse163.pdf

代码示例:https://github.com/DroidAITech/ROS-Academy-for-Beginners

有一位大佬做了同样的笔记:大佬的读书笔记(1)

---

下面这两个视频,东西会比较多,更多侧重于从软硬件搭建一个树莓派的ros机器人,甚至有说到stm32,并非用套件。

 

目录

课程笔记

第一节课 ROS介绍与安装

框架

工具

功能

社区

ROS的安装的基本步骤和对应事项、好用的IDE:roboware

下载

安装好

教学代码包github地址

ROBOWARE的IDE

第二节课:ROS工程结构

src--功能包

package组成

package.xml

代码

除了上面的,package还可以放这些文件

ROS包管理的常用指令

操作演示:Catkin工作空间探索


课程笔记

第一节课 ROS介绍与安装

ROS就是机器人操作系统,避免了机器人工程师直接面对硬件、传感器、电路、底层驱动、通信、上层算法造成工作量大的问题,提供了类似于操作系统一样的工程,使得机器人的开发更加的简单。

ROS起源于2000s,吴恩达就参与其开发,到现在有十多个版本,每一个版本都有对应依赖的ubuntu系统,Indigo和Kinetic是LTS长期维护版本,其他的都是两年。此教程基于ubuntu16对应的Kinetic。

ROS实际上不是操作系统,是中间件,连接了真正的操作系统和程序,提供了一下功能:

  1. 硬件抽象
  2. 底层设备控制
  3. 常用函数的实现
  4. 进场之间消息的传递
  5. 包管理

其实ROS的官方定义是 框架+工具+功能+社区:

框架

我们说ROS一般指的是ROS的通信框架(规范),ROS采用分布式架构:可以运行多个进程,每个进程又可以单独设计,组合起来。在ROS中进程被称为节点NODE。ROS提供框架管理NODE提供了他们之间相互通信的桥梁,使得机器人控制,机关雷达,定位,导航等任务相互通信,组织,最后实现自主导航。

这种分布式架构的好处就是扩展性好,软件复用率高,只对节点负责,将程序分划。

工具

ROS提供了很多基础工具,比如Gazebo、Rviz等等 用于仿真和调试

功能

ROS提供了很多功能包,比如控制啊,规划啊,视觉啊,建图的包啊,可以直接使用。这样的好处就是,可以在ROS开源的程序之上加上我们自己写的算法,这样就可以只需要做自己擅长的那一部分,这也是分布式架构的体现

ROS的官方网站wiki和GITHUB上可以看到其开源程序

社区

ROS也是一个强大的社区和软件包管理工具,很多工具都是apt-get就可以获得


ROS的安装的基本步骤和对应事项、好用的IDE:roboware

ROS的官网:这里这里

比较重要的地方是ros官网里的wiki:http://wiki.ros.org/

里面有安装教程啊、ROS的教程的

下载

rosdep是ROS里面依赖项管理的工具,安装完毕之后要初始化:sudo rosdep

然后echo “sourc /opt/ros/kinetic/setup.bash" >> ~/.bashrc是用来配置ROS环境的,使得每次打开一个终端都会将ROS的环境自动配置好,也就是添加到bash会话中:因为source /opt/ros/kinetic/setup.bash只在当前的终端起作用(PS:貌似UBUNTU中所有的安装软件都是在根目录下的某个文件夹,详情可以看linux软件安装目录的选择

然后下载官方推荐的python-rosinstall

记得source bash.rc生效哦

安装好

安装好之后,输入roscore,如果没有报错,在另一个终端输入如下,会出现版本号

asber@asber-X550VX:~$ rosparam list
/rosdistro
/roslaunch/uris/host_asber_x550vx__38823
/rosversion
/run_id
asber@asber-X550VX:~$ rosparam get /rosdistro
'melodic

  '
asber@asber-X550VX:~$ 

教学代码包github地址

https://github.com/DroidAITech/ROS-Academy-for-Beginners

下载、编译,由于github的教程是kinetic的,所以安装教学包所需的依赖的时候会出现如下错误

asber@asber-X550VX:~/catkin_ws$ rosdep install --from-paths src --ignore-src --rosdistro=kinetic -y
WARNING: given --rosdistro kinetic but ROS_DISTRO is "melodic". Ignoring environment.
WARNING: ROS_PYTHON_VERSION is unset. Defaulting to 2
ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies:
robot_sim_demo: No definition of [yocs_cmd_vel_mux] for OS version [bionic]
navigation_sim_demo: No definition of [dwa_local_planner] for OS version [bionic]
slam_sim_demo: No definition of [hector_mapping] for OS version [bionic]

按照此处:https://github.com/DroidAITech/ROS-Academy-for-Beginners/issues/13

下载报,修改package.xml

但是发现修改xml之后

 rosdep install --from-paths src --ignore-src --rosdistro=melodic -y

还是发生:

下列软件包有未满足的依赖关系:
 : 依赖: libsdl-image1.2-dev 但是它将不会被安装
                          依赖: libsdl1.2-dev 但是它将不会被安装
E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系。
ERROR: the following rosdeps failed to install

那就安装map_server:https://blog.csdn.net/qq_32618327/article/details/98878592

sudo apt-get install libsdl1.2-dev libsdl-image1.2-dev

的时候显示依赖问题:E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系。

所以用aptitude来下:sudo aptitude install libsdl1.2-dev libsdl-image1.2-dev

发现最后按照上面这篇说的make之后还是

  Could NOT find SDL (missing: SDL_LIBRARY SDL_INCLUDE_DIR)
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.10/Modules/FindSDL.cmake:190 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  navigation/map_server/CMakeLists.txt:12 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/asber/catkin_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/asber/catkin_ws/build/CMakeFiles/CMakeError.log".
Invoking "cmake" failed

按照此处:https://blog.csdn.net/Groot_Lee/article/details/79202507

catkin_make之后还是出现上面这个报错

然后我

asber@asber-X550VX:~/catkin_ws$ sudo apt-get install libsdl2-dev
正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
有一些软件包无法被安装。如果您用的是 unstable 发行版,这也许是
因为系统无法达到您要求的状态造成的。该版本中可能会有一些您需要的软件
包尚未被创建或是它们已被从新到(Incoming)目录移出。
下列信息可能会对解决问题有所帮助:

下列软件包有未满足的依赖关系:
 libsdl2-dev : 依赖: libpulse-dev 但是它将不会被安装
E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系。
asber@asber-X550VX:~/catkin_ws$ sudo apt-get install libsdl2-image-dev
正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
有一些软件包无法被安装。如果您用的是 unstable 发行版,这也许是
因为系统无法达到您要求的状态造成的。该版本中可能会有一些您需要的软件
包尚未被创建或是它们已被从新到(Incoming)目录移出。
下列信息可能会对解决问题有所帮助:

下列软件包有未满足的依赖关系:
 libsdl2-image-dev : 依赖: libsdl2-dev (>= 2.0.8) 但是它将不会被安装
E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系。

然后再aptitude发现之前的方案是保持没有安装,所以否认没有安装的方案,然后他给了一个降级其他包的方案,然后安装

asber@asber-X550VX:~/catkin_ws$ sudo aptitude install libsdl2-dev
下列“新”软件包将被安装。         
  libasound2-dev{a} libcapnp-0.6.1{a} libibus-1.0-dev{a} 
  libmirclient-dev{a} libmirclient9{a} libmircommon-dev{a} libmircommon7{a} 
  libmircookie-dev{a} libmircookie2{a} libmircore-dev{a} libmircore1{a} 
  libmirprotobuf3{a} libpulse-dev{ab} libsdl2-dev libsndio-dev{a} 
  libxv-dev{a} 
0 个软件包被升级,新安装 16 个, 0 个将被删除, 同时 9 个将不升级。
需要获取 2,271 kB 的存档。 解包后将要使用 13.4 MB。
下列软件包存在未满足的依赖关系:
 libpulse-dev : 依赖: libpulse0 (= 1:11.1-1ubuntu7.2) but 1:11.1-1ubuntu7.3 is installed
                依赖: libpulse-mainloop-glib0 (= 1:11.1-1ubuntu7.2) but 1:11.1-1ubuntu7.3 is installed
下列动作将解决这些依赖关系:

     保持 下列软件包于其当前版本:
1)     libpulse-dev [未安装的]    
2)     libsdl2-dev [未安装的]     



是否接受该解决方案?[Y/n/q/?] n
下列动作将解决这些依赖关系:

     降级 下列软件包:                                                          
1)     libpulse-mainloop-glib0 [1:11.1-1ubuntu7.3 (now) -> 1:11.1-1ubuntu7.2 (bi
2)     libpulse0 [1:11.1-1ubuntu7.3 (now) -> 1:11.1-1ubuntu7.2 (bionic-updates)]
3)     libpulsedsp [1:11.1-1ubuntu7.3 (now) -> 1:11.1-1ubuntu7.2 (bionic-updates
4)     pulseaudio [1:11.1-1ubuntu7.3 (now) -> 1:11.1-1ubuntu7.2 (bionic-updates)
5)     pulseaudio-module-bluetooth [1:11.1-1ubuntu7.3 (now) -> 1:11.1-1ubuntu7.2
6)     pulseaudio-utils [1:11.1-1ubuntu7.3 (now) -> 1:11.1-1ubuntu7.2 (bionic-up



是否接受该解决方案?[Y/n/q/?] Y
下列软件包将被“降级”:
  libpulse-mainloop-glib0 libpulse0 libpulsedsp pulseaudio 
  pulseaudio-module-bluetooth pulseaudio-utils 
下列“新”软件包将被安装。
  libasound2-dev{a} libcapnp-0.6.1{a} libibus-1.0-dev{a} 
  libmirclient-dev{a} libmirclient9{a} libmircommon-dev{a} libmircommon7{a} 
  libmircookie-dev{a} libmircookie2{a} libmircore-dev{a} libmircore1{a} 
  libmirprotobuf3{a} libpulse-dev{a} libsdl2-dev libsndio-dev{a} 
  libxv-dev{a} 
0 个软件包被升级,新安装 16 个, 6 个被降级, 0 个将被删除, 同时 9 个将不升级。
需要获取 3,506 kB 的存档。 解包后将要使用 13.4 MB。
您要继续吗?[Y/n/?] Y
读取: 1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates/main amd64 libasound2-dev amd64 1.1.3-5ubuntu0.2 [123 kB]
读取: 2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic/main amd64 libcapnp-0.6.1 amd64 0.6.1-1ubuntu1 [658 kB]
读取: 3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates/main amd64 libibus-1.0-dev amd64 1.5.17-3ubuntu5.2 [145 kB]
读取: 4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic/main amd64 libmircore1 amd64 0.31.1-0ubuntu1 [26.5 kB]
读取: 5 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic/main amd64 libmircommon7 amd64 0.31.1-0ubuntu1 [73.9 kB]
读取: 6 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic/main amd64 libmirprotobuf3 amd64 0.31.1-0ubuntu1 [127 kB]
读取: 7 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic/main amd64 libmirclient9 amd64 0.31.1-0ubuntu1 [199 kB]
读取: 8 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic/main amd64 libmircore-dev amd64 0.31.1-0ubuntu1 [21.7 kB]
读取: 9 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic/main amd64 libmircommon-dev amd64 0.31.1-0ubuntu1 [13.9 kB]
读取: 10 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic/main amd64 libmircookie2 amd64 0.31.1-0ubuntu1 [19.7 kB]
读取: 11 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic/main amd64 libmircookie-dev amd64 0.31.1-0ubuntu1 [4,392 B]
读取: 12 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic/main amd64 libmirclient-dev amd64 0.31.1-0ubuntu1 [47.8 kB]
读取: 13 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates/main amd64 pulseaudio-module-bluetooth amd64 1:11.1-1ubuntu7.2 [67.1 kB]
读取: 14 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates/main amd64 libpulsedsp amd64 1:11.1-1ubuntu7.2 [31.9 kB]
读取: 15 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates/main amd64 pulseaudio-utils amd64 1:11.1-1ubuntu7.2 [64.3 kB]
读取: 16 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates/main amd64 pulseaudio amd64 1:11.1-1ubuntu7.2 [785 kB]
读取: 17 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates/main amd64 libpulse-mainloop-glib0 amd64 1:11.1-1ubuntu7.2 [22.1 kB]
读取: 18 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates/main amd64 libpulse0 amd64 1:11.1-1ubuntu7.2 [265 kB]
读取: 19 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates/main amd64 libpulse-dev amd64 1:11.1-1ubuntu7.2 [81.5 kB]
读取: 20 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic/universe amd64 libsndio-dev amd64 1.1.0-3 [13.3 kB]
读取: 21 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic/main amd64 libxv-dev amd64 2:1.0.11-1 [32.5 kB]
读取: 22 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates/universe amd64 libsdl2-dev amd64 2.0.8+dfsg1-1ubuntu1.18.04.4 [683 kB]
已下载 3,506 kB,耗时 3秒 (1,144 kB/s)
正在选中未选择的软件包 libasound2-dev:amd64。
(正在读取数据库 ... 系统当前共安装有 355185 个文件和目录。)
正准备解包 .../00-libasound2-dev_1.1.3-5ubuntu0.2_amd64.deb  ...
正在解包 libasound2-dev:amd64 (1.1.3-5ubuntu0.2) ...
正在选中未选择的软件包 libcapnp-0.6.1:amd64。
正准备解包 .../01-libcapnp-0.6.1_0.6.1-1ubuntu1_amd64.deb  ...
正在解包 libcapnp-0.6.1:amd64 (0.6.1-1ubuntu1) ...
正在选中未选择的软件包 libibus-1.0-dev:amd64。
正准备解包 .../02-libibus-1.0-dev_1.5.17-3ubuntu5.2_amd64.deb  ...
正在解包 libibus-1.0-dev:amd64 (1.5.17-3ubuntu5.2) ...
正在选中未选择的软件包 libmircore1:amd64。
正准备解包 .../03-libmircore1_0.31.1-0ubuntu1_amd64.deb  ...
正在解包 libmircore1:amd64 (0.31.1-0ubuntu1) ...
正在选中未选择的软件包 libmircommon7:amd64。
正准备解包 .../04-libmircommon7_0.31.1-0ubuntu1_amd64.deb  ...
正在解包 libmircommon7:amd64 (0.31.1-0ubuntu1) ...
正在选中未选择的软件包 libmirprotobuf3:amd64。
正准备解包 .../05-libmirprotobuf3_0.31.1-0ubuntu1_amd64.deb  ...
正在解包 libmirprotobuf3:amd64 (0.31.1-0ubuntu1) ...
正在选中未选择的软件包 libmirclient9:amd64。
正准备解包 .../06-libmirclient9_0.31.1-0ubuntu1_amd64.deb  ...
正在解包 libmirclient9:amd64 (0.31.1-0ubuntu1) ...
正在选中未选择的软件包 libmircore-dev:amd64。
正准备解包 .../07-libmircore-dev_0.31.1-0ubuntu1_amd64.deb  ...
正在解包 libmircore-dev:amd64 (0.31.1-0ubuntu1) ...
正在选中未选择的软件包 libmircommon-dev:amd64。
正准备解包 .../08-libmircommon-dev_0.31.1-0ubuntu1_amd64.deb  ...
正在解包 libmircommon-dev:amd64 (0.31.1-0ubuntu1) ...
正在选中未选择的软件包 libmircookie2:amd64。
正准备解包 .../09-libmircookie2_0.31.1-0ubuntu1_amd64.deb  ...
正在解包 libmircookie2:amd64 (0.31.1-0ubuntu1) ...
正在选中未选择的软件包 libmircookie-dev:amd64。
正准备解包 .../10-libmircookie-dev_0.31.1-0ubuntu1_amd64.deb  ...
正在解包 libmircookie-dev:amd64 (0.31.1-0ubuntu1) ...
正在选中未选择的软件包 libmirclient-dev:amd64。
正准备解包 .../11-libmirclient-dev_0.31.1-0ubuntu1_amd64.deb  ...
正在解包 libmirclient-dev:amd64 (0.31.1-0ubuntu1) ...
dpkg: 警告: 即将把 pulseaudio-module-bluetooth 从 1:11.1-1ubuntu7.3 降级到 1:11.1-1ubuntu7.2
正准备解包 .../12-pulseaudio-module-bluetooth_1%3a11.1-1ubuntu7.2_amd64.deb  ...
正在将 pulseaudio-module-bluetooth (1:11.1-1ubuntu7.2) 解包到 (1:11.1-1ubuntu7.3) 上 ...
dpkg: 警告: 即将把 libpulsedsp:amd64 从 1:11.1-1ubuntu7.3 降级到 1:11.1-1ubuntu7.2
正准备解包 .../13-libpulsedsp_1%3a11.1-1ubuntu7.2_amd64.deb  ...
正在将 libpulsedsp:amd64 (1:11.1-1ubuntu7.2) 解包到 (1:11.1-1ubuntu7.3) 上 ...
dpkg: 警告: 即将把 pulseaudio-utils 从 1:11.1-1ubuntu7.3 降级到 1:11.1-1ubuntu7.2
正准备解包 .../14-pulseaudio-utils_1%3a11.1-1ubuntu7.2_amd64.deb  ...
正在将 pulseaudio-utils (1:11.1-1ubuntu7.2) 解包到 (1:11.1-1ubuntu7.3) 上 ...
dpkg: 警告: 即将把 pulseaudio 从 1:11.1-1ubuntu7.3 降级到 1:11.1-1ubuntu7.2
正准备解包 .../15-pulseaudio_1%3a11.1-1ubuntu7.2_amd64.deb  ...
正在将 pulseaudio (1:11.1-1ubuntu7.2) 解包到 (1:11.1-1ubuntu7.3) 上 ...
dpkg: 警告: 即将把 libpulse-mainloop-glib0:amd64 从 1:11.1-1ubuntu7.3 降级到 1:11.1-1ubuntu7.2
正准备解包 .../16-libpulse-mainloop-glib0_1%3a11.1-1ubuntu7.2_amd64.deb  ...
正在将 libpulse-mainloop-glib0:amd64 (1:11.1-1ubuntu7.2) 解包到 (1:11.1-1ubuntu7.3) 上 ...
dpkg: 警告: 即将把 libpulse0:amd64 从 1:11.1-1ubuntu7.3 降级到 1:11.1-1ubuntu7.2
正准备解包 .../17-libpulse0_1%3a11.1-1ubuntu7.2_amd64.deb  ...
正在将 libpulse0:amd64 (1:11.1-1ubuntu7.2) 解包到 (1:11.1-1ubuntu7.3) 上 ...
正在选中未选择的软件包 libpulse-dev:amd64。
正准备解包 .../18-libpulse-dev_1%3a11.1-1ubuntu7.2_amd64.deb  ...
正在解包 libpulse-dev:amd64 (1:11.1-1ubuntu7.2) ...
正在选中未选择的软件包 libsndio-dev:amd64。
正准备解包 .../19-libsndio-dev_1.1.0-3_amd64.deb  ...
正在解包 libsndio-dev:amd64 (1.1.0-3) ...
正在选中未选择的软件包 libxv-dev:amd64。
正准备解包 .../20-libxv-dev_2%3a1.0.11-1_amd64.deb  ...
正在解包 libxv-dev:amd64 (2:1.0.11-1) ...
正在选中未选择的软件包 libsdl2-dev:amd64。
正准备解包 .../21-libsdl2-dev_2.0.8+dfsg1-1ubuntu1.18.04.4_amd64.deb  ...
正在解包 libsdl2-dev:amd64 (2.0.8+dfsg1-1ubuntu1.18.04.4) ...
正在设置 libasound2-dev:amd64 (1.1.3-5ubuntu0.2) ...
正在设置 libmircore-dev:amd64 (0.31.1-0ubuntu1) ...
正在设置 libmirprotobuf3:amd64 (0.31.1-0ubuntu1) ...
正在设置 libsndio-dev:amd64 (1.1.0-3) ...
正在设置 libpulse0:amd64 (1:11.1-1ubuntu7.2) ...
正在设置 libmircookie2:amd64 (0.31.1-0ubuntu1) ...
正在设置 libibus-1.0-dev:amd64 (1.5.17-3ubuntu5.2) ...
正在设置 libxv-dev:amd64 (2:1.0.11-1) ...
正在设置 libcapnp-0.6.1:amd64 (0.6.1-1ubuntu1) ...
正在设置 libmircore1:amd64 (0.31.1-0ubuntu1) ...
正在设置 libpulse-mainloop-glib0:amd64 (1:11.1-1ubuntu7.2) ...
正在设置 libpulse-dev:amd64 (1:11.1-1ubuntu7.2) ...
正在设置 libpulsedsp:amd64 (1:11.1-1ubuntu7.2) ...
正在设置 pulseaudio-utils (1:11.1-1ubuntu7.2) ...
正在设置 libmircookie-dev:amd64 (0.31.1-0ubuntu1) ...
正在设置 libmircommon7:amd64 (0.31.1-0ubuntu1) ...
正在设置 pulseaudio (1:11.1-1ubuntu7.2) ...
正在设置 libmirclient9:amd64 (0.31.1-0ubuntu1) ...
正在设置 pulseaudio-module-bluetooth (1:11.1-1ubuntu7.2) ...
正在设置 libmircommon-dev:amd64 (0.31.1-0ubuntu1) ...
正在设置 libmirclient-dev:amd64 (0.31.1-0ubuntu1) ...
正在设置 libsdl2-dev:amd64 (2.0.8+dfsg1-1ubuntu1.18.04.4) ...
正在处理用于 man-db (2.8.3-2ubuntu0.1) 的触发器 ...
正在处理用于 dbus (1.12.2-1ubuntu1.1) 的触发器 ...
正在处理用于 libc-bin (2.27-3ubuntu1) 的触发器 ...
/sbin/ldconfig.real: /usr/lib/ is not a symbolic link

这时候catkin_make发现竟然还是一样的

明明

asber@asber-X550VX:~/catkin_ws$ sudo apt install libsdl2-dev
正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
libsdl2-dev 已经是最新版 (2.0.8+dfsg1-1ubuntu1.18.04.4)。
升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 9 个软件包未被升级。

原来弄错了,是sudo apt-get install libsdl1.2-dev

然后发现:

asber@asber-X550VX:~/catkin_ws$ sudo apt-get install libsdl1.2-dev
正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
libsdl1.2-dev 已经是最新版 (1.2.15+dfsg2-0.1ubuntu0.1)。
升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 9 个软件包未被升级。
 

 

OK了但是还有另一个问题

 Could NOT find SDL_image (missing: SDL_IMAGE_LIBRARIES
  SDL_IMAGE_INCLUDE_DIRS)
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.10/Modules/FindSDL_image.cmake:91 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  navigation/map_server/CMakeLists.txt:13 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/asber/catkin_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/asber/catkin_ws/build/CMakeFiles/CMakeError.log".
Makefile:320: recipe for target 'cmake_check_build_system' failed
make: *** [cmake_check_build_system] Error 1
Invoking "make cmake_check_build_system" failed

SDL_image

sudo apt-get install libsdl-image1.2-dev 

然后

- Could NOT find amcl (missing: amcl_DIR)
-- Could not find the required component 'amcl'. The following CMake error indicates that you either need to install the package with the same name or change your environment so that it can be found.
CMake Error at /opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
  Could not find a package configuration file provided by "amcl" with any of
  the following names:

    amclConfig.cmake
    amcl-config.cmake

  Add the installation prefix of "amcl" to CMAKE_PREFIX_PATH or set
  "amcl_DIR" to a directory containing one of the above files.  If "amcl"
  provides a separate development package or SDK, be sure it has been
  installed.
Call Stack (most recent call first):
  ROS-Academy-for-Beginners/navigation_sim_demo/CMakeLists.txt:3 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/asber/catkin_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/asber/catkin_ws/build/CMakeFiles/CMakeError.log".
Makefile:320: recipe for target 'cmake_check_build_system' failed
make: *** [cmake_check_build_system] Error 1
Invoking "make cmake_check_build_system" failed

 就是這裡catkin_ws/src/ROS-Academy-for-Beginners/navigation_sim_demo/CMakeLists.txt

本来都一直报错觉得无望了,才在github的issue里面看到一句说melodic的用melodic的分支……我giao

报错的话参考:https://blog.csdn.net/weixin_42159320/article/details/87803532

超时就多来几次

然后依赖就安装好了,但是make的时候又出现

-- msgs_demo: 42 messages, 9 services
-- +++ processing catkin package: 'gmapping'
-- ==> add_subdirectory(ROS-Academy-for-Beginners/dependlib/slam_gmapping/gmapping)
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
CMake Error at /home/asber/catkin_ws/devel/share/tf2_ros/cmake/tf2_rosConfig.cmake:113 (message):
  Project 'tf2_ros' specifies
  '/home/asber/catkin_ws/src/geometry2/tf2_ros/include' as an include dir,
  which is not found.  It does neither exist as an absolute directory nor in
  '/home/asber/catkin_ws/src/geometry2/tf2_ros//home/asber/catkin_ws/src/geometry2/tf2_ros/include'.
  Check the website 'http://www.ros.org/wiki/tf2_ros' for information and
  consider reporting the problem.
Call Stack (most recent call first):
  /opt/ros/melodic/share/tf/cmake/tfConfig.cmake:197 (find_package)
  /opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:76 (find_package)
  ROS-Academy-for-Beginners/dependlib/slam_gmapping/gmapping/CMakeLists.txt:4 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/asber/catkin_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/asber/catkin_ws/build/CMakeFiles/CMakeError.log".
Invoking "cmake" failed

去github上找到https://github.com/ros/geometry2,git下来后报错消失

-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
CMake Error at /home/asber/catkin_ws/devel/share/map_server/cmake/map_serverConfig.cmake:113 (message):
  Project 'map_server' specifies
  '/home/asber/catkin_ws/src/navigation/map_server/include' as an include
  dir, which is not found.  It does neither exist as an absolute directory
  nor in
  '/home/asber/catkin_ws/src/navigation/map_server//home/asber/catkin_ws/src/navigation/map_server/include'.
  Check the website 'http://wiki.ros.org/map_server' for information and
  consider reporting the problem.
Call Stack (most recent call first):
  /opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:76 (find_package)
  ROS-Academy-for-Beginners/navigation_sim_demo/CMakeLists.txt:3 (find_package)

下navigation后出现

-- +++ processing catkin package: 'amcl'
-- ==> add_subdirectory(navigation/amcl)
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
-- Boost version: 1.65.1
CMake Error at /opt/ros/melodic/share/dynamic_reconfigure/cmake/dynamic_reconfigure-macros.cmake:80 (add_custom_target):
  add_custom_target cannot create target "amcl_gencfg" because another target
  with the same name already exists.  The existing target is a custom target
  created in source directory
  "/home/asber/catkin_ws/src/ROS-Academy-for-Beginners/navigation_sim_demo".
  See documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
  navigation/amcl/CMakeLists.txt:28 (generate_dynamic_reconfigure_options)

----


-- +++ processing catkin package: 'costmap_2d'
-- ==> add_subdirectory(navigation/costmap_2d)
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
-- Boost version: 1.65.1
-- Found the following Boost libraries:
--   system
--   thread
--   chrono
--   date_time
--   atomic
-- costmap_2d: 1 messages, 0 services
CMake Error at /home/asber/catkin_ws/build/navigation/costmap_2d/cmake/costmap_2d-genmsg.cmake:46 (add_custom_target):
  add_custom_target cannot create target "costmap_2d_generate_messages_cpp"
  because another target with the same name already exists.  The existing
  target is a custom target created in source directory
  "/home/asber/catkin_ws/src/ROS-Academy-for-Beginners/navigation_sim_demo".
  See documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
  /opt/ros/melodic/share/genmsg/cmake/genmsg-extras.cmake:307 (include)
  navigation/costmap_2d/CMakeLists.txt:44 (generate_messages)
CMake Error at /home/asber/catkin_ws/build/navigation/costmap_2d/cmake/costmap_2d-genmsg.cmake:79 (add_custom_target):
  add_custom_target cannot create target "costmap_2d_generate_messages_eus"
  because another target with the same name already exists.  The existing
  target is a custom target created in source directory
  "/home/asber/catkin_ws/src/ROS-Academy-for-Beginners/navigation_sim_demo".
  See documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
  /opt/ros/melodic/share/genmsg/cmake/genmsg-extras.cmake:307 (include)
  navigation/costmap_2d/CMakeLists.txt:44 (generate_messages)


CMake Error at /home/asber/catkin_ws/build/navigation/costmap_2d/cmake/costmap_2d-genmsg.cmake:112 (add_custom_target):
  add_custom_target cannot create target "costmap_2d_generate_messages_lisp"
  because another target with the same name already exists.  The existing
  target is a custom target created in source directory
  "/home/asber/catkin_ws/src/ROS-Academy-for-Beginners/navigation_sim_demo".
  See documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
  /opt/ros/melodic/share/genmsg/cmake/genmsg-extras.cmake:307 (include)
  navigation/costmap_2d/CMakeLists.txt:44 (generate_messages)


CMake Error at /home/asber/catkin_ws/build/navigation/costmap_2d/cmake/costmap_2d-genmsg.cmake:145 (add_custom_target):
  add_custom_target cannot create target
  "costmap_2d_generate_messages_nodejs" because another target with the same
  name already exists.  The existing target is a custom target created in
  source directory
  "/home/asber/catkin_ws/src/ROS-Academy-for-Beginners/navigation_sim_demo".
  See documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
  /opt/ros/melodic/share/genmsg/cmake/genmsg-extras.cmake:307 (include)
  navigation/costmap_2d/CMakeLists.txt:44 (generate_messages)


CMake Error at /home/asber/catkin_ws/build/navigation/costmap_2d/cmake/costmap_2d-genmsg.cmake:178 (add_custom_target):
  add_custom_target cannot create target "costmap_2d_generate_messages_py"
  because another target with the same name already exists.  The existing
  target is a custom target created in source directory
  "/home/asber/catkin_ws/src/ROS-Academy-for-Beginners/navigation_sim_demo".
  See documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
  /opt/ros/melodic/share/genmsg/cmake/genmsg-extras.cmake:307 (include)
  navigation/costmap_2d/CMakeLists.txt:44 (generate_messages)


----
-- +++ processing catkin package: 'base_local_planner'
-- ==> add_subdirectory(navigation/base_local_planner)
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
-- Boost version: 1.65.1
-- Found the following Boost libraries:
--   thread
--   chrono
--   system
--   date_time
--   atomic
-- base_local_planner: 1 messages, 0 services
CMake Error at /home/asber/catkin_ws/build/navigation/base_local_planner/cmake/base_local_planner-genmsg.cmake:46 (add_custom_target):
  add_custom_target cannot create target
  "base_local_planner_generate_messages_cpp" because another target with the
  same name already exists.  The existing target is a custom target created
  in source directory
  "/home/asber/catkin_ws/src/ROS-Academy-for-Beginners/navigation_sim_demo".
  See documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
  /opt/ros/melodic/share/genmsg/cmake/genmsg-extras.cmake:307 (include)
  navigation/base_local_planner/CMakeLists.txt:48 (generate_messages)


CMake Error at /home/asber/catkin_ws/build/navigation/base_local_planner/cmake/base_local_planner-genmsg.cmake:79 (add_custom_target):
  add_custom_target cannot create target
  "base_local_planner_generate_messages_eus" because another target with the
  same name already exists.  The existing target is a custom target created
  in source directory
  "/home/asber/catkin_ws/src/ROS-Academy-for-Beginners/navigation_sim_demo".
  See documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
  /opt/ros/melodic/share/genmsg/cmake/genmsg-extras.cmake:307 (include)
  navigation/base_local_planner/CMakeLists.txt:48 (generate_messages)


CMake Error at /home/asber/catkin_ws/build/navigation/base_local_planner/cmake/base_local_planner-genmsg.cmake:112 (add_custom_target):
  add_custom_target cannot create target
  "base_local_planner_generate_messages_lisp" because another target with the
  same name already exists.  The existing target is a custom target created
  in source directory
  "/home/asber/catkin_ws/src/ROS-Academy-for-Beginners/navigation_sim_demo".
  See documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
  /opt/ros/melodic/share/genmsg/cmake/genmsg-extras.cmake:307 (include)
  navigation/base_local_planner/CMakeLists.txt:48 (generate_messages)


CMake Error at /home/asber/catkin_ws/build/navigation/base_local_planner/cmake/base_local_planner-genmsg.cmake:145 (add_custom_target):
  add_custom_target cannot create target
  "base_local_planner_generate_messages_nodejs" because another target with
  the same name already exists.  The existing target is a custom target
  created in source directory
  "/home/asber/catkin_ws/src/ROS-Academy-for-Beginners/navigation_sim_demo".
  See documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
  /opt/ros/melodic/share/genmsg/cmake/genmsg-extras.cmake:307 (include)
  navigation/base_local_planner/CMakeLists.txt:48 (generate_messages)


CMake Error at /home/asber/catkin_ws/build/navigation/base_local_planner/cmake/base_local_planner-genmsg.cmake:178 (add_custom_target):
  add_custom_target cannot create target
  "base_local_planner_generate_messages_py" because another target with the
  same name already exists.  The existing target is a custom target created
  in source directory
  "/home/asber/catkin_ws/src/ROS-Academy-for-Beginners/navigation_sim_demo".
  See documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
  /opt/ros/melodic/share/genmsg/cmake/genmsg-extras.cmake:307 (include)
  navigation/base_local_planner/CMakeLists.txt:48 (generate_messages)

最后换了kinetic,顺利

 

ROBOWARE的IDE

http://www.mamicode.com/info-detail-2771326.html

(PS:aptget得到的程序一般是以二进制文件形式的,是编译好的,而从github上找,一般需要编译之后运行,方便改进源码)

 

第二节课:ROS工程结构

 catkin是用来编译ros程序的,所有文件子目录

这个文件夹如下命令建立

asber@asber-X550VX:~/projects/ros$ mkdir -p ~/catkin_ws/src
asber@asber-X550VX:~/projects/ros$ cd ~/catkin_ws
asber@asber-X550VX:~/catkin_ws$ catkin_make
....中间省
-- BUILD_SHARED_LIBS is on
-- Configuring done
-- Generating done
-- Build files have been written to: /home/asber/catkin_ws/build
####
#### Running command: "make -j4 -l4" in "/home/asber/catkin_ws/build"
####

catkin_make除了建立工作空间还有编译的功能,写完代码使用

最后一句话作用是将编译完的workspace刷新到环境变量去,系统才知道我们生成的ros可执行文件放在哪里,才可以运行!

src是真正写代码的地方

src--功能包

package是catkin编译的基本单元

catkin递归编译package

package组成

package是ROS的细胞,ROS的基本组织形式,但是一个package可以包含多个可执行文件(节点)

package必然包含

对cmake的语法还是很不熟悉的话,可以读一下cmake实践这本书:https://vdisk.weibo.com/s/9dFPlKvfPEf?sudaref=www.baidu.com

只需要对cmake每一条指令有印象就可以

因为cmake可以系统生成,如果编译出问题,多半和cmake以及依赖相关

package.xml

一般修改红线处信息:

代码

scripts放这些脚本文件

scr还可以放被import的python包

除了上面的,package还可以放这些文件

除了代码、通信文件,还可以有

launch的作用是一次性执行多个可执行文件

配置文件 配置的是参数、路径等,内容格式自由度高,现在大多数配置文件使用yaml

 

总的来说

ROS包管理的常用指令

pkg是package的缩写

操作演示:Catkin工作空间探索

catkin_create_pkg test2 roscpp rospy std_msgs nav_msgs

这句话创建test2名字的package 并且依赖roscpp rospy std_msgs nav_msgs

rosdep是如何知道所需要依赖的:根据每个包底下的package.xml

我们rosdep好了之后使用catkin_make然后需要source ~/catkin_ws/devel/setup.bash

但是这个命令只能在一次终端起作用,所以我们会echo "source ~/catkin_ws/devel/setup.bash">> ~/.bashrc

加入到环境变量

Metapackage

依赖包集合,比如ros的navigation就是metapackage

作用是安装更方便,比如可以直接用apt-get的方式

sudo apt-get install ros-版本名-navigation 安装其二进制软件包

常见matapackage

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值