概述
ros2使用自建类型编译,订阅以及发布的demo
sub和pub对象:
chasis_Subscription_ =
rclcpp::create_subscription<calmcar::msg::BinraryData>(
*ROS2DOME::instance(),"/demo_sub_10ms", 5,
std::bind(&PubSubDemo::GetChasis, this, placeholders::_1));
auto puber = rclcpp::create_publisher<calmcar::msg::BinraryData>(
*ROS2DOME::instance(),"/demo_pub_10ms_binrarydata_topi", 20);
puber->publish(*msg);
CMakeLists.txt 添加自检类型:
# demo_data - demo_data
set(CMAKE_PREFIX_PATH
${CMAKE_PREFIX_PATH}
${CMAKE_CURRENT_LIST_DIR}/install/demo_data
)
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
${CMAKE_CURRENT_LIST_DIR}/install/demo_data
)
find_package(demo_data REQUIRED)
ament_export_dependencies(demo_data)
target_include_directories(${PROJECT_NAME} SYSTEM
PRIVATE
${rclcpp_INCLUDE_DIRS}
${demo_data_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME}
PRIVATE
${rclcpp_LIBRARIES}
${demo_data_LIBRARIES}
)
target_link_options(${PROJECT_NAME}
PRIVATE ${demo_data_LINK_FLAGS}
)
target_link_libraries(${PROJECT_NAME}
PRIVATE
${rclcpp_LIBRARIES}
demo_data_rclcpp
demo_data-dds
proto_interface_s
protobuf
protobuf-lite
)
最后
以上就是眯眯眼大地为你收集整理的ros2 demo的全部内容,希望文章能够帮你解决ros2 demo所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复