ROS快速入门第一讲——ROS的工作空间创建

简介: ROS快速入门第一讲——ROS的工作空间创建

ROS的工作空间创建


scc18@ubuntu:~$ mkdir ros_ws
scc18@ubuntu:~$ cd ros_ws/
scc18@ubuntu:~/ros_ws$ mkdir src
scc18@ubuntu:~/ros_ws$ cd src
scc18@ubuntu:~/ros_ws/src$ catkin_init_workspace 
Creating symlink "/home/scc18/ros_ws/src/CMakeLists.txt" pointing to "/opt/ros/melodic/share/catkin/cmake/toplevel.cmake"
scc18@ubuntu:~/ros_ws/src$ cd ..
scc18@ubuntu:~/ros_ws$ catkin_make
Base path: /home/scc18/ros_ws
Source space: /home/scc18/ros_ws/src
Build space: /home/scc18/ros_ws/build
Devel space: /home/scc18/ros_ws/devel
Install space: /home/scc18/ros_ws/install
####
#### Running command: "cmake /home/scc18/ros_ws/src -DCATKIN_DEVEL_PREFIX=/home/scc18/ros_ws/devel -DCMAKE_INSTALL_PREFIX=/home/scc18/ros_ws/install -G Unix Makefiles" in "/home/scc18/ros_ws/build"
####
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using CATKIN_DEVEL_PREFIX: /home/scc18/ros_ws/devel
-- Using CMAKE_PREFIX_PATH: /opt/ros/melodic
-- This workspace overlays: /opt/ros/melodic
-- Found PythonInterp: /usr/bin/python2 (found suitable version "2.7.17", minimum required is "2") 
-- Using PYTHON_EXECUTABLE: /usr/bin/python2
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/scc18/ros_ws/build/test_results
-- Found gtest sources under '/usr/src/googletest': gtests will be built
-- Found gmock sources under '/usr/src/googletest': gmock will be built
-- Found PythonInterp: /usr/bin/python2 (found version "2.7.17") 
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.29
-- BUILD_SHARED_LIBS is on
-- BUILD_SHARED_LIBS is on
-- Configuring done
-- Generating done
-- Build files have been written to: /home/scc18/ros_ws/build
####
#### Running command: "make -j2 -l2" in "/home/scc18/ros_ws/build"
####
scc18@ubuntu:~/ros_ws$ catkin_make install
Base path: /home/scc18/ros_ws
Source space: /home/scc18/ros_ws/src
Build space: /home/scc18/ros_ws/build
Devel space: /home/scc18/ros_ws/devel
Install space: /home/scc18/ros_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/scc18/ros_ws/build"
####
####
#### Running command: "make install -j2 -l2" in "/home/scc18/ros_ws/build"
####
Install the project...
-- Install configuration: ""
-- Installing: /home/scc18/ros_ws/install/_setup_util.py
-- Installing: /home/scc18/ros_ws/install/env.sh
-- Installing: /home/scc18/ros_ws/install/setup.bash
-- Installing: /home/scc18/ros_ws/install/local_setup.bash
-- Installing: /home/scc18/ros_ws/install/setup.sh
-- Installing: /home/scc18/ros_ws/install/local_setup.sh
-- Installing: /home/scc18/ros_ws/install/setup.zsh
-- Installing: /home/scc18/ros_ws/install/local_setup.zsh
-- Installing: /home/scc18/ros_ws/install/.rosinstall
scc18@ubuntu:~/ros_ws$ source devel/setup.bash 
scc18@ubuntu:~/ros_ws$ cd src
scc18@ubuntu:~/ros_ws/src$ catkin_create_pkg test std_msgs rospy roscpp
Created file test/CMakeLists.txt
Created file test/package.xml
Created folder test/include/test
Created folder test/src
Successfully created files in /home/scc18/ros_ws/src/test. Please adjust the values in package.xml.
scc18@ubuntu:~/ros_ws/src$ ls
CMakeLists.txt  test
scc18@ubuntu:~/ros_ws/src$ cd test/
scc18@ubuntu:~/ros_ws/src/test$ ls
CMakeLists.txt  include  package.xml  src
scc18@ubuntu:~/ros_ws/src/test$ cd ..
scc18@ubuntu:~/ros_ws/src$ cd ..
scc18@ubuntu:~/ros_ws$ catkin_make
Base path: /home/scc18/ros_ws
Source space: /home/scc18/ros_ws/src
Build space: /home/scc18/ros_ws/build
Devel space: /home/scc18/ros_ws/devel
Install space: /home/scc18/ros_ws/install
####
#### Running command: "cmake /home/scc18/ros_ws/src -DCATKIN_DEVEL_PREFIX=/home/scc18/ros_ws/devel -DCMAKE_INSTALL_PREFIX=/home/scc18/ros_ws/install -G Unix Makefiles" in "/home/scc18/ros_ws/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/scc18/ros_ws/devel
-- Using CMAKE_PREFIX_PATH: /home/scc18/ros_ws/devel;/opt/ros/melodic
-- This workspace overlays: /home/scc18/ros_ws/devel;/opt/ros/melodic
-- Found PythonInterp: /usr/bin/python2 (found suitable version "2.7.17", minimum required is "2") 
-- Using PYTHON_EXECUTABLE: /usr/bin/python2
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/scc18/ros_ws/build/test_results
-- Found gtest sources under '/usr/src/googletest': gtests will be built
-- Found gmock sources under '/usr/src/googletest': gmock will be built
-- Found PythonInterp: /usr/bin/python2 (found version "2.7.17") 
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.29
-- BUILD_SHARED_LIBS is on
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~  traversing 1 packages in topological order:
-- ~~  - test
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'test'
-- ==> add_subdirectory(test)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/scc18/ros_ws/build
####
#### Running command: "make -j2 -l2" in "/home/scc18/ros_ws/build"
####
scc18@ubuntu:~/ros_ws$ catkin_make install
Base path: /home/scc18/ros_ws
Source space: /home/scc18/ros_ws/src
Build space: /home/scc18/ros_ws/build
Devel space: /home/scc18/ros_ws/devel
Install space: /home/scc18/ros_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/scc18/ros_ws/build"
####
####
#### Running command: "make install -j2 -l2" in "/home/scc18/ros_ws/build"
####
Install the project...
-- Install configuration: ""
-- Installing: /home/scc18/ros_ws/install/_setup_util.py
-- Up-to-date: /home/scc18/ros_ws/install/env.sh
-- Up-to-date: /home/scc18/ros_ws/install/setup.bash
-- Up-to-date: /home/scc18/ros_ws/install/local_setup.bash
-- Up-to-date: /home/scc18/ros_ws/install/setup.sh
-- Up-to-date: /home/scc18/ros_ws/install/local_setup.sh
-- Up-to-date: /home/scc18/ros_ws/install/setup.zsh
-- Up-to-date: /home/scc18/ros_ws/install/local_setup.zsh
-- Up-to-date: /home/scc18/ros_ws/install/.rosinstall
-- Installing: /home/scc18/ros_ws/install/lib/pkgconfig/test.pc
-- Installing: /home/scc18/ros_ws/install/share/test/cmake/testConfig.cmake
-- Installing: /home/scc18/ros_ws/install/share/test/cmake/testConfig-version.cmake
-- Installing: /home/scc18/ros_ws/install/share/test/package.xml

image.png

简单理解


mkdir filename/src


这句话就是在创建一个简单的文件夹,目前在创建之后,并没有任何的意义,但是如果我们进行rosinit的操作之后就会变成一个工作空间。

catkin_init_workspace


这句话必须要在src文件目录下使用,这样会将src下改变成为一个工作空间。

catkin_make


这句话要求在ros的根目录,也就是我们创建的filename那个文件夹。(具体叫啥名自己看着办)。这样就是一个编译,其实意思跟我们的C++的编译类似。但是我们现在编译没有啥用处,就是编译了一个空项目。

catkin_make install


这句话会生成一个install文件夹,但是也没啥用,以后会有的。现在就是先试试,看看文件有啥问题没。

catkin_create_pkg


catkin_create_pkg test std_msgs rospy roscpp 一般来说的话就是这么去写,但是其实这句话的真正含义是,创建一个pkg,叫做test,然后倒入ros基本的信息发布包,以及python包和C++包。

source devel/setup.bash


这句话就是设置一下环境变量。要注意的是devel是在我们filename的文件夹下面的。

结尾


这就是ROS创建一个工作空间的简单操作,我觉得没什么难度,只要好好多练习,这些都属于基本功。用完删除,再创建一个也无妨。

相关实践学习
使用ROS创建VPC和VSwitch
本场景主要介绍如何利用阿里云资源编排服务,定义资源编排模板,实现自动化创建阿里云专有网络和交换机。
ROS入门实践
本课程将基于基础设施即代码 IaC 的理念,介绍阿里云自动化编排服务ROS的概念、功能和使用方式,并通过实际应用场景介绍如何借助ROS实现云资源的自动化部署,使得云上资源部署和运维工作更为高效。
相关文章
|
IDE Linux 开发工具
[ROS基础] --- 创建工作空间
[ROS基础] --- 创建工作空间
787 0
|
Unix Java C++
ROS快速入门使用
ROS快速入门使用
904 0
ROS快速入门使用
|
存储 缓存
02 ROS创建工作空间和功能包
如何在ROS中创建工作空间和功能包,包括初始化工作空间、编译、设置环境变量以及使用`catkin_create_pkg`创建新功能包的步骤。
1285 1
|
机器人 Shell 开发者
ROS2教程08 ROS2的功能包、依赖管理、工作空间配置与编译
这篇文章是关于ROS2(Robot Operating System 2)中功能包、依赖管理、工作空间配置和编译的教程,涵盖了ROS2工作空间的概念、如何获取和安装功能包的依赖、构建工作空间的步骤,以及如何创建和管理ROS2功能包,包括使用命令行工具对功能包进行操作的方法。
4126 0
ROS2教程08 ROS2的功能包、依赖管理、工作空间配置与编译
|
存储 缓存 机器人
ROS2教程 01 创建工作空间
本文是关于如何在ROS2(机器人操作系统2)中创建和管理工作空间的教程,介绍了工作空间的概念、ROS1与ROS2工作空间的区别、创建工作空间的步骤,包括建立工作空间文件夹、更新包依赖、编译工作空间以及设置环境变量以便于调用新生成的文件和脚本。
1933 0
|
机器人
ROS快速入门第三讲——ROS的Subscriber订阅者
ROS快速入门第三讲——ROS的Subscriber订阅者
718 0
ROS快速入门第三讲——ROS的Subscriber订阅者
|
C++ 计算机视觉 Python
ROS快速入门第二讲——ROS的Publisher发布者
ROS快速入门第二讲——ROS的Publisher发布者
396 0
ROS快速入门第二讲——ROS的Publisher发布者
ROS创建工作空间添加包并编译
ROS创建工作空间添加包并编译
779 0
|
机器学习/深度学习 前端开发 机器人
ubuntu16.04下ROS操作系统学习笔记(三 / 一)ROS基础-工作空间
ubuntu16.04下ROS操作系统学习笔记(三 / 一)ROS基础-工作空间
882 0
|
存储
【古月21讲】ROS入门系列(1)——ROS命令工具的使用及创建工作空间和功能包
【古月21讲】ROS入门系列(1)——ROS命令工具的使用及创建工作空间和功能包
781 0
【古月21讲】ROS入门系列(1)——ROS命令工具的使用及创建工作空间和功能包

推荐镜像

更多
  • ros