diff --git a/versions/main/_component_8hpp_source.html b/versions/main/_component_8hpp_source.html index 9addefc1..bb96c273 100644 --- a/versions/main/_component_8hpp_source.html +++ b/versions/main/_component_8hpp_source.html @@ -230,7 +230,7 @@
modulo_components::ComponentInterface::finalize_interfaces
void finalize_interfaces()
Finalize all interfaces.
Definition ComponentInterface.cpp:612
modulo_components::ComponentInterface::get_parameter_value
T get_parameter_value(const std::string &name) const
Get a parameter value by name.
Definition ComponentInterface.hpp:600
modulo_components::ComponentInterface::publish_predicates
void publish_predicates()
Helper function to publish all predicates.
Definition ComponentInterface.cpp:574
-
modulo_components::ComponentInterface::create_output
std::string create_output(modulo_core::communication::PublisherType publisher_type, const std::string &signal_name, const std::shared_ptr< DataT > &data, const std::string &default_topic, bool fixed_topic, bool publish_on_step)
Helper function to parse the signal name and add an unconfigured PublisherInterface to the map of out...
Definition ComponentInterface.hpp:751
+
modulo_components::ComponentInterface::create_output
std::string create_output(modulo_core::communication::PublisherType publisher_type, const std::string &signal_name, const std::shared_ptr< DataT > &data, const std::string &default_topic, bool fixed_topic, bool publish_on_step)
Helper function to parse the signal name and add an unconfigured PublisherInterface to the map of out...
Definition ComponentInterface.hpp:760
modulo_components::ComponentInterface::get_qos
rclcpp::QoS get_qos() const
Getter of the Quality of Service attribute.
Definition ComponentInterface.cpp:549
modulo_components::ComponentInterface::inputs_
std::map< std::string, std::shared_ptr< modulo_core::communication::SubscriptionInterface > > inputs_
Map of inputs.
Definition ComponentInterface.hpp:445
modulo_components::ComponentInterface::evaluate_periodic_callbacks
void evaluate_periodic_callbacks()
Helper function to evaluate all periodic function callbacks.
Definition ComponentInterface.cpp:600
diff --git a/versions/main/_component_interface_8hpp_source.html b/versions/main/_component_interface_8hpp_source.html index 92aec4f1..87e3eaec 100644 --- a/versions/main/_component_interface_8hpp_source.html +++ b/versions/main/_component_interface_8hpp_source.html @@ -480,85 +480,94 @@
736 RCLCPP_DEBUG_STREAM(
737 this->node_logging_->get_logger(),
738 "Adding input '" << parsed_signal_name << "' with topic name '" << topic_name << "'.");
-
739 auto subscription =
-
740 rclcpp::create_subscription<MsgT>(this->node_parameters_, this->node_topics_, topic_name, this->qos_, callback);
-
741 auto subscription_interface =
-
742 std::make_shared<SubscriptionHandler<MsgT>>()->create_subscription_interface(subscription);
-
743 this->inputs_.insert_or_assign(parsed_signal_name, subscription_interface);
-
744 } catch (const std::exception& ex) {
-
745 RCLCPP_ERROR_STREAM(
-
746 this->node_logging_->get_logger(), "Failed to add input '" << signal_name << "': " << ex.what());
-
747 }
-
748}
+
739 auto subscription = rclcpp::create_subscription<MsgT>(
+
740 this->node_parameters_, this->node_topics_, topic_name, this->qos_,
+
741 [this, signal_name, callback](const std::shared_ptr<MsgT> message) {
+
742 try {
+
743 callback(message);
+
744 } catch (const std::exception& ex) {
+
745 RCLCPP_WARN_STREAM_THROTTLE(
+
746 this->node_logging_->get_logger(), *this->node_clock_->get_clock(), 1000,
+
747 "Unhandled exception in callback of input '" << signal_name << "': " << ex.what());
+
748 }
+
749 });
+
750 auto subscription_interface =
+
751 std::make_shared<SubscriptionHandler<MsgT>>()->create_subscription_interface(subscription);
+
752 this->inputs_.insert_or_assign(parsed_signal_name, subscription_interface);
+
753 } catch (const std::exception& ex) {
+
754 RCLCPP_ERROR_STREAM(
+
755 this->node_logging_->get_logger(), "Failed to add input '" << signal_name << "': " << ex.what());
+
756 }
+
757}
-
749
-
750template<typename DataT>
-
-
751inline std::string ComponentInterface::create_output(
-
752 modulo_core::communication::PublisherType publisher_type, const std::string& signal_name,
-
753 const std::shared_ptr<DataT>& data, const std::string& default_topic, bool fixed_topic, bool publish_on_step) {
-
754 using namespace modulo_core::communication;
-
755 try {
-
756 if (data == nullptr) {
-
757 throw modulo_core::exceptions::NullPointerException("Invalid data pointer for output '" + signal_name + "'.");
-
758 }
-
759 this->declare_output(signal_name, default_topic, fixed_topic);
-
760 auto parsed_signal_name = modulo_utils::parsing::parse_topic_name(signal_name);
-
761 RCLCPP_DEBUG_STREAM(
-
762 this->node_logging_->get_logger(),
-
763 "Creating output '" << parsed_signal_name << "' (provided signal name was '" << signal_name << "').");
-
764 auto message_pair = make_shared_message_pair(data, this->node_clock_->get_clock());
-
765 this->outputs_.insert_or_assign(
-
766 parsed_signal_name, std::make_shared<PublisherInterface>(publisher_type, message_pair));
-
767 this->periodic_outputs_.insert_or_assign(parsed_signal_name, publish_on_step);
-
768 return parsed_signal_name;
-
769 } catch (const modulo_core::exceptions::AddSignalException&) {
-
770 throw;
-
771 } catch (const std::exception& ex) {
-
772 throw modulo_core::exceptions::AddSignalException(ex.what());
-
773 }
-
774}
+
758
+
759template<typename DataT>
+
+ +
761 modulo_core::communication::PublisherType publisher_type, const std::string& signal_name,
+
762 const std::shared_ptr<DataT>& data, const std::string& default_topic, bool fixed_topic, bool publish_on_step) {
+
763 using namespace modulo_core::communication;
+
764 try {
+
765 if (data == nullptr) {
+
766 throw modulo_core::exceptions::NullPointerException("Invalid data pointer for output '" + signal_name + "'.");
+
767 }
+
768 this->declare_output(signal_name, default_topic, fixed_topic);
+
769 auto parsed_signal_name = modulo_utils::parsing::parse_topic_name(signal_name);
+ +
771 this->node_logging_->get_logger(),
+
772 "Creating output '" << parsed_signal_name << "' (provided signal name was '" << signal_name << "').");
+
773 auto message_pair = make_shared_message_pair(data, this->node_clock_->get_clock());
+
774 this->outputs_.insert_or_assign(
+
775 parsed_signal_name, std::make_shared<PublisherInterface>(publisher_type, message_pair));
+
776 this->periodic_outputs_.insert_or_assign(parsed_signal_name, publish_on_step);
+
777 return parsed_signal_name;
+ +
779 throw;
+
780 } catch (const std::exception& ex) {
+ +
782 }
+
783}
-
775
-
776template<typename T>
-
777inline bool ComponentInterface::remove_signal(
-
778 const std::string& signal_name, std::map<std::string, std::shared_ptr<T>>& signal_map, bool skip_check) {
-
779 if (!skip_check && signal_map.find(signal_name) == signal_map.cend()) {
-
780 return false;
-
781 } else {
-
782 RCLCPP_DEBUG_STREAM(this->node_logging_->get_logger(), "Removing signal '" << signal_name << "'.");
-
783 signal_map.at(signal_name).reset();
-
784 return signal_map.erase(signal_name);
-
785 }
-
786}
-
787
-
788template<typename T>
-
789inline void ComponentInterface::publish_transforms(
-
790 const std::vector<state_representation::CartesianPose>& transforms, const std::shared_ptr<T>& tf_broadcaster,
-
791 bool is_static) {
-
792 std::string modifier = is_static ? "static " : "";
-
793 if (tf_broadcaster == nullptr) {
-
794 RCLCPP_ERROR_STREAM_THROTTLE(
-
795 this->node_logging_->get_logger(), *this->node_clock_->get_clock(), 1000,
-
796 "Failed to send " << modifier << "transform: No " << modifier << "TF broadcaster configured.");
-
797 return;
-
798 }
-
799 try {
-
800 std::vector<geometry_msgs::msg::TransformStamped> transform_messages;
-
801 transform_messages.reserve(transforms.size());
-
802 for (const auto& tf : transforms) {
-
803 geometry_msgs::msg::TransformStamped transform_message;
-
804 modulo_core::translators::write_message(transform_message, tf, this->node_clock_->get_clock()->now());
-
805 transform_messages.emplace_back(transform_message);
-
806 }
-
807 tf_broadcaster->sendTransform(transform_messages);
-
808 } catch (const std::exception& ex) {
-
809 RCLCPP_ERROR_STREAM_THROTTLE(
-
810 this->node_logging_->get_logger(), *this->node_clock_->get_clock(), 1000,
-
811 "Failed to send " << modifier << "transform: " << ex.what());
-
812 }
-
813}
-
814}// namespace modulo_components
+
784
+
785template<typename T>
+
786inline bool ComponentInterface::remove_signal(
+
787 const std::string& signal_name, std::map<std::string, std::shared_ptr<T>>& signal_map, bool skip_check) {
+
788 if (!skip_check && signal_map.find(signal_name) == signal_map.cend()) {
+
789 return false;
+
790 } else {
+
791 RCLCPP_DEBUG_STREAM(this->node_logging_->get_logger(), "Removing signal '" << signal_name << "'.");
+
792 signal_map.at(signal_name).reset();
+
793 return signal_map.erase(signal_name);
+
794 }
+
795}
+
796
+
797template<typename T>
+
798inline void ComponentInterface::publish_transforms(
+
799 const std::vector<state_representation::CartesianPose>& transforms, const std::shared_ptr<T>& tf_broadcaster,
+
800 bool is_static) {
+
801 std::string modifier = is_static ? "static " : "";
+
802 if (tf_broadcaster == nullptr) {
+
803 RCLCPP_ERROR_STREAM_THROTTLE(
+
804 this->node_logging_->get_logger(), *this->node_clock_->get_clock(), 1000,
+
805 "Failed to send " << modifier << "transform: No " << modifier << "TF broadcaster configured.");
+
806 return;
+
807 }
+
808 try {
+
809 std::vector<geometry_msgs::msg::TransformStamped> transform_messages;
+
810 transform_messages.reserve(transforms.size());
+
811 for (const auto& tf : transforms) {
+
812 geometry_msgs::msg::TransformStamped transform_message;
+
813 modulo_core::translators::write_message(transform_message, tf, this->node_clock_->get_clock()->now());
+
814 transform_messages.emplace_back(transform_message);
+
815 }
+
816 tf_broadcaster->sendTransform(transform_messages);
+
817 } catch (const std::exception& ex) {
+
818 RCLCPP_ERROR_STREAM_THROTTLE(
+
819 this->node_logging_->get_logger(), *this->node_clock_->get_clock(), 1000,
+
820 "Failed to send " << modifier << "transform: " << ex.what());
+
821 }
+
822}
+
823}// namespace modulo_components
Friend class to the ComponentInterface to allow test fixtures to access protected and private members...
Base interface class for modulo components to wrap a ROS Node with custom behaviour.
double get_rate() const
Get the component rate in Hertz.
@@ -589,7 +598,7 @@
virtual void step()
Step function that is called periodically.
void publish_predicates()
Helper function to publish all predicates.
void set_qos(const rclcpp::QoS &qos)
Set the Quality of Service for ROS publishers and subscribers.
-
std::string create_output(modulo_core::communication::PublisherType publisher_type, const std::string &signal_name, const std::shared_ptr< DataT > &data, const std::string &default_topic, bool fixed_topic, bool publish_on_step)
Helper function to parse the signal name and add an unconfigured PublisherInterface to the map of out...
+
std::string create_output(modulo_core::communication::PublisherType publisher_type, const std::string &signal_name, const std::shared_ptr< DataT > &data, const std::string &default_topic, bool fixed_topic, bool publish_on_step)
Helper function to parse the signal name and add an unconfigured PublisherInterface to the map of out...
rclcpp::QoS get_qos() const
Getter of the Quality of Service attribute.
void add_predicate(const std::string &predicate_name, bool predicate_value)
Add a predicate to the map of predicates.
void send_transform(const state_representation::CartesianPose &transform)
Send a transform to TF.
diff --git a/versions/main/_lifecycle_component_8hpp_source.html b/versions/main/_lifecycle_component_8hpp_source.html index 244bda8a..5a08cbcd 100644 --- a/versions/main/_lifecycle_component_8hpp_source.html +++ b/versions/main/_lifecycle_component_8hpp_source.html @@ -228,7 +228,7 @@
void finalize_interfaces()
Finalize all interfaces.
T get_parameter_value(const std::string &name) const
Get a parameter value by name.
void publish_predicates()
Helper function to publish all predicates.
-
std::string create_output(modulo_core::communication::PublisherType publisher_type, const std::string &signal_name, const std::shared_ptr< DataT > &data, const std::string &default_topic, bool fixed_topic, bool publish_on_step)
Helper function to parse the signal name and add an unconfigured PublisherInterface to the map of out...
+
std::string create_output(modulo_core::communication::PublisherType publisher_type, const std::string &signal_name, const std::shared_ptr< DataT > &data, const std::string &default_topic, bool fixed_topic, bool publish_on_step)
Helper function to parse the signal name and add an unconfigured PublisherInterface to the map of out...
rclcpp::QoS get_qos() const
Getter of the Quality of Service attribute.
std::map< std::string, std::shared_ptr< modulo_core::communication::SubscriptionInterface > > inputs_
Map of inputs.
void evaluate_periodic_callbacks()
Helper function to evaluate all periodic function callbacks.
diff --git a/versions/main/classmodulo__components_1_1_component_interface.html b/versions/main/classmodulo__components_1_1_component_interface.html index c3e53524..a3bec555 100644 --- a/versions/main/classmodulo__components_1_1_component_interface.html +++ b/versions/main/classmodulo__components_1_1_component_interface.html @@ -1143,7 +1143,7 @@

Returns
The parsed signal name
-

Definition at line 751 of file ComponentInterface.hpp.

+

Definition at line 760 of file ComponentInterface.hpp.