105 const std::string& signal_name,
const std::shared_ptr<DataT>& data,
const std::string& default_topic,
106 bool fixed_topic,
bool publish_on_step) {
109 auto parsed_signal_name =
110 this->create_output(PublisherType::PUBLISHER, signal_name, data, default_topic, fixed_topic, publish_on_step);
113 this->get_logger(),
"Adding output '" << parsed_signal_name <<
"' with topic name '" << topic_name <<
"'.");
114 auto message_pair = this->outputs_.at(parsed_signal_name)->get_message_pair();
115 switch (message_pair->get_type()) {
116 case MessageType::BOOL: {
117 auto publisher = this->create_publisher<std_msgs::msg::Bool>(topic_name, this->
get_qos());
118 this->outputs_.at(parsed_signal_name) =
119 std::make_shared<PublisherHandler<rclcpp::Publisher<std_msgs::msg::Bool>, std_msgs::msg::Bool>>(
120 PublisherType::PUBLISHER, publisher)
121 ->create_publisher_interface(message_pair);
124 case MessageType::FLOAT64: {
125 auto publisher = this->create_publisher<std_msgs::msg::Float64>(topic_name, this->
get_qos());
126 this->outputs_.at(parsed_signal_name) =
127 std::make_shared<PublisherHandler<rclcpp::Publisher<std_msgs::msg::Float64>, std_msgs::msg::Float64>>(
128 PublisherType::PUBLISHER, publisher)
129 ->create_publisher_interface(message_pair);
132 case MessageType::FLOAT64_MULTI_ARRAY: {
133 auto publisher = this->create_publisher<std_msgs::msg::Float64MultiArray>(topic_name, this->
get_qos());
135 rclcpp::Publisher<std_msgs::msg::Float64MultiArray>, std_msgs::msg::Float64MultiArray>>(
136 PublisherType::PUBLISHER, publisher)
137 ->create_publisher_interface(message_pair);
140 case MessageType::INT32: {
141 auto publisher = this->create_publisher<std_msgs::msg::Int32>(topic_name, this->
get_qos());
142 this->outputs_.at(parsed_signal_name) =
143 std::make_shared<PublisherHandler<rclcpp::Publisher<std_msgs::msg::Int32>, std_msgs::msg::Int32>>(
144 PublisherType::PUBLISHER, publisher)
145 ->create_publisher_interface(message_pair);
148 case MessageType::STRING: {
149 auto publisher = this->create_publisher<std_msgs::msg::String>(topic_name, this->
get_qos());
150 this->outputs_.at(parsed_signal_name) =
151 std::make_shared<PublisherHandler<rclcpp::Publisher<std_msgs::msg::String>, std_msgs::msg::String>>(
152 PublisherType::PUBLISHER, publisher)
153 ->create_publisher_interface(message_pair);
156 case MessageType::ENCODED_STATE: {
157 auto publisher = this->create_publisher<modulo_core::EncodedState>(topic_name, this->
get_qos());
158 this->outputs_.at(parsed_signal_name) =
159 std::make_shared<PublisherHandler<rclcpp::Publisher<modulo_core::EncodedState>, modulo_core::EncodedState>>(
160 PublisherType::PUBLISHER, publisher)
161 ->create_publisher_interface(message_pair);
164 case MessageType::CUSTOM_MESSAGE: {
166 auto publisher = this->create_publisher<DataT>(topic_name, this->
get_qos());
167 this->outputs_.at(parsed_signal_name) =
168 std::make_shared<PublisherHandler<rclcpp::Publisher<DataT>, DataT>>(PublisherType::PUBLISHER, publisher)
169 ->create_publisher_interface(message_pair);
174 }
catch (
const std::exception& ex) {
175 RCLCPP_ERROR_STREAM(this->get_logger(),
"Failed to add output '" << signal_name <<
"': " << ex.what());