踩坑ROS2humble自定义通信接口文件

 明明.srv、package.xml和CMakeLists.txt都一一对照没有问题,但是就是编译不通过。

将功能包换到另外一个工作空间下又能编译成功,我之前还以为是没有将环境变量写入到.bashrc的原因。结果今天才发现问题出在工作空间的路径有中文。

其他的功能包可以在中文路径下正常编译,但是定义通信接口的功能包不行!

另外,附上依赖std_msgs的一个自定义通信接口:

Jabocian.srv:

# request
float64[]   theta        # theta角度
---
# response
std_msgs/Float64MultiArray    jabocian      # 求和结果

CMakeLists.txt:

cmake_minimum_required(VERSION 3.8)
project(arm_interface)

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(std_msgs REQUIRED)		# 1.有用到就需要加(非必须)
find_package(rosidl_default_generators REQUIRED)	# 2.必须

rosidl_generate_interfaces(${PROJECT_NAME}		# 3.必须
  "srv/Jabocian.srv"
  DEPENDENCIES std_msgs		# 有用到就需要加(非必须)
 )

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()

ament_package()

package.xml:

<?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>arm_interface</name>
  <version>0.0.0</version>
  <description>TODO: Package description</description>
  <maintainer email="mi@todo.todo">mi</maintainer>
  <license>TODO: License declaration</license>

  <buildtool_depend>ament_cmake</buildtool_depend>

  <depend>std_msgs</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>

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值