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

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

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

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/789113.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-05
下一篇 2022-05-05

发表评论

登录后才能评论

评论列表(0条)

保存