Ros2-galactic下使用std_msgs::msg::Bool
Posted KAI-yq
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ros2-galactic下使用std_msgs::msg::Bool相关的知识,希望对你有一定的参考价值。
- CMakeList.txt
find_package(ament_cmake REQUIRED)
find_package(std_msgs REQUIRED)
ament_auto_add_executable(pose_initializer_node
src/pose_initializer/pose_initializer_node.cpp
src/pose_initializer/pose_initializer_core.cpp
)
ament_target_dependencies(pose_initializer_node std_msgs)
- package.xml
<depend>std_msgs</depend>
- cpp
hpp:
#include "std_msgs/msg/bool.hpp"
rclcpp::Subscription<std_msgs::msg::Bool>::SharedPtr sub_init_pose_control_;
rclcpp::Publisher<geometry_msgs::msg::PoseWithCovarianceStamped>::SharedPtr pub_initial_pose_cov_;
cpp:
GnssModule::GnssModule(rclcpp::Node * node)
sub_init_pose_control_ = node->create_subscription<std_msgs::msg::Bool>(
"/InitPoseControl", 1, std::bind(&GnssModule::callbackInitialPoseControl, this, _1));
void GnssModule::callbackInitialPoseControl(std_msgs::msg::Bool msg)
if(msg.data)
is_init_ = true;
else
is_init_ = false;
以上是关于Ros2-galactic下使用std_msgs::msg::Bool的主要内容,如果未能解决你的问题,请参考以下文章
-Publishing and Subscribing .3.2