#include <chrono>
#include <cinttypes>
#include <cstdio>
#include <memory>
#include <string>
#include <utility>
#include <chrono> // std::chrono::seconds
#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/string.hpp"
#include "std_msgs/msg/int32.hpp"
using namespace std::chrono_literals;
struct Producer : public rclcpp::Node
{
Producer(const std::string &name, const std::string &output)
: Node(name)
{
// Create a publisher on the output topic.
pub_ = this->create_publisher<std_msgs::msg::Int32>(output, 10);
std::weak_ptr<std::remove_pointer<decltype(pub_.get())>::type> captured_pub = pub_;
// Create a timer which publishes on the output topic at ~1Hz.
auto callback = [captured_pub]() -> void {
auto pub_ptr = captured_pu
ros2发布订阅多线程
最新推荐文章于 2024-05-14 17:14:36 发布
![](https://img-home.csdnimg.cn/images/20240611030827.png)