ROS kinetic 创建功能包

同一个工作空间下,不允许存在同名功能包;
不同工作空间下,允许存在同名的功能包。

创建功能包命令
        catkin_create_pkg [depend1] [depend2] [depend3]

操作方式
kinetic@vm:~/catkin_ws$ cd ~/catkin_ws/src
kinetic@vm:~/catkin_ws/src$ catkin_create_pkg learning_communication std_msgs rospy roscpp
Created file learning_communication/CMakeLists.txt
Created file learning_communication/package.xml
Created folder learning_communication/include/learning_communication
Created folder learning_communication/src
Successfully created files in /home/kinetic/catkin_ws/src/learning_communication. Please adjust the values in package.xml.


kinetic@vm:~/catkin_ws/src$ tree
.
├── CMakeLists.txt -> /opt/ros/kinetic/share/catkin/cmake/toplevel.cmake
└── learning_communication
    ├── CMakeLists.txt   放置如何去编译功能包的编译选项
    ├── include
    │   └── learning_communication
    ├── package.xml    描述功能包的具体信息,如功能包名字、版本、维护者,功能包的依赖关系
    └── src
4 directories, 3 files


package.xml    下面是声明功能包依赖那些功能包

  catkin
  roscpp
  rospy
  std_msgs
  roscpp
  rospy
  std_msgs
  roscpp
  rospy
  std_msgs

编译功能包
kinetic@vm:~/catkin_ws/src$ cd ~/catkin_ws/
kinetic@vm:~/catkin_ws$ catkin_make
Source space: /home/kinetic/catkin_ws/src
Build space: /home/kinetic/catkin_ws/build
Devel space: /home/kinetic/catkin_ws/devel
Install space: /home/kinetic/catkin_ws/install
####
#### Running command: "cmake /home/kinetic/catkin_ws/src -DCATKIN_DEVEL_PREFIX=/home/kinetic/catkin_ws/devel -DCMAKE_INSTALL_PREFIX=/home/kinetic/catkin_ws/install -G Unix Makefiles" in "/home/kinetic/catkin_ws/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/kinetic/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /home/kinetic/catkin_ws/devel;/opt/ros/kinetic
-- This workspace overlays: /home/kinetic/catkin_ws/devel;/opt/ros/kinetic
-- 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/kinetic/catkin_ws/build/test_results
-- Found gmock sources under '/usr/src/gmock': gmock will be built
-- 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
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~  traversing 1 packages in topological order:
-- ~~  - learning_communication

-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'learning_communication'
-- ==> add_subdirectory(learning_communication)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/kinetic/catkin_ws/build
####
#### Running command: "make -j4 -l4" in "/home/kinetic/catkin_ws/build"
####

查看ROS相关的环境变量
kinetic@vm:~$ env | grep ros
ROS_ROOT=/opt/ros/kinetic/share/ros
ROS_PACKAGE_PATH=/home/kinetic/catkin_ws/src:/opt/ros/kinetic/share
LD_LIBRARY_PATH=/home/kinetic/catkin_ws/devel/lib:/opt/ros/kinetic/lib:/opt/ros/kinetic/lib/x86_64-linux-gnu
PATH=/opt/ros/kinetic/bin:/home/kinetic/bin:/home/kinetic/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
PYTHONPATH=/opt/ros/kinetic/lib/python2.7/dist-packages
PKG_CONFIG_PATH=/opt/ros/kinetic/lib/pkgconfig:/opt/ros/kinetic/lib/x86_64-linux-gnu/pkgconfig
CMAKE_PREFIX_PATH=/home/kinetic/catkin_ws/devel:/opt/ros/kinetic
ROS_ETC_DIR=/opt/ros/kinetic/etc/ros

ROS 运行时如何查找功能包?
        在 ROS_PACKAGE_PATH 路径下按先后顺序查找,如果找到了就不在继续往下查找。如果不存在继续往后查找。
        新设置的 
ROS_PACKAGE_PATH  会自动放在最前端

查找功能包
kinetic@vm:~$
rospack find learning_communication
/home/kinetic/catkin_ws/src/learning_communication

kinetic@vm:~$ rospack find roscpp_tutorials 
/opt/ros/kinetic/share/roscpp_tutorials

安装例程
ubuntu@T430:~/catkin_ws$ sudo apt-get install ros-kinetic-roscpp-tutorials


你可能感兴趣的:(ROS)