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

在这里插入图片描述

简单理解

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

  • 6
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Loading_create

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值