紧急通知:禁止一切关于政治&VPN翻墙等话题,发现相关帖子会立马删除封号
小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
ros2发布自定义消息时报了symbol lookup error的错误
-
再运行时报错如下
[ahrs_driver_node-1] /home/ly1/imu_test/install/fdilink_ahrs/lib/fdilink_ahrs/ahrs_driver_node: symbol lookup error: /home/ly1/imu_test/install/imu_ins_gps_interfaces/lib/libimu_ins_gps_interfaces__rosidl_typesupport_fastrtps_cpp.so: undefined symbol: _ZN8std_msgs3msg24typesupport_fastrtps_cpp26max_serialized_size_HeaderERbm
当我把自定义类型的实例化对象语句屏蔽后,就不报错,看起来就是因为我实例化了自定义类型的对象引起的,代码如下
ins_pub_ = create_publisher<imu_ins_gps_interfaces::msg::Insgps>(ins_topic.c_str(),20);
请问这是什么错误?有人遇到么?
-
@Zln4ever 贴一下
- 你自定义的消息接口文件
2, 接口功能包CMakeLists.txt - 调用的功能包CmakeLists.txt
@小鱼 在 提问前必看!一定要看!必须看一下! 中说:
尽量提供更多的信息(大多数问题不是别人不知道如何解决,而是不知道你的问题是什么)
- 你自定义的消息接口文件
-
@小鱼
1.这是文件Insgps.msg
路径:imu_test/src/imu_ins_gps_interfaces/msg
ros程序路径 imu_test/src/fdlink_ahrs_ROS2/src#ins/gps数据接口 std_msgs/Header header float64 l_n #从坐标原点到当前向北方向的距离 float64 l_e #从坐标原点到当前向东方向的距离 float64 l_d #从坐标原点到当前向地方向的距离
2.接口功能包的CMakelist.txt
cmake_minimum_required(VERSION 3.5) project(imu_ins_gps_interfaces) # Default to C99 if(NOT CMAKE_C_STANDARD) set(CMAKE_C_STANDARD 99) endif() # Default to C++14 if(NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 14) endif() 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) # uncomment the following section in order to fill in # further dependencies manually. # find_package(<dependency> REQUIRED) #find_package(sensor_msgs REQUIRED) find_package(std_msgs REQUIRED) if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) # the following line skips the linter which checks for copyrights # uncomment the line when a copyright and license is not present in all source files #set(ament_cmake_copyright_FOUND TRUE) # the following line skips cpplint (only works in a git repo) # uncomment the line when this package is not in a git repo #set(ament_cmake_cpplint_FOUND TRUE) ament_lint_auto_find_test_dependencies() endif() find_package(rosidl_default_generators REQUIRED) rosidl_generate_interfaces(${PROJECT_NAME} "msg/Insgps.msg" DEPENDENCIES ) ament_package()
3.功能包的Cmakelist.txt
cmake_minimum_required(VERSION 3.5) project(fdilink_ahrs) # Default to C99 if(NOT CMAKE_C_STANDARD) set(CMAKE_C_STANDARD 99) endif() # Default to C++14 if(NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 14) endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Wpedantic) endif() find_package(Eigen3 REQUIRED) set(Eigen3_INCLUDE_DIRS ${EIGEN3_INCLUDE_DIR}) # find dependencies find_package(ament_cmake REQUIRED) find_package(rclcpp REQUIRED) find_package(rclpy REQUIRED) find_package(sensor_msgs REQUIRED) find_package(std_msgs REQUIRED) find_package(tf2 REQUIRED) find_package(tf2_ros REQUIRED) find_package(serial REQUIRED) find_package(imu_ins_gps_interfaces REQUIRED) if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) # the following line skips the linter which checks for copyrights # uncomment the line when a copyright and license is not present in all source files #set(ament_cmake_copyright_FOUND TRUE) # the following line skips cpplint (only works in a git repo) # uncomment the line when this package is not in a git repo #set(ament_cmake_cpplint_FOUND TRUE) ament_lint_auto_find_test_dependencies() endif() include_directories( include src ${catkin_INCLUDE_DIRS} ${Eigen3_INCLUDE_DIRS} ) add_executable(ahrs_driver_node src/ahrs_driver.cpp src/crc_table.cpp) ament_target_dependencies(ahrs_driver_node rclcpp rclpy std_msgs sensor_msgs serial tf2_ros tf2 imu_ins_gps_interfaces) add_executable(imu_tf_node src/imu_tf.cpp) ament_target_dependencies(imu_tf_node rclcpp rclpy std_msgs sensor_msgs serial tf2_ros tf2 imu_ins_gps_interfaces) # find_package(Boost 1.55.0 REQUIRED COMPONENTS system filesystem) # include_directories(ahrs_driver_node ${Boost_INCLOUDE_DIRS}) # link_directories(ahrs_driver_node ${Boost_LIBRARY_DIRS}) # target_link_libraries(ahrs_driver_node ${Boost_LIBRSRIES}) install(TARGETS ahrs_driver_node imu_tf_node DESTINATION lib/${PROJECT_NAME} ) install( DIRECTORY launch DESTINATION share/${PROJECT_NAME} ) ament_package()
-
@Zln4ever 问题出在这里,你用到了std_msgs应该添加依赖.
在 ros2发布自定义消息时报了symbol lookup error的错误 中说:
rosidl_generate_interfaces(${PROJECT_NAME}
"msg/Insgps.msg"
DEPENDENCIES
)正确写法
rosidl_generate_interfaces(${PROJECT_NAME} "msg/Insgps.msg" DEPENDENCIES std_msgs )
-
@小鱼 ok鱼哥 解决了 学到了 。然后也会注意一下提问方式。