当前位置: 首页 > news >正文

ROS2 同一个pkg里定义自定义action、msg报错

参考

主要就是在定义完可执行文件后加入

rosidl_target_interfaces(fibonacci_action_server
  ${PROJECT_NAME} "rosidl_typesupport_cpp")
末尾加
 ament_export_dependencies(rosidl_default_runtime) 
 同时别忘记 packagexml定义 rosidl_default_runtime

完整Cmakelists,txt

cmake_minimum_required(VERSION 3.8)
project(mypkg)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_action REQUIRED)
find_package(example_interfaces REQUIRED)


find_package(rosidl_default_generators REQUIRED)

rosidl_generate_interfaces(${PROJECT_NAME}
  "action/Fibonacci.action"
)



if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # comment the line when a copyright and license is added to all source files
  set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # comment the line when this package is in a git repo and when
  # a copyright and license is added to all source files
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

add_executable(fibonacci_action_server src/fibonacci_action_server.cpp)
ament_target_dependencies(fibonacci_action_server 
rclcpp rclcpp_action example_interfaces rosidl_default_runtime)
rosidl_target_interfaces(fibonacci_action_server
  ${PROJECT_NAME} "rosidl_typesupport_cpp")



add_executable(fibonacci_action_client src/fibonacci_action_client.cpp)
ament_target_dependencies(fibonacci_action_client 
rclcpp 
rclcpp_action 
example_interfaces 
rosidl_default_runtime)

rosidl_target_interfaces(fibonacci_action_client
  ${PROJECT_NAME} "rosidl_typesupport_cpp")

install(TARGETS
  fibonacci_action_server
  fibonacci_action_client
  DESTINATION lib/${PROJECT_NAME})
  
 ament_export_dependencies(rosidl_default_runtime) 
ament_package()
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
  <name>mypkg</name>
  <version>0.0.0</version>
  <description>TODO: Package description</description>
  <maintainer email="lzq@todo.todo">lzq</maintainer>
  <license>TODO: License declaration</license>

  <buildtool_depend>ament_cmake</buildtool_depend>

  <depend>rclcpp</depend>
  <depend>rclcpp_action</depend>
  <depend>example_interfaces</depend>

  <test_depend>ament_lint_auto</test_depend>
  <test_depend>ament_lint_common</test_depend>
  
  <build_depend>rosidl_default_generators</build_depend>
  <exec_depend>rosidl_default_runtime</exec_depend>
  <member_of_group>rosidl_interface_packages</member_of_group>

  <export>
    <build_type>ament_cmake</build_type>
  </export>
</package>
http://www.dtcms.com/a/35153.html

相关文章:

  • 爬虫解析库:Beautiful Soup的详细使用
  • 怎样把外网的文件放到内网?
  • Python3 运算符
  • 清影2.0(AI视频生成)技术浅析(五):音频处理技术
  • 超高速工业相机的应用
  • angular简易计算器
  • 27.C++继承 3 (复杂的菱形继承与菱形虚拟继承)
  • 蓝桥云课python代码
  • 影像集的过滤
  • 重新求职刷题DAY18
  • [Web 安全] Web 安全攻防 - 学习手册
  • 读取罗克韦尔AllenBradley Micro-Logix1400 罗克韦尔 CIP PCCC通信协议
  • 【Godot4.3】自定义圆角容器
  • FCC CE SRRC MIC是什么意思?
  • vue3 下载文件 responseType-blob 或者 a标签
  • java练习(39)
  • 【C语言基础】基本数据类型和常量介绍
  • MinIO Go 客户端 API
  • DSP芯片C6678的SRIO及其中断跳转的配置
  • 【Java】I/O 流篇 —— 字节 I/O 流
  • Starlink卫星动力学系统仿真建模第九讲-滑模(SMC)控制算法原理简介及卫星控制应用
  • 深入理解Self-Attention - 原理与等价表示
  • 15.1 智能销售顾问系统架构与业务价值解析:AI 如何重塑销售流程
  • RTOS系统ulTaskNotifyTake怎么知道哪个发送任务通知函数的pxcurrentTCB
  • 4.WebSocket 配置与Nginx 的完美结合
  • react路由总结
  • IDEA搭建SpringBoot,MyBatis,Mysql工程项目
  • 学习threejs,使用createMultiMaterialObject创建多材质对象
  • 小视频压缩实用方法大汇总
  • 6.2 - UART串口数据发送之轮询