diff --git a/src/IdentityPublisher.cpp b/src/IdentityPublisher.cpp new file mode 100644 index 0000000..4410404 --- /dev/null +++ b/src/IdentityPublisher.cpp @@ -0,0 +1,36 @@ +#include +#include +#include + +#include + +using namespace std::chrono_literals; + + +namespace j7s { + class IdentityPublisher : public rclcpp::Node { + public: + IdentityPublisher(const rclcpp::NodeOptions& options); + private: + std::shared_ptr> m_publisher; + rclcpp::TimerBase::SharedPtr m_timer; + }; +}; + +namespace j7s { + IdentityPublisher::IdentityPublisher(const rclcpp::NodeOptions& options): + Node("identity_publisher", options), + m_publisher(this->create_publisher("identity", 1)), + m_timer{} + { + const std::string identity = "namespace: data_simulator\njaus_id: 123.1.1"; + m_timer = this->create_timer(1000ms, [this, identity]() -> void { + std_msgs::msg::String msg; + msg.data = identity; + m_publisher->publish(msg); + }); + } +}; + +#include +RCLCPP_COMPONENTS_REGISTER_NODE(j7s::IdentityPublisher)