Summary
Fault reporter currently is only initialized with a rclcpp::Node::SharedPtr. This prevents clean initialization when using a lifecycle node. We most likely want to take only the interfaces we need, and have a constructor that can take lifecycle and a constructor for the normal node (or a templated constructor).
Proposed solution
Since FaultReporter already only stores a subset of the node interfaces, we can remove the need for the default constructor to have the entire node passed in. We can then create helper constructors that do the work for
Have a constructor for node base interfaces that are used:
/// @brief Generic constructor takes only exact interfaces needed
/// @param node_parameters
/// @param logger
/// @param name
FaultReporter(
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base,
rclcpp::node_interfaces::NodeParametersInterface::SharedPtr node_params,
rclcpp::node_interfaces::NodeGraphInterface::SharedPtr node_graph,
rclcpp::node_interfaces::NodeServiceInterfaec::SharedPtr node_services,
rclcpp::Logger logger,
const & std::string source_id,
const std:: & service_name);
And support node and lifecycle node
FaultReporter(const rclcpp::Node & node, const std::string & source_id, const std::string & service_name = "/fault_manager/report_fault")
: FaultReporter(
node.get_node_base_interface(),
node.get_node_param_interface(),
node.get_logger(),
node.get_graph_interface(),
node.get_service_interface(),
source_id,
service_name
)
{};
FaultReporter(const rclcpp_lifecycle::LifecycleNode & node, const std::string & source_id, const std::string & service_name = "/fault_manager/report_fault")
: FaultReporter(
node.get_node_base_interface(),
node.get_node_param_interface(),
node.get_logger(),
node.get_graph_interface(),
node.get_service_interface(),
source_id,
service_name
)
{}
You can do similar for the pointer versions of both
Summary
Fault reporter currently is only initialized with a
rclcpp::Node::SharedPtr. This prevents clean initialization when using a lifecycle node. We most likely want to take only the interfaces we need, and have a constructor that can take lifecycle and a constructor for the normal node (or a templated constructor).Proposed solution
Since FaultReporter already only stores a subset of the node interfaces, we can remove the need for the default constructor to have the entire node passed in. We can then create helper constructors that do the work for
Have a constructor for node base interfaces that are used:
And support node and lifecycle node
You can do similar for the pointer versions of both