Add identity publisher.
This commit is contained in:
parent
a80d602ac3
commit
f003c19b5c
|
|
@ -0,0 +1,36 @@
|
||||||
|
#include <rclcpp/rclcpp.hpp>
|
||||||
|
#include <std_msgs/msg/string.hpp>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
|
|
||||||
|
namespace j7s {
|
||||||
|
class IdentityPublisher : public rclcpp::Node {
|
||||||
|
public:
|
||||||
|
IdentityPublisher(const rclcpp::NodeOptions& options);
|
||||||
|
private:
|
||||||
|
std::shared_ptr<rclcpp::Publisher<std_msgs::msg::String>> m_publisher;
|
||||||
|
rclcpp::TimerBase::SharedPtr m_timer;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace j7s {
|
||||||
|
IdentityPublisher::IdentityPublisher(const rclcpp::NodeOptions& options):
|
||||||
|
Node("identity_publisher", options),
|
||||||
|
m_publisher(this->create_publisher<std_msgs::msg::String>("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_macro.hpp>
|
||||||
|
RCLCPP_COMPONENTS_REGISTER_NODE(j7s::IdentityPublisher)
|
||||||
Loading…
Reference in New Issue