Skip to content

Commit

Permalink
Use user thread to run logger service
Browse files Browse the repository at this point in the history
Signed-off-by: Barry Xu <barry.xu@sony.com>
  • Loading branch information
Barry-Xu-2018 committed Apr 7, 2023
1 parent a6aff79 commit d278d1f
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 244 deletions.
1 change: 0 additions & 1 deletion rclcpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ set(${PROJECT_NAME}_SRCS
src/rclcpp/message_info.cpp
src/rclcpp/network_flow_endpoint.cpp
src/rclcpp/node.cpp
src/rclcpp/node_builtin_executor.cpp
src/rclcpp/node_interfaces/node_base.cpp
src/rclcpp/node_interfaces/node_clock.cpp
src/rclcpp/node_interfaces/node_graph.cpp
Expand Down
3 changes: 0 additions & 3 deletions rclcpp/include/rclcpp/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
#include "rclcpp/logger.hpp"
#include "rclcpp/macros.hpp"
#include "rclcpp/message_memory_strategy.hpp"
#include "rclcpp/node_builtin_executor.hpp"
#include "rclcpp/node_interfaces/node_base_interface.hpp"
#include "rclcpp/node_interfaces/node_clock_interface.hpp"
#include "rclcpp/node_interfaces/node_graph_interface.hpp"
Expand Down Expand Up @@ -1589,8 +1588,6 @@ class Node : public std::enable_shared_from_this<Node>
rclcpp::node_interfaces::NodeTimeSourceInterface::SharedPtr node_time_source_;
rclcpp::node_interfaces::NodeWaitablesInterface::SharedPtr node_waitables_;

rclcpp::NodeBuiltinExecutor::UniquePtr node_builtin_executor_;

const rclcpp::NodeOptions node_options_;
const std::string sub_namespace_;
const std::string effective_namespace_;
Expand Down
52 changes: 0 additions & 52 deletions rclcpp/include/rclcpp/node_builtin_executor.hpp

This file was deleted.

15 changes: 13 additions & 2 deletions rclcpp/include/rclcpp/node_interfaces/node_logging.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#include "rclcpp/node_interfaces/node_logging_interface.hpp"
#include "rclcpp/visibility_control.hpp"

#include "rcl_interfaces/srv/get_logger_levels.hpp"
#include "rcl_interfaces/srv/set_logger_levels.hpp"

namespace rclcpp
{
namespace node_interfaces
Expand All @@ -35,7 +38,7 @@ class NodeLogging : public NodeLoggingInterface
RCLCPP_SMART_PTR_ALIASES_ONLY(NodeLoggingInterface)

RCLCPP_PUBLIC
explicit NodeLogging(rclcpp::node_interfaces::NodeBaseInterface * node_base);
explicit NodeLogging(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base);

RCLCPP_PUBLIC
virtual
Expand All @@ -49,13 +52,21 @@ class NodeLogging : public NodeLoggingInterface
const char *
get_logger_name() const override;

RCLCPP_PUBLIC
void
create_logger_services(
node_interfaces::NodeServicesInterface::SharedPtr node_services) override;

private:
RCLCPP_DISABLE_COPY(NodeLogging)

/// Handle to the NodeBaseInterface given in the constructor.
rclcpp::node_interfaces::NodeBaseInterface * node_base_;
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base_;

rclcpp::Logger logger_;

rclcpp::Service<rcl_interfaces::srv::GetLoggerLevels>::SharedPtr get_loggers_service_;
rclcpp::Service<rcl_interfaces::srv::SetLoggerLevels>::SharedPtr set_loggers_service_;
};

} // namespace node_interfaces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "rclcpp/logger.hpp"
#include "rclcpp/macros.hpp"
#include "rclcpp/node_interfaces/node_services_interface.hpp"
#include "rclcpp/node_interfaces/detail/node_interfaces_helpers.hpp"
#include "rclcpp/visibility_control.hpp"

Expand Down Expand Up @@ -54,6 +55,13 @@ class NodeLoggingInterface
virtual
const char *
get_logger_name() const = 0;

/// create logger services
RCLCPP_PUBLIC
virtual
void
create_logger_services(
node_interfaces::NodeServicesInterface::SharedPtr node_services) = 0;
};

} // namespace node_interfaces
Expand Down
14 changes: 5 additions & 9 deletions rclcpp/src/rclcpp/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "rclcpp/exceptions.hpp"
#include "rclcpp/graph_listener.hpp"
#include "rclcpp/node.hpp"
#include "rclcpp/node_builtin_executor.hpp"
#include "rclcpp/node_interfaces/node_base.hpp"
#include "rclcpp/node_interfaces/node_clock.hpp"
#include "rclcpp/node_interfaces/node_graph.hpp"
Expand Down Expand Up @@ -168,7 +167,7 @@ Node::Node(
options.use_intra_process_comms(),
options.enable_topic_statistics())),
node_graph_(new rclcpp::node_interfaces::NodeGraph(node_base_.get())),
node_logging_(new rclcpp::node_interfaces::NodeLogging(node_base_.get())),
node_logging_(new rclcpp::node_interfaces::NodeLogging(node_base_)),
node_timers_(new rclcpp::node_interfaces::NodeTimers(node_base_.get())),
node_topics_(new rclcpp::node_interfaces::NodeTopics(node_base_.get(), node_timers_.get())),
node_services_(new rclcpp::node_interfaces::NodeServices(node_base_.get())),
Expand Down Expand Up @@ -208,12 +207,6 @@ Node::Node(
options.use_clock_thread()
)),
node_waitables_(new rclcpp::node_interfaces::NodeWaitables(node_base_.get())),
node_builtin_executor_(new rclcpp::NodeBuiltinExecutor(
node_base_,
node_topics_,
node_services_,
options
)),
node_options_(options),
sub_namespace_(""),
effective_namespace_(create_effective_namespace(this->get_namespace(), sub_namespace_))
Expand All @@ -232,6 +225,10 @@ Node::Node(
node_topics_->resolve_topic_name("/parameter_events"),
options.parameter_event_qos(),
rclcpp::detail::PublisherQosParametersTraits{});

if (options.enable_logger_service()) {
node_logging_->create_logger_services(node_services_);
}
}

Node::Node(
Expand Down Expand Up @@ -275,7 +272,6 @@ Node::Node(
Node::~Node()
{
// release sub-interfaces in an order that allows them to consult with node_base during tear-down
node_builtin_executor_.reset();
node_waitables_.reset();
node_time_source_.reset();
node_parameters_.reset();
Expand Down
176 changes: 0 additions & 176 deletions rclcpp/src/rclcpp/node_builtin_executor.cpp

This file was deleted.

Loading

0 comments on commit d278d1f

Please sign in to comment.