一:创建专门的project书写文件
如下图所示,做一个msg文件夹,并建立msg文件,注意首字母一定要大写
创建上面的结构以后需要对package.xcml 和CMakeLists.txt文件进行如下的修改
package.xcml
<build_depend>rosidl_default_generators</build_depend> <exec_depend>rosidl_default_runtime</exec_depend> <member_of_group>rosidl_interface_packages</member_of_group>
CMakeLists.txt
find_package(rosidl_default_generators REQUIRED) rosidl_generate_interfaces(${PROJECT_NAME} "msg/Stu.msg" )
二:导入包
导入包的时候在同项目下的另一个功能包中配置对应的package.xcml 和CMakeLists.txt文件即可
package.xcml
<depend>project_msg_data</depend> //添加这个文件包
CMakeLists.txt 寻找导入即可
find_package(project_msg_data REQUIRED)
ament_target_dependencies(
demo02_listener_stu
"rclcpp"
"project_msg_data"
)
标签:文件,CMakeLists,package,xcml,msg,txt,ROS2,rosidl From: https://www.cnblogs.com/ririking/p/17843981.html