Writing ROS programs
2015-07-16 21:55
323 查看
Writing ROS programs
参考:
A Gentle Introduction to ROS
Jason M. O’Kane
Creating a workspace and a package
Creating a workspace:
Creating a package:
A simple program
(1) Writing source file,
named hello.cpp, belongs in your package folder, right next to package.xml and CMake-Lists.txt.
(2) Compiling the Hello program.
Declaring dependencies. To list dependencies, edit the CMakeLists.txt in your package directory.
$ find_package(catkin REQUIRED COMPONENTS roscpp)
list dependencies in the package manifest (package.xml), using the build-
_depend and run_depend elements:
Steps:
当package中的.cpp文件很多时,建一个src放源代码文件会有帮助,.cpp文件不多时也可以建。
Declaring dependencies
In CMakeLists.txt:
Dependencies on other catkin packages can be added in a COMPONENTS section on this line:
find_package(catkin REQUIRED COMPONENTS package-names)
比如:
In manifest.xml:
list dependencies in the package manifest (package.xml)
We should also list dependencies in the package manifest (package.xml), using the build_depend and run_depend elements:
In our example, the hello program needs roscpp both at build time and at run time, so the
manifest should contain:
Declaring an executable
In CMakeLists.txt:
add two lines to CMakeLists.txt declaring
the executable we would like to create. The general form is
例子:
Building the workspace
Once your CMakeLists.txt is set up, you can build your workspace—including
compiling all of the executables in all of its packages—using this command:
In workspace directory:
参考:
A Gentle Introduction to ROS
Jason M. O’Kane
Creating a workspace and a package
Creating a workspace:
$ mkdir workspaceName
Creating a package:
$ catkin_create_pkg agitr
A simple program
(1) Writing source file,
named hello.cpp, belongs in your package folder, right next to package.xml and CMake-Lists.txt.
(2) Compiling the Hello program.
Declaring dependencies. To list dependencies, edit the CMakeLists.txt in your package directory.
$ find_package(catkin REQUIRED COMPONENTS roscpp)
list dependencies in the package manifest (package.xml), using the build-
_depend and run_depend elements:
Steps:
$ source /opt/ros/hydro/setup.bash
$ mkdir -p ~/ros_workspace/src
$ cd src
~/ros_workspace/src$ catkin_create_pkg agitr
~/ros_workspace/src/ros_package$ mkdir src
当package中的.cpp文件很多时,建一个src放源代码文件会有帮助,.cpp文件不多时也可以建。
Declaring dependencies
In CMakeLists.txt:
Dependencies on other catkin packages can be added in a COMPONENTS section on this line:
find_package(catkin REQUIRED COMPONENTS package-names)
比如:
find_package(catkin REQUIRED COMPONENTS cv_bridge dynamic_reconfigure image_transport image_geometry kobuki_msgs nodelet pcl_ros roscpp std_msgs turtlebot_msgs visualization_msgs tf pcl_conversions )
In manifest.xml:
list dependencies in the package manifest (package.xml)
We should also list dependencies in the package manifest (package.xml), using the build_depend and run_depend elements:
<build_depend>package-name</build_depend> <run_depend>package-name</run_depend>
In our example, the hello program needs roscpp both at build time and at run time, so the
manifest should contain:
<build_depend>roscpp</build_depend> <run_depend>roscpp</run_depend>
Declaring an executable
In CMakeLists.txt:
add two lines to CMakeLists.txt declaring
the executable we would like to create. The general form is
add_executable(executable-name source-files) target_link_libraries(executable-name ${catkin_LIBRARIES})
例子:
add_executable(hello src/hello.cpp) target_link_libraries(hello ${catkin_LIBRARIES})
Building the workspace
Once your CMakeLists.txt is set up, you can build your workspace—including
compiling all of the executables in all of its packages—using this command:
In workspace directory:
catkin_make
相关文章推荐
- ios感想
- 第3章 结构之法——重建二叉树
- Crossing River
- Linux启动过程
- select的用法
- (七十二)自定义通知NSNotification实现消息传递
- Palindrome Transformation
- VIM Tutorial
- (七十二)自定义通知NSNotification实现消息传递
- oracle用户和表空间
- linux之配置IP地址
- ThreadPoolExecutor运转机制详解
- 怎样更健康解决一个人时的性需求
- leetcode83 Remove Duplicates from Sorted List
- poj1236 强连通分量+缩点
- Objective-C编码规范:26个方面解决iOS开发问题
- mysql或则oracle的declare可以放在操作语句的后面吗?
- Mac新手操作指南(五)
- java EE之jsp的7个动作指令 复习
- vimrc for windows