11#include <diagnostic_updater/diagnostic_updater.hpp>
12#include <rclcpp/rclcpp.hpp>
30 virtual void initialize(
const rclcpp::Node::SharedPtr& node)
57 RCLCPP_INFO(
node_->get_logger(),
"Driver test function called for driver: %s",
name_.c_str());
71 const std::filesystem::path dir(folder_name);
72 if (!std::filesystem::exists(dir))
74 std::filesystem::create_directory(dir);
78 const std::filesystem::path
check_file(
const std::string& file_name)
81 const std::filesystem::path file_path(file_name);
82 if (!std::filesystem::exists(file_path))
99 if (!
node_->has_parameter(
"use_diagnostics"))
100 node_->declare_parameter(
"use_diagnostics",
false);
111 std::function<
void(diagnostic_updater::DiagnosticStatusWrapper&)> task,
112 std::chrono::milliseconds period = std::chrono::seconds(1))
Definition driver_base.hpp:19
virtual void initialize(const rclcpp::Node::SharedPtr &node)
Initialize the driver.
Definition driver_base.hpp:30
virtual ~DriverBase()=default
void check_directory(std::string folder_name)
Check if the test directory exists, create it if not.
Definition driver_base.hpp:68
virtual std::string getName() const
Get the name of the driver.
Definition driver_base.hpp:46
virtual void test()
Test the driver.
Definition driver_base.hpp:55
std::mutex buffer_mutex_
Mutex to protect access to the driver data.
Definition driver_base.hpp:149
std::atomic< bool > is_running_
Flag to indicate if the driver thread is running.
Definition driver_base.hpp:161
std::string name_
Name of the driver.
Definition driver_base.hpp:143
std::condition_variable buffer_cv_
Condition variable to notify when new data is available.
Definition driver_base.hpp:155
rclcpp::Node::SharedPtr node_
ROS node for the driver.
Definition driver_base.hpp:138
bool diagnostics_enabled_
Flag to enable standard ROS diagnostics publishing.
Definition driver_base.hpp:166
void initialize_base(const rclcpp::Node::SharedPtr &node)
Initializer base driver in place of constructor due to plugin semantics.
Definition driver_base.hpp:95
rclcpp::TimerBase::SharedPtr diagnostics_timer_
Definition driver_base.hpp:169
const std::filesystem::path check_file(const std::string &file_name)
Definition driver_base.hpp:78
std::unique_ptr< diagnostic_updater::Updater > diagnostics_updater_
Definition driver_base.hpp:168
void disable_diagnostics()
Definition driver_base.hpp:129
virtual void deinitialize()=0
Deinitialize the driver.
bool diagnostics_enabled() const
Definition driver_base.hpp:105
void enable_diagnostics(const std::string &hardware_id, const std::string &task_name, std::function< void(diagnostic_updater::DiagnosticStatusWrapper &)> task, std::chrono::milliseconds period=std::chrono::seconds(1))
Definition driver_base.hpp:110
Definition audio_buffer.hpp:16
Base class for driver exceptions.
Definition exceptions.hpp:14