TA的每日心情 | 开心 2019-11-19 16:54 |
---|
签到天数: 1 天 [LV.1]初来乍到
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
本帖最后由 harry-IoT 于 2020-3-13 08:50 编辑
一、概述
二、ROSCPP客户端
一、概述
- roscpp:ROS中的C++客户端库,执行效率高,在ROS中使用最广泛。
- rospy:ROS中的python客户端库,使得ROS可以享有面向对象的脚本语言所带来的便利。rospy注重开发效率而不是运行效率,master,roslaunch和很多工具都是采用rospy开发的。
- roslisp:用于LISP的客户端库,它目前用于开发规划库。
- 其他实验库:rosjava,roslua
二、ROSCPP客户端 编写主题发布者节点需要:
- 初始化ROS系统
- 广播消息:在foo主题上发布Foo_type_msg类型的消息
- 已指定频率发布消息到foo主题
编写主题订阅者需要:
- 初始化ROS
- 从foo主题订阅消息
- Spin,然后等待消息到达
- 当消息到达时,Msg_Callback()函数被调用
简单的服务器端和客户端:
提取参数
bool getParam(const std::string &key,parameter_type &output_value) const
parameter_type param(const std::string& param_name, parameter_type& default_val)
设置参数
void setParam(const std::string& key, parameter_type& v) const
删除参数
bool deleteParam(const std::string& key) const
检查存在性
bool hasParam(const std::string& key) const
关于CMakeList.txt
总体框架和顺序
- CMakeLists.txt文件必须符合以下格式和顺序,否则将不能正确编译
- Required CMake Version (cmake_minimum_required)
- Package Name (project())
- Find other CMake/Catkin packages needed for build (find_package())
- Message/Service/Action Generators (add_message_files(), add_service_files(), add_action_files())
- Invoke message/service/action generation (generate_messages())
- Specify package build info export (catkin_package())
- Libraries/Executables to build (add_library()/add_executable()/target_link_libraries())
- Tests to build (catkin_add_gtest())
- Install rules (install())
每个catkin CMakeLists.txt文件必须指定CMake的版本,Catkin需要版本 2.8.3或更高
- project()
- project()是由CMake工程函数指定的软件包名称,在以后的 CMake脚本中可以使用随时变量 ${PROJECT_NAME}
- find_package()
使用find_package编译时我们需要指定依赖哪个CMake软件包,通常需要至少一个catkin依赖项,如果还依赖其他的软件包,他们会自动转化为CMake的组件。例如find_package(catkin REQUIRED) find_package(nodelet REQUIRED) 也可写成简易形式 find_package(catkin REQUIRED COMPONENTS nodelet)如果使用find_package(nodelet)意味着nodelet paths, libraries 等都不会添加到catkin_ variables.
如果使用C++和Boost,需要调用Boost上的find_package()来指定使用的Boost的库,例如使用Boost threads find_package(Boost REQUIRED COMPONENTS thread)
指定catkin信息给编译系统生成pkg-config和CMake文件
这个函数必须在调用add_library()或 add_executable()之前调用,这个函数有五个可选参数:
INCLUDE_DIRS - The exported include paths (i.e. cflags) for the package
LIBRARIES - The exported libraries from the project
CATKIN_DEPENDS - Other catkin projects that this project depends on
DEPENDS - Non-catkin CMake projects that this project depends on
CFG_EXTRAS - Additional configuration options
例如:
INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME}
CATKIN_DEPENDS roscpp nodelet
DEPENDS eigen opencv)
This indicates that the folder "include" within the package folder is where exported headers go. The CMake environment variable ${PROJECT_NAME} evaluates to whatever you passed to the project() function earlier, in this case it will be "robot_brain". "roscpp" + "nodelet" are packages that need to be present to build/run this package, and "eigen" + "opencv" are system dependencies that need to be present to build/run this package.
add_library()函数指定编译需要添加的库,默认情况下,catkin编译共享的库
add_library(${PROJECT_NAME} ${${PROJECT_NAME}_SRCS})
指定一个必须编译的可执行目标,必须使用add_executable() 例如
- add_executable(myProgram src/main.cpp src/some_file.cpp src/another_file.cpp)
这会从从src/main.cpp, src/some_file.cpp and src/another_file.cpp3个文件中编译一个为myProgram的目标可行文件
指定可执行目标链接的库,这通常在add_executable()之后调用。语法:
- target_link_libraries(<executableTargetName>, <lib1>, <lib2>, ... <libN>)
例如: add_executable(foo src/foo.cpp)
add_library(moo src/moo.cpp)
target_link_libraries(foo moo) -- This links foo against libmoo.so
处理gtest-based unit tests 的函数,例如:
catkin_add_gtest(myUnitTest test/utest.cpp)
编译后,目标被分散在catkin工作空间中,install()可以安装目标到系统中
|
|