string_pub_sub.h
Go to the documentation of this file.
1 //
2 // Created by nakakura on 22/08/31.
3 //
4 
5 #ifndef SKYWAY_PLUGIN_STRING_PUB_SUB_H
6 #define SKYWAY_PLUGIN_STRING_PUB_SUB_H
7 
8 #include <skyway/skyway_plugin.h>
9 
10 #include <mutex>
11 #include <thread>
12 
13 #include "std_msgs/String.h"
14 
15 namespace string_pub_sub {
17  private:
20  nh_.advertise<std_msgs::String>("skyway_string_publisher", 1000);
21  ros::Subscriber sub_ = nh_.subscribe("skyway_string_subscriber", 1000,
23  std::shared_ptr<std::function<void(std::string)>> callback_;
24  std::list<std::string> parameters_{};
25  std::mutex mutex_;
26  std::thread loop_thread_;
28 
29  void subscribe(const std_msgs::String::ConstPtr& msg);
30  void service_thread();
31 
32  public:
33  StringPubSub();
34  ~StringPubSub();
35  virtual void Initialize(
36  std::shared_ptr<rapidjson::Document> parameter,
37  std::shared_ptr<std::function<void(std::string)>> callback) override;
38  virtual void Execute(std::string data) override;
39  virtual void Shutdown() override;
40 };
41 }; // namespace string_pub_sub
42 
43 #endif // SKYWAY_PLUGIN_STRING_PUB_SUB_H
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
virtual void Execute(std::string data) override
std::shared_ptr< std::function< void(std::string)> > callback_
virtual void Shutdown() override
void subscribe(const std_msgs::String::ConstPtr &msg)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
std::list< std::string > parameters_
virtual void Initialize(std::shared_ptr< rapidjson::Document > parameter, std::shared_ptr< std::function< void(std::string)>> callback) override


skyway
Author(s): Toshiya Nakakura
autogenerated on Sat Apr 15 2023 02:08:21