ROS--5Packages & Catkin Workspaces

Catkin工作空间本质上是一个目录,可以在这里编写、修改并安装catkin包,通常当你开发基于ROS的机器人或项目时,你需要在单独的工作空间里完成。这个单独的空间需要保存大量不同的catkin包,所有ROS软件组件都以catkin包的形式组织并发布。

Catkin包可能包含节点的源代码,有用的脚本、配置文件等等。


1.Create a Catkin Workspace

Step 1: mkdir -p ~/catkin_ws/src

$ mkdir -p ~/catkin_ws/src

 

Step 2:

$ mkdir -p ~/catkin_ws/src

 

Step3:

$ catkin_init_workspace

 

Step4:

$ cd ~/catkin_ws

 

Step5:

$ catkin_make

 

More in

http://wiki.ros.org/catkin/conceptual_overview

You now have two new directories: build and devel. The aptly named build directory is the build space for C++ packages and, for the most part, you will not interact with it. The devel directory does contain something of interest, a file named setup.bash. This setup.bash script must be sourced before using the catkin workspace.

 

2Add a package

step1:Cloning the simple_arm Package

One of the biggest benefits of using ROS is that it has a really large community of users and developers, so there is a lot of code that you can use.

$ cd ~/catkin_ws/src
$ git clone https://github.com/udacity/simple_arm_01.git simple_arm

step2: Building the simple_arm package

After the repo has finished cloning, you can change directory to the top-level of the ros workspace and build the new package.

$ cd ~/catkin_ws
$ catkin_make

step3: Launch multiple nodes

roslaunch allows you to do the following

  • Launch ROS Master and multiple nodes with one simple command
  • Set default parameters on the parameter server
  • Automatically re-spawn processes that have died

Once the workspace has been built, you can source it’s setup script:

$ source devel/setup.bash

With your workspace sourced you can now launch simple_arm:

$ roslaunch simple_arm robot_spawn.launch

 

3.rosdep 自动检查依赖库

After the last exercise, you might have noticed the following warning line:

The controller spawner couldn’t find the expected controller_manager ROS interface.

ROS packages have two different types of dependencies: build dependencies, and run dependencies. This error message was due to a missing runtime dependency.

The rosdep tool will check for a package's missing dependencies, download them, and install them.

To check for missing dependencies in the simple_arm package:

$ rosdep check simple_arm

 

To have rosdep install packages, invoke the following command from the root of the catkin workspace

$ rosdep install -i simple_arm

Issues with this command may arise when using a VM. If this is the case, please try:

sudo apt-get install ros-kinetic-gazebo-ros-control

Dive Deeper into Packages

$ cd ~/catkin_ws/src

The syntax for creating a catkin package is simply,

$ catkin_create_pkg <your_package_name> [dependency1 dependency2 …]

 

$ catkin_create_pkg first_package

I mentioned earlier that ROS packages have a conventional directory structure. Let’s take a look at a more typical package.

  • scripts (python executables)
  • src (C++ source files)
  • msg (for custom message definitions)
  • srv (for service message definitions)
  • include -> headers/libraries that are needed as dependencies
  • config -> configuration files
  • launch -> provide a more automated way of starting nodes

Other folders may include

  • urdf (Universal Robot Description Files)
  • meshes (CAD files in .dae (Collada) or .stl (STereoLithography) format)
  • worlds (XML like files that are used for Gazebo simulation environments)

There are many packages that you can install. To see a list of available packages for the Kinetic distribution, take some time to explore here.

https://www.ros.org/browse/list.php

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值