ros2_control - jazzy
Loading...
Searching...
No Matches
hardware_component_interface.hpp
1// Copyright 2025 ros2_control Development Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef HARDWARE_INTERFACE__HARDWARE_COMPONENT_INTERFACE_HPP_
16#define HARDWARE_INTERFACE__HARDWARE_COMPONENT_INTERFACE_HPP_
17
18#include <fmt/compile.h>
19
20#include <limits>
21#include <memory>
22#include <string>
23#include <unordered_map>
24#include <utility>
25#include <vector>
26
27#include "hardware_interface/component_parser.hpp"
28#include "hardware_interface/handle.hpp"
29#include "hardware_interface/hardware_info.hpp"
30#include "hardware_interface/introspection.hpp"
31#include "hardware_interface/types/hardware_component_interface_params.hpp"
32#include "hardware_interface/types/hardware_component_params.hpp"
33#include "hardware_interface/types/hardware_interface_return_values.hpp"
34#include "hardware_interface/types/hardware_interface_type_values.hpp"
35#include "hardware_interface/types/lifecycle_state_names.hpp"
36#include "hardware_interface/types/trigger_type.hpp"
37#include "lifecycle_msgs/msg/state.hpp"
38#include "rclcpp/duration.hpp"
39#include "rclcpp/logger.hpp"
40#include "rclcpp/logging.hpp"
41#include "rclcpp/node_interfaces/node_clock_interface.hpp"
42#include "rclcpp/time.hpp"
43#include "rclcpp_lifecycle/node_interfaces/lifecycle_node_interface.hpp"
44#include "rclcpp_lifecycle/state.hpp"
45#include "realtime_tools/async_function_handler.hpp"
46
47namespace hardware_interface
48{
49
50using CallbackReturn = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn;
51
60class HardwareComponentInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface
61{
62public:
64 : lifecycle_state_(
65 rclcpp_lifecycle::State(
66 lifecycle_msgs::msg::State::PRIMARY_STATE_UNKNOWN, lifecycle_state_names::UNKNOWN)),
67 logger_(rclcpp::get_logger("hardware_component_interface"))
68 {
69 }
70
72
77
79
80 virtual ~HardwareComponentInterface() = default;
81
84
91 [[deprecated("Use init(HardwareInfo, rclcpp::Logger, rclcpp::Clock::SharedPtr) instead.")]]
92 CallbackReturn init(
93 const HardwareInfo & hardware_info, rclcpp::Logger logger,
94 rclcpp::node_interfaces::NodeClockInterface::SharedPtr clock_interface)
95 {
96 return this->init(hardware_info, logger, clock_interface->get_clock());
97 }
98
101
108 [[deprecated(
109 "Replaced by CallbackReturn init(const hardware_interface::HardwareComponentParams & "
110 "params). Initialization is handled by the Framework.")]]
111 CallbackReturn init(
112 const HardwareInfo & hardware_info, rclcpp::Logger logger, rclcpp::Clock::SharedPtr clock)
113 {
115 params.hardware_info = hardware_info;
116 params.clock = clock;
117 params.logger = logger;
118 return init(params);
119 };
120
123
134 {
135 clock_ = params.clock;
136 auto logger_copy = params.logger;
137 logger_ = logger_copy.get_child(
138 "hardware_component." + params.hardware_info.type + "." + params.hardware_info.name);
139 info_ = params.hardware_info;
140 if (info_.is_async)
141 {
142 RCLCPP_INFO_STREAM(
143 get_logger(), "Starting async handler with scheduler priority: " << info_.thread_priority);
144 async_handler_ = std::make_unique<realtime_tools::AsyncFunctionHandler<return_type>>();
145 async_handler_->init(
146 [this](const rclcpp::Time & time, const rclcpp::Duration & period)
147 {
148 const auto read_start_time = std::chrono::steady_clock::now();
149 const auto ret_read = read(time, period);
150 const auto read_end_time = std::chrono::steady_clock::now();
151 read_return_info_.store(ret_read, std::memory_order_release);
152 read_execution_time_.store(
153 std::chrono::duration_cast<std::chrono::nanoseconds>(read_end_time - read_start_time),
154 std::memory_order_release);
155 if (ret_read != return_type::OK)
156 {
157 return ret_read;
158 }
159 if (info_.type != "sensor")
160 {
161 const auto write_start_time = std::chrono::steady_clock::now();
162 const auto ret_write = write(time, period);
163 const auto write_end_time = std::chrono::steady_clock::now();
164 write_return_info_.store(ret_write, std::memory_order_release);
165 write_execution_time_.store(
166 std::chrono::duration_cast<std::chrono::nanoseconds>(
167 write_end_time - write_start_time),
168 std::memory_order_release);
169 return ret_write;
170 }
171 return return_type::OK;
172 },
173 info_.thread_priority);
174 async_handler_->start_thread();
175 }
176
177 if (auto locked_executor = params.executor.lock())
178 {
179 std::string node_name = params.hardware_info.name;
180 std::transform(
181 node_name.begin(), node_name.end(), node_name.begin(),
182 [](unsigned char c) { return std::tolower(c); });
183 std::replace(node_name.begin(), node_name.end(), '/', '_');
184 hardware_component_node_ = std::make_shared<rclcpp::Node>(node_name);
185 locked_executor->add_node(hardware_component_node_->get_node_base_interface());
186 }
187 else
188 {
189 RCLCPP_WARN(
190 params.logger,
191 "Executor is not available during hardware component initialization for '%s'. Skipping "
192 "node creation!",
193 params.hardware_info.name.c_str());
194 }
195
197 interface_params.hardware_info = info_;
198 interface_params.executor = params.executor;
199 return on_init(interface_params);
200 };
201
203
208 [[deprecated("Use on_init(const HardwareComponentInterfaceParams & params) instead.")]]
209 virtual CallbackReturn on_init(const HardwareInfo & hardware_info)
210 {
211 info_ = hardware_info;
212 if (info_.type == "actuator")
213 {
214 parse_state_interface_descriptions(info_.joints, joint_state_interfaces_);
215 parse_command_interface_descriptions(info_.joints, joint_command_interfaces_);
216 }
217 else if (info_.type == "sensor")
218 {
219 parse_state_interface_descriptions(info_.joints, joint_state_interfaces_);
220 parse_state_interface_descriptions(info_.sensors, sensor_state_interfaces_);
221 }
222 else if (info_.type == "system")
223 {
224 parse_state_interface_descriptions(info_.joints, joint_state_interfaces_);
225 parse_state_interface_descriptions(info_.sensors, sensor_state_interfaces_);
226 parse_state_interface_descriptions(info_.gpios, gpio_state_interfaces_);
227 parse_command_interface_descriptions(info_.joints, joint_command_interfaces_);
228 parse_command_interface_descriptions(info_.gpios, gpio_command_interfaces_);
229 }
230 return CallbackReturn::SUCCESS;
231 };
232
234
243 virtual CallbackReturn on_init(
245 {
246 // This is done for backward compatibility with the old on_init method.
247#pragma GCC diagnostic push
248#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
249 return on_init(params.hardware_info);
250#pragma GCC diagnostic pop
251 };
252
254
265 [[deprecated(
266 "Replaced by vector<StateInterface::ConstSharedPtr> on_export_state_interfaces() method. "
267 "Exporting is handled by the Framework.")]]
268 virtual std::vector<StateInterface> export_state_interfaces()
269 {
270 // return empty vector by default. For backward compatibility we try calling
271 // export_state_interfaces() and only when empty vector is returned call
272 // on_export_state_interfaces()
273 return {};
274 }
275
282 virtual std::vector<hardware_interface::InterfaceDescription>
284 {
285 // return empty vector by default.
286 return {};
287 }
288
296 virtual std::vector<StateInterface::ConstSharedPtr> on_export_state_interfaces()
297 {
298 // import the unlisted interfaces
299 std::vector<hardware_interface::InterfaceDescription> unlisted_interface_descriptions =
301
302 std::vector<StateInterface::ConstSharedPtr> state_interfaces;
303 state_interfaces.reserve(
304 unlisted_interface_descriptions.size() + joint_state_interfaces_.size() +
305 sensor_state_interfaces_.size() + gpio_state_interfaces_.size());
306
307 // add InterfaceDescriptions and create the StateInterfaces from the descriptions and add to
308 // maps.
309 for (const auto & description : unlisted_interface_descriptions)
310 {
311 auto name = description.get_name();
312 unlisted_state_interfaces_.insert(std::make_pair(name, description));
313 auto state_interface = std::make_shared<StateInterface>(description);
314 hardware_states_.insert(std::make_pair(name, state_interface));
315 unlisted_states_.push_back(state_interface);
316 state_interfaces.push_back(std::const_pointer_cast<const StateInterface>(state_interface));
317 }
318
319 for (const auto & [name, descr] : joint_state_interfaces_)
320 {
321 auto state_interface = std::make_shared<StateInterface>(descr);
322 hardware_states_.insert(std::make_pair(name, state_interface));
323 joint_states_.push_back(state_interface);
324 state_interfaces.push_back(std::const_pointer_cast<const StateInterface>(state_interface));
325 }
326 for (const auto & [name, descr] : sensor_state_interfaces_)
327 {
328 auto state_interface = std::make_shared<StateInterface>(descr);
329 hardware_states_.insert(std::make_pair(name, state_interface));
330 sensor_states_.push_back(state_interface);
331 state_interfaces.push_back(std::const_pointer_cast<const StateInterface>(state_interface));
332 }
333 for (const auto & [name, descr] : gpio_state_interfaces_)
334 {
335 auto state_interface = std::make_shared<StateInterface>(descr);
336 hardware_states_.insert(std::make_pair(name, state_interface));
337 gpio_states_.push_back(state_interface);
338 state_interfaces.push_back(std::const_pointer_cast<const StateInterface>(state_interface));
339 }
340 return state_interfaces;
341 }
342
344
355 [[deprecated(
356 "Replaced by vector<CommandInterface::SharedPtr> on_export_command_interfaces() method. "
357 "Exporting is handled by the Framework.")]]
358 virtual std::vector<CommandInterface> export_command_interfaces()
359 {
360 // return empty vector by default. For backward compatibility we try calling
361 // export_command_interfaces() and only when empty vector is returned call
362 // on_export_command_interfaces()
363 return {};
364 }
365
372 virtual std::vector<hardware_interface::InterfaceDescription>
374 {
375 // return empty vector by default.
376 return {};
377 }
378
389 virtual std::vector<CommandInterface::SharedPtr> on_export_command_interfaces()
390 {
391 // import the unlisted interfaces
392 std::vector<hardware_interface::InterfaceDescription> unlisted_interface_descriptions =
394
395 std::vector<CommandInterface::SharedPtr> command_interfaces;
396 command_interfaces.reserve(
397 unlisted_interface_descriptions.size() + joint_command_interfaces_.size() +
398 gpio_command_interfaces_.size());
399
400 // add InterfaceDescriptions and create the CommandInterfaces from the descriptions and add to
401 // maps.
402 for (const auto & description : unlisted_interface_descriptions)
403 {
404 auto name = description.get_name();
405 unlisted_command_interfaces_.insert(std::make_pair(name, description));
406 auto command_interface = std::make_shared<CommandInterface>(description);
407 hardware_commands_.insert(std::make_pair(name, command_interface));
408 unlisted_commands_.push_back(command_interface);
409 command_interfaces.push_back(command_interface);
410 }
411
412 for (const auto & [name, descr] : joint_command_interfaces_)
413 {
414 auto command_interface = std::make_shared<CommandInterface>(descr);
415 hardware_commands_.insert(std::make_pair(name, command_interface));
416 joint_commands_.push_back(command_interface);
417 command_interfaces.push_back(command_interface);
418 }
419
420 for (const auto & [name, descr] : gpio_command_interfaces_)
421 {
422 auto command_interface = std::make_shared<CommandInterface>(descr);
423 hardware_commands_.insert(std::make_pair(name, command_interface));
424 gpio_commands_.push_back(command_interface);
425 command_interfaces.push_back(command_interface);
426 }
427 return command_interfaces;
428 }
429
431
441 virtual return_type prepare_command_mode_switch(
442 const std::vector<std::string> & /*start_interfaces*/,
443 const std::vector<std::string> & /*stop_interfaces*/)
444 {
445 return return_type::OK;
446 }
447
448 // Perform switching to the new command interface.
458 virtual return_type perform_command_mode_switch(
459 const std::vector<std::string> & /*start_interfaces*/,
460 const std::vector<std::string> & /*stop_interfaces*/)
461 {
462 return return_type::OK;
463 }
464
466
477 const rclcpp::Time & time, const rclcpp::Duration & period)
478 {
480 status.result = return_type::ERROR;
481 if (info_.is_async)
482 {
483 status.result = read_return_info_.load(std::memory_order_acquire);
484 const auto read_exec_time = read_execution_time_.load(std::memory_order_acquire);
485 if (read_exec_time.count() > 0)
486 {
487 status.execution_time = read_exec_time;
488 }
489 const auto result = async_handler_->trigger_async_callback(time, period);
490 status.successful = result.first;
491 if (!status.successful)
492 {
493 RCLCPP_WARN(
494 get_logger(),
495 "Trigger read/write called while the previous async trigger is still in progress for "
496 "hardware interface : '%s'. Failed to trigger read/write cycle!",
497 info_.name.c_str());
498 status.result = return_type::OK;
499 return status;
500 }
501 }
502 else
503 {
504 const auto start_time = std::chrono::steady_clock::now();
505 status.successful = true;
506 status.result = read(time, period);
507 status.execution_time = std::chrono::duration_cast<std::chrono::nanoseconds>(
508 std::chrono::steady_clock::now() - start_time);
509 }
510 return status;
511 }
512
514
523 virtual return_type read(const rclcpp::Time & time, const rclcpp::Duration & period) = 0;
524
526
536 const rclcpp::Time & time, const rclcpp::Duration & period)
537 {
539 status.result = return_type::ERROR;
540 if (info_.is_async)
541 {
542 status.successful = true;
543 const auto write_exec_time = write_execution_time_.load(std::memory_order_acquire);
544 if (write_exec_time.count() > 0)
545 {
546 status.execution_time = write_exec_time;
547 }
548 status.result = write_return_info_.load(std::memory_order_acquire);
549 }
550 else
551 {
552 const auto start_time = std::chrono::steady_clock::now();
553 status.successful = true;
554 status.result = write(time, period);
555 status.execution_time = std::chrono::duration_cast<std::chrono::nanoseconds>(
556 std::chrono::steady_clock::now() - start_time);
557 }
558 return status;
559 }
560
562
570 virtual return_type write(const rclcpp::Time & /*time*/, const rclcpp::Duration & /*period*/)
571 {
572 return return_type::OK;
573 }
574
576
579 const std::string & get_name() const { return info_.name; }
580
582
585 const std::string & get_group_name() const { return info_.group; }
586
588
591 const rclcpp_lifecycle::State & get_lifecycle_state() const { return lifecycle_state_; }
592
594
597 void set_lifecycle_state(const rclcpp_lifecycle::State & new_state)
598 {
599 lifecycle_state_ = new_state;
600 }
601
602 template <typename T>
603 void set_state(const std::string & interface_name, const T & value)
604 {
605 auto it = hardware_states_.find(interface_name);
606 if (it == hardware_states_.end())
607 {
608 throw std::runtime_error(
609 fmt::format(
610 FMT_COMPILE(
611 "State interface not found: {} in hardware component: {}. "
612 "This should not happen."),
613 interface_name, info_.name));
614 }
615 auto & handle = it->second;
616 std::unique_lock<std::shared_mutex> lock(handle->get_mutex());
617 std::ignore = handle->set_value(lock, value);
618 }
619
620 template <typename T = double>
621 T get_state(const std::string & interface_name) const
622 {
623 auto it = hardware_states_.find(interface_name);
624 if (it == hardware_states_.end())
625 {
626 throw std::runtime_error(
627 fmt::format(
628 FMT_COMPILE(
629 "State interface not found: {} in hardware component: {}. "
630 "This should not happen."),
631 interface_name, info_.name));
632 }
633 auto & handle = it->second;
634 std::shared_lock<std::shared_mutex> lock(handle->get_mutex());
635 const auto opt_value = handle->get_optional<T>(lock);
636 if (!opt_value)
637 {
638 throw std::runtime_error(
639 fmt::format(
640 FMT_COMPILE("Failed to get state value from interface: {}. This should not happen."),
641 interface_name));
642 }
643 return opt_value.value();
644 }
645
646 template <typename T>
647 void set_command(const std::string & interface_name, const T & value)
648 {
649 auto it = hardware_commands_.find(interface_name);
650 if (it == hardware_commands_.end())
651 {
652 throw std::runtime_error(
653 fmt::format(
654 FMT_COMPILE(
655 "Command interface not found: {} in hardware component: {}. "
656 "This should not happen."),
657 interface_name, info_.name));
658 }
659 auto & handle = it->second;
660 std::unique_lock<std::shared_mutex> lock(handle->get_mutex());
661 std::ignore = handle->set_value(lock, value);
662 }
663
664 template <typename T = double>
665 T get_command(const std::string & interface_name) const
666 {
667 auto it = hardware_commands_.find(interface_name);
668 if (it == hardware_commands_.end())
669 {
670 throw std::runtime_error(
671 fmt::format(
672 FMT_COMPILE(
673 "Command interface not found: {} in hardware component: {}. "
674 "This should not happen."),
675 interface_name, info_.name));
676 }
677 auto & handle = it->second;
678 std::shared_lock<std::shared_mutex> lock(handle->get_mutex());
679 const auto opt_value = handle->get_optional<double>(lock);
680 if (!opt_value)
681 {
682 throw std::runtime_error(
683 fmt::format(
684 FMT_COMPILE("Failed to get command value from interface: {}. This should not happen."),
685 interface_name));
686 }
687 return opt_value.value();
688 }
689
691
694 rclcpp::Logger get_logger() const { return logger_; }
695
697
700 rclcpp::Clock::SharedPtr get_clock() const { return clock_; }
701
703
706 rclcpp::Node::SharedPtr get_node() const { return hardware_component_node_; }
707
709
712 const HardwareInfo & get_hardware_info() const { return info_; }
713
715
719 {
720 read_return_info_.store(return_type::OK, std::memory_order_release);
721 read_execution_time_.store(std::chrono::nanoseconds::zero(), std::memory_order_release);
722 write_return_info_.store(return_type::OK, std::memory_order_release);
723 write_execution_time_.store(std::chrono::nanoseconds::zero(), std::memory_order_release);
724 }
725
727
730 void enable_introspection(bool enable)
731 {
732 if (enable)
733 {
734 stats_registrations_.enableAll();
735 }
736 else
737 {
738 stats_registrations_.disableAll();
739 }
740 }
741
742protected:
743 HardwareInfo info_;
744 // interface names to InterfaceDescription
745 std::unordered_map<std::string, InterfaceDescription> joint_state_interfaces_;
746 std::unordered_map<std::string, InterfaceDescription> joint_command_interfaces_;
747
748 std::unordered_map<std::string, InterfaceDescription> sensor_state_interfaces_;
749
750 std::unordered_map<std::string, InterfaceDescription> gpio_state_interfaces_;
751 std::unordered_map<std::string, InterfaceDescription> gpio_command_interfaces_;
752
753 std::unordered_map<std::string, InterfaceDescription> unlisted_state_interfaces_;
754 std::unordered_map<std::string, InterfaceDescription> unlisted_command_interfaces_;
755
756 rclcpp_lifecycle::State lifecycle_state_;
757 std::unique_ptr<realtime_tools::AsyncFunctionHandler<return_type>> async_handler_;
758
759 // Exported Command- and StateInterfaces in order they are listed in the hardware description.
760 std::vector<StateInterface::SharedPtr> joint_states_;
761 std::vector<CommandInterface::SharedPtr> joint_commands_;
762
763 std::vector<StateInterface::SharedPtr> sensor_states_;
764
765 std::vector<StateInterface::SharedPtr> gpio_states_;
766 std::vector<CommandInterface::SharedPtr> gpio_commands_;
767
768 std::vector<StateInterface::SharedPtr> unlisted_states_;
769 std::vector<CommandInterface::SharedPtr> unlisted_commands_;
770
771private:
772 rclcpp::Clock::SharedPtr clock_;
773 rclcpp::Logger logger_;
774 rclcpp::Node::SharedPtr hardware_component_node_ = nullptr;
775 // interface names to Handle accessed through getters/setters
776 std::unordered_map<std::string, StateInterface::SharedPtr> hardware_states_;
777 std::unordered_map<std::string, CommandInterface::SharedPtr> hardware_commands_;
778 std::atomic<return_type> read_return_info_ = return_type::OK;
779 std::atomic<std::chrono::nanoseconds> read_execution_time_ = std::chrono::nanoseconds::zero();
780 std::atomic<return_type> write_return_info_ = return_type::OK;
781 std::atomic<std::chrono::nanoseconds> write_execution_time_ = std::chrono::nanoseconds::zero();
782
783protected:
784 pal_statistics::RegistrationsRAII stats_registrations_;
785};
786
787} // namespace hardware_interface
788#endif // HARDWARE_INTERFACE__HARDWARE_COMPONENT_INTERFACE_HPP_
Virtual base class for all hardware components (Actuators, Sensors, and Systems).
Definition hardware_component_interface.hpp:61
const std::string & get_name() const
Get name of the hardware.
Definition hardware_component_interface.hpp:579
void prepare_for_activation()
Prepare for the activation of the hardware.
Definition hardware_component_interface.hpp:718
virtual std::vector< StateInterface > export_state_interfaces()
Exports all state interfaces for this hardware interface.
Definition hardware_component_interface.hpp:268
const rclcpp_lifecycle::State & get_lifecycle_state() const
Get life-cycle state of the hardware.
Definition hardware_component_interface.hpp:591
virtual return_type read(const rclcpp::Time &time, const rclcpp::Duration &period)=0
Read the current state values from the hardware.
virtual return_type write(const rclcpp::Time &, const rclcpp::Duration &)
Write the current command values to the hardware.
Definition hardware_component_interface.hpp:570
virtual std::vector< StateInterface::ConstSharedPtr > on_export_state_interfaces()
Definition hardware_component_interface.hpp:296
virtual std::vector< hardware_interface::InterfaceDescription > export_unlisted_command_interface_descriptions()
Definition hardware_component_interface.hpp:373
virtual std::vector< hardware_interface::InterfaceDescription > export_unlisted_state_interface_descriptions()
Definition hardware_component_interface.hpp:283
HardwareComponentCycleStatus trigger_read(const rclcpp::Time &time, const rclcpp::Duration &period)
Triggers the read method synchronously or asynchronously depending on the HardwareInfo.
Definition hardware_component_interface.hpp:476
void set_lifecycle_state(const rclcpp_lifecycle::State &new_state)
Set life-cycle state of the hardware.
Definition hardware_component_interface.hpp:597
virtual return_type perform_command_mode_switch(const std::vector< std::string > &, const std::vector< std::string > &)
Definition hardware_component_interface.hpp:458
const std::string & get_group_name() const
Get name of the hardware group to which it belongs to.
Definition hardware_component_interface.hpp:585
HardwareComponentCycleStatus trigger_write(const rclcpp::Time &time, const rclcpp::Duration &period)
Triggers the write method synchronously or asynchronously depending on the HardwareInfo.
Definition hardware_component_interface.hpp:535
CallbackReturn init(const HardwareInfo &hardware_info, rclcpp::Logger logger, rclcpp::node_interfaces::NodeClockInterface::SharedPtr clock_interface)
Definition hardware_component_interface.hpp:92
HardwareComponentInterface(const HardwareComponentInterface &other)=delete
HardwareComponentInterface copy constructor is actively deleted.
rclcpp::Node::SharedPtr get_node() const
Get the default node of the Interface.
Definition hardware_component_interface.hpp:706
virtual return_type prepare_command_mode_switch(const std::vector< std::string > &, const std::vector< std::string > &)
Prepare for a new command interface switch.
Definition hardware_component_interface.hpp:441
CallbackReturn init(const hardware_interface::HardwareComponentParams &params)
Definition hardware_component_interface.hpp:133
CallbackReturn init(const HardwareInfo &hardware_info, rclcpp::Logger logger, rclcpp::Clock::SharedPtr clock)
Definition hardware_component_interface.hpp:111
void enable_introspection(bool enable)
Enable or disable introspection of the hardware.
Definition hardware_component_interface.hpp:730
rclcpp::Logger get_logger() const
Get the logger of the Interface.
Definition hardware_component_interface.hpp:694
virtual std::vector< CommandInterface > export_command_interfaces()
Exports all command interfaces for this hardware interface.
Definition hardware_component_interface.hpp:358
virtual std::vector< CommandInterface::SharedPtr > on_export_command_interfaces()
Definition hardware_component_interface.hpp:389
rclcpp::Clock::SharedPtr get_clock() const
Get the clock of the Interface.
Definition hardware_component_interface.hpp:700
const HardwareInfo & get_hardware_info() const
Get the hardware info of the Interface.
Definition hardware_component_interface.hpp:712
virtual CallbackReturn on_init(const hardware_interface::HardwareComponentInterfaceParams &params)
Initialization of the hardware interface from data parsed from the robot's URDF.
Definition hardware_component_interface.hpp:243
virtual CallbackReturn on_init(const HardwareInfo &hardware_info)
Initialization of the hardware interface from data parsed from the robot's URDF.
Definition hardware_component_interface.hpp:209
Definition actuator.hpp:22
std::vector< InterfaceDescription > parse_command_interface_descriptions(const std::vector< ComponentInfo > &component_info)
Definition component_parser.cpp:1067
std::vector< InterfaceDescription > parse_state_interface_descriptions(const std::vector< ComponentInfo > &component_info)
Definition component_parser.cpp:1034
Definition hardware_interface_return_values.hpp:41
Parameters required for the initialization of a specific hardware component plugin....
Definition hardware_component_interface_params.hpp:32
rclcpp::Executor::WeakPtr executor
Weak pointer to the rclcpp::Executor instance. Hardware components can use this (after locking) to ad...
Definition hardware_component_interface_params.hpp:46
hardware_interface::HardwareInfo hardware_info
Reference to the HardwareInfo struct for this specific component, parsed from the URDF....
Definition hardware_component_interface_params.hpp:39
Parameters required for the initialization of a specific hardware component plugin....
Definition hardware_component_params.hpp:32
rclcpp::Executor::WeakPtr executor
Weak pointer to the rclcpp::Executor instance. Hardware components can use this (after locking) to ad...
Definition hardware_component_params.hpp:57
rclcpp::Logger logger
A logger instance taken from resource manager.
Definition hardware_component_params.hpp:44
rclcpp::Clock::SharedPtr clock
Shared pointer to the rclcpp::Clock to be used by this hardware component. Typically,...
Definition hardware_component_params.hpp:50
hardware_interface::HardwareInfo hardware_info
Reference to the HardwareInfo struct for this specific component, parsed from the URDF....
Definition hardware_component_params.hpp:39
This structure stores information about hardware defined in a robot's URDF.
Definition hardware_info.hpp:234
std::string type
Type of the hardware: actuator, sensor or system.
Definition hardware_info.hpp:238
int thread_priority
Async thread priority.
Definition hardware_info.hpp:246
std::string group
Hardware group to which the hardware belongs.
Definition hardware_info.hpp:240
bool is_async
Component is async.
Definition hardware_info.hpp:244
std::vector< ComponentInfo > gpios
Definition hardware_info.hpp:269
std::vector< ComponentInfo > joints
Definition hardware_info.hpp:255
std::string name
Name of the hardware.
Definition hardware_info.hpp:236
std::vector< ComponentInfo > sensors
Definition hardware_info.hpp:264