From 2cf07c1e1d60727e1b12663fa7a5d93604dcfa3c Mon Sep 17 00:00:00 2001 From: domire8 Date: Fri, 13 Dec 2024 09:46:04 +0000 Subject: [PATCH] deploy: 935db828881b5686c046ebf170852ff5cd4358f0 --- versions/main/_component_8hpp_source.html | 2 +- .../_component_interface_8hpp_source.html | 165 +++++++++--------- .../_lifecycle_component_8hpp_source.html | 2 +- ...o__components_1_1_component_interface.html | 2 +- 4 files changed, 90 insertions(+), 81 deletions(-) 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 @@
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/_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>
-
- -
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);
- -
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;
- -
770 throw;
-
771 } catch (const std::exception& ex) {
- -
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) {
- -
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());
- -
806 }
-
807 tf_broadcaster->sendTransform(transform_messages);
-
808 } catch (const std::exception& ex) {
- -
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) {
+ +
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());
+ +
815 }
+
816 tf_broadcaster->sendTransform(transform_messages);
+
817 } catch (const std::exception& ex) {
+ +
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.