Chapter 1. ROS 创建工作空间

1. 创建catkin工作空间
~$ mkdir -p ros_workspace/src
2. 编译catkin工作空间
~$ cd ros_workspace
~/ros_workspace$ catkin_make

编译成功后,显示如下内容:

Base path: /home/nic/ros_workspace
Source space: /home/nic/ros_workspace/src
Build space: /home/nic/ros_workspace/build
Devel space: /home/nic/ros_workspace/devel
Install space: /home/nic/ros_workspace/install
Creating symlink "/home/nic/ros_workspace/src/CMakeLists.txt" pointing to "/opt/ros/kinetic/share/catkin/cmake/toplevel.cmake"
####
#### Running command: "cmake /home/nic/ros_workspace/src -DCATKIN_DEVEL_PREFIX=/home/nic/ros_workspace/devel -DCMAKE_INSTALL_PREFIX=/home/nic/ros_workspace/install -G Unix Makefiles" in "/home/nic/ros_workspace/build"
####
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.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/nic/ros_workspace/devel
-- Using CMAKE_PREFIX_PATH: /opt/ros/kinetic
-- This workspace overlays: /opt/ros/kinetic
-- Found PythonInterp: /usr/bin/python (found version "2.7.12") 
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/nic/ros_workspace/build/test_results
-- Found gmock sources under '/usr/src/gmock': gmock will be built
-- 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  
-- Found gtest sources under '/usr/src/gmock': gtests will be built
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.11
-- BUILD_SHARED_LIBS is on
-- Configuring done
-- Generating done
-- Build files have been written to: /home/nic/ros_workspace/build
####
#### Running command: "make -j4 -l4" in "/home/nic/ros_workspace/build"
####
3. 配置环境变量
~/ros_workspace$ source ./devel/setup.bash

最后还要在~/.bashrc文件的末尾添加命令行,来配置我们的环境,如下, 如果在安装ROS时已经配置了,那就不需要配置了,此处的ROS版本是ROS kinetic,如果要使用其他版本的,请自行更改。

$ echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
4. 验证配置

如果工作空间已配置正确,需确保ROS_PACKAGE_PATH环境变量包含工作空间目录,采用以下命令查看:

~/ros_workspace$ echo $ROS_PACKAGE_PATH

返回提示:

/home/nic/ros_workspace/src:/opt/ros/kinetic/share
5. 到此,ROS的工作环境已经搭建完成,接下来继续…

你可能感兴趣的:(机器人ROS,基础)