ROS基础完整教程
1. 创建catkin工作空间
...
mkdir -p ~/catkin_car/src
...
其中 -p 代表的是创建多级文件夹,如上所示,创建的是catkin_car与src这两个文件夹,并且src是在catkin_car之下
2. 编译工作空间
回到catkin_car 文件夹下,使用
catkin_make
对catkin工作空间进行编译
3. 环境变量配置
ros中在创建catkin工作空间后,要想与ros进行连接,必须使得ros环境置顶,才能使用ros的变量,因此使用如下命令,使得环境变量配置
source devel/setup.bash
使用如下命令查看环境变量配置
export | grep ROS
// 其中grep 代表的意思是搜寻含有ROS关键词所在的命令
或者
echo $ROS_PAKCAGE_PATH
// echo 代表的是打印当前的内容
4. 创建ros程序包
使用如下命令创建
cd src
catkin_create_pkg formcar roscpp rospy // 其中 makecar是程序包的名字,roscpp是使用c++必备的包名字,rospy 是使用python 的必须的包
5. 自定义自己的消息文件
在包中创建msg文件夹,并创建.msg文件
mkdir msg
mkdir src
<?xml version="1.0"?>
<package format="2">
<name>formcar</name>
<version>0.0.0</version>
<description>The formcar package</description>
<!-- One maintainer tag required, multiple allowed, one person per tag -->
<!-- Example: -->
<!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> -->
<maintainer email="macl@todo.todo">macl</maintainer>
<!-- One license tag required, multiple allowed, one license per tag -->
<!-- Commonly used license strings: -->
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
<license>TODO</license>
<!-- Url tags are optional, but multiple are allowed, one per tag -->
<!-- Optional attribute type can be: website, bugtracker, or repository -->
<!-- Example: -->
<!-- <url type="website">http://wiki.ros.org/formcar</url> -->
<!-- Author tags are optional, multiple are allowed, one per tag -->
<!-- Authors do not have to be maintainers, but could be -->
<!-- Example: -->
<!-- <author email="jane.doe@example.com">Jane Doe</author> -->
<!-- The *depend tags are used to specify dependencies -->
<!-- Dependencies can be catkin packages or system dependencies -->
<!-- Examples: -->
<!-- Use depend as a shortcut for packages that are both build and exec dependencies -->
<!-- <depend>roscpp</depend> -->
<!-- Note that this is equivalent to the following: -->
<!-- <build_depend>roscpp</build_depend> -->
<!-- <exec_depend>roscpp</exec_depend> -->
<!-- Use build_depend for packages you need at compile time: -->
<!-- <build_depend>message_generation</build_depend> -->
<!-- Use build_export_depend for packages you need in order to build against this package: -->
<!-- <build_export_depend>message_generation</build_export_depend> -->
<!-- Use buildtool_depend for build tool packages: -->
<!-- <buildtool_depend>catkin</buildtool_depend> -->
<!-- Use exec_depend for packages you need at runtime: -->
<!-- <exec_depend>message_runtime</exec_depend> -->
<!-- Use test_depend for packages you need only for testing: -->
<!-- <test_depend>gtest</test_depend> -->
<!-- Use doc_depend for packages you need only for building documentation: -->
<!-- <doc_depend>doxygen</doc_depend> -->
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>rospy</build_export_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>rospy</exec_depend>
<build_depend>message_generation</build_depend>
<exec_depend>message_runtime</exec_depend>
<build_depend>geometry_msgs</build_depend>
<build_export_depend>geometry_msgs</build_export_depend>
<exec_depend>geometry_msgs</exec_depend>
<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- Other tools can request additional information be placed here -->
</export>
</package>
网友评论