ros2_control - rolling
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/version.h"
44#include "rclcpp_lifecycle/node_interfaces/lifecycle_node_interface.hpp"
45#include "rclcpp_lifecycle/state.hpp"
46#include "realtime_tools/async_function_handler.hpp"
47
48namespace hardware_interface
49{
50
51static inline rclcpp::NodeOptions get_hardware_component_node_options()
52{
53 rclcpp::NodeOptions node_options;
54// \note The versions conditioning is added here to support the source-compatibility with Humble
55#if RCLCPP_VERSION_MAJOR >= 21
56 node_options.enable_logger_service(true);
57#endif
58 return node_options;
59}
60
61using CallbackReturn = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn;
62
71class HardwareComponentInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface
72{
73public:
75 : lifecycle_state_(
76 rclcpp_lifecycle::State(
77 lifecycle_msgs::msg::State::PRIMARY_STATE_UNKNOWN, lifecycle_state_names::UNKNOWN)),
78 logger_(rclcpp::get_logger("hardware_component_interface"))
79 {
80 }
81
83
88
90
91 virtual ~HardwareComponentInterface() = default;
92
95
102 [[deprecated(
103 "Replaced by CallbackReturn init(const hardware_interface::HardwareComponentParams & "
104 "params). Initialization is handled by the Framework.")]]
105 CallbackReturn init(
106 const HardwareInfo & hardware_info, rclcpp::Logger logger, rclcpp::Clock::SharedPtr clock)
107 {
109 params.hardware_info = hardware_info;
110 params.clock = clock;
111 params.logger = logger;
112 return init(params);
113 };
114
117
128 {
129 clock_ = params.clock;
130 auto logger_copy = params.logger;
131 logger_ = logger_copy.get_child(
132 "hardware_component." + params.hardware_info.type + "." + params.hardware_info.name);
133 info_ = params.hardware_info;
134 if (info_.is_async)
135 {
136 RCLCPP_INFO_STREAM(
137 get_logger(), "Starting async handler with scheduler priority: " << info_.thread_priority);
138 async_handler_ = std::make_unique<realtime_tools::AsyncFunctionHandler<return_type>>();
139 async_handler_->init(
140 [this](const rclcpp::Time & time, const rclcpp::Duration & period)
141 {
142 const auto read_start_time = std::chrono::steady_clock::now();
143 const auto ret_read = read(time, period);
144 const auto read_end_time = std::chrono::steady_clock::now();
145 read_return_info_.store(ret_read, std::memory_order_release);
146 read_execution_time_.store(
147 std::chrono::duration_cast<std::chrono::nanoseconds>(read_end_time - read_start_time),
148 std::memory_order_release);
149 if (ret_read != return_type::OK)
150 {
151 return ret_read;
152 }
153 if (info_.type != "sensor")
154 {
155 const auto write_start_time = std::chrono::steady_clock::now();
156 const auto ret_write = write(time, period);
157 const auto write_end_time = std::chrono::steady_clock::now();
158 write_return_info_.store(ret_write, std::memory_order_release);
159 write_execution_time_.store(
160 std::chrono::duration_cast<std::chrono::nanoseconds>(
161 write_end_time - write_start_time),
162 std::memory_order_release);
163 return ret_write;
164 }
165 return return_type::OK;
166 },
167 info_.thread_priority);
168 async_handler_->start_thread();
169 }
170
171 if (auto locked_executor = params.executor.lock())
172 {
173 std::string node_name = params.hardware_info.name;
174 std::transform(
175 node_name.begin(), node_name.end(), node_name.begin(),
176 [](unsigned char c) { return std::tolower(c); });
177 std::replace(node_name.begin(), node_name.end(), '/', '_');
178 hardware_component_node_ =
179 std::make_shared<rclcpp::Node>(node_name, get_hardware_component_node_options());
180 locked_executor->add_node(hardware_component_node_->get_node_base_interface());
181 }
182 else
183 {
184 RCLCPP_WARN(
185 params.logger,
186 "Executor is not available during hardware component initialization for '%s'. Skipping "
187 "node creation!",
188 params.hardware_info.name.c_str());
189 }
190
192 interface_params.hardware_info = info_;
193 interface_params.executor = params.executor;
194 return on_init(interface_params);
195 };
196
198
203 [[deprecated("Use on_init(const HardwareComponentInterfaceParams & params) instead.")]]
204 virtual CallbackReturn on_init(const HardwareInfo & hardware_info)
205 {
206 info_ = hardware_info;
207 if (info_.type == "actuator")
208 {
209 parse_state_interface_descriptions(info_.joints, joint_state_interfaces_);
210 parse_command_interface_descriptions(info_.joints, joint_command_interfaces_);
211 }
212 else if (info_.type == "sensor")
213 {
214 parse_state_interface_descriptions(info_.joints, joint_state_interfaces_);
215 parse_state_interface_descriptions(info_.sensors, sensor_state_interfaces_);
216 }
217 else if (info_.type == "system")
218 {
219 parse_state_interface_descriptions(info_.joints, joint_state_interfaces_);
220 parse_state_interface_descriptions(info_.sensors, sensor_state_interfaces_);
221 parse_state_interface_descriptions(info_.gpios, gpio_state_interfaces_);
222 parse_command_interface_descriptions(info_.joints, joint_command_interfaces_);
223 parse_command_interface_descriptions(info_.gpios, gpio_command_interfaces_);
224 }
225 return CallbackReturn::SUCCESS;
226 };
227
229
238 virtual CallbackReturn on_init(
240 {
241 // This is done for backward compatibility with the old on_init method.
242#pragma GCC diagnostic push
243#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
244 return on_init(params.hardware_info);
245#pragma GCC diagnostic pop
246 };
247
249
260 [[deprecated(
261 "Replaced by vector<StateInterface::ConstSharedPtr> on_export_state_interfaces() method. "
262 "Exporting is handled by the Framework.")]]
263 virtual std::vector<StateInterface> export_state_interfaces()
264 {
265 // return empty vector by default. For backward compatibility we try calling
266 // export_state_interfaces() and only when empty vector is returned call
267 // on_export_state_interfaces()
268 return {};
269 }
270
277 virtual std::vector<hardware_interface::InterfaceDescription>
279 {
280 // return empty vector by default.
281 return {};
282 }
283
291 virtual std::vector<StateInterface::ConstSharedPtr> on_export_state_interfaces()
292 {
293 // import the unlisted interfaces
294 std::vector<hardware_interface::InterfaceDescription> unlisted_interface_descriptions =
296
297 std::vector<StateInterface::ConstSharedPtr> state_interfaces;
298 state_interfaces.reserve(
299 unlisted_interface_descriptions.size() + joint_state_interfaces_.size() +
300 sensor_state_interfaces_.size() + gpio_state_interfaces_.size());
301
302 // add InterfaceDescriptions and create the StateInterfaces from the descriptions and add to
303 // maps.
304 for (const auto & description : unlisted_interface_descriptions)
305 {
306 auto name = description.get_name();
307 unlisted_state_interfaces_.insert(std::make_pair(name, description));
308 auto state_interface = std::make_shared<StateInterface>(description);
309 hardware_states_.insert(std::make_pair(name, state_interface));
310 unlisted_states_.push_back(state_interface);
311 state_interfaces.push_back(std::const_pointer_cast<const StateInterface>(state_interface));
312 }
313
314 for (const auto & [name, descr] : joint_state_interfaces_)
315 {
316 auto state_interface = std::make_shared<StateInterface>(descr);
317 hardware_states_.insert(std::make_pair(name, state_interface));
318 joint_states_.push_back(state_interface);
319 state_interfaces.push_back(std::const_pointer_cast<const StateInterface>(state_interface));
320 }
321 for (const auto & [name, descr] : sensor_state_interfaces_)
322 {
323 auto state_interface = std::make_shared<StateInterface>(descr);
324 hardware_states_.insert(std::make_pair(name, state_interface));
325 sensor_states_.push_back(state_interface);
326 state_interfaces.push_back(std::const_pointer_cast<const StateInterface>(state_interface));
327 }
328 for (const auto & [name, descr] : gpio_state_interfaces_)
329 {
330 auto state_interface = std::make_shared<StateInterface>(descr);
331 hardware_states_.insert(std::make_pair(name, state_interface));
332 gpio_states_.push_back(state_interface);
333 state_interfaces.push_back(std::const_pointer_cast<const StateInterface>(state_interface));
334 }
335 return state_interfaces;
336 }
337
339
350 [[deprecated(
351 "Replaced by vector<CommandInterface::SharedPtr> on_export_command_interfaces() method. "
352 "Exporting is handled by the Framework.")]]
353 virtual std::vector<CommandInterface> export_command_interfaces()
354 {
355 // return empty vector by default. For backward compatibility we try calling
356 // export_command_interfaces() and only when empty vector is returned call
357 // on_export_command_interfaces()
358 return {};
359 }
360
367 virtual std::vector<hardware_interface::InterfaceDescription>
369 {
370 // return empty vector by default.
371 return {};
372 }
373
384 virtual std::vector<CommandInterface::SharedPtr> on_export_command_interfaces()
385 {
386 // import the unlisted interfaces
387 std::vector<hardware_interface::InterfaceDescription> unlisted_interface_descriptions =
389
390 std::vector<CommandInterface::SharedPtr> command_interfaces;
391 command_interfaces.reserve(
392 unlisted_interface_descriptions.size() + joint_command_interfaces_.size() +
393 gpio_command_interfaces_.size());
394
395 // add InterfaceDescriptions and create the CommandInterfaces from the descriptions and add to
396 // maps.
397 for (const auto & description : unlisted_interface_descriptions)
398 {
399 auto name = description.get_name();
400 unlisted_command_interfaces_.insert(std::make_pair(name, description));
401 auto command_interface = std::make_shared<CommandInterface>(description);
402 hardware_commands_.insert(std::make_pair(name, command_interface));
403 unlisted_commands_.push_back(command_interface);
404 command_interfaces.push_back(command_interface);
405 }
406
407 for (const auto & [name, descr] : joint_command_interfaces_)
408 {
409 auto command_interface = std::make_shared<CommandInterface>(descr);
410 hardware_commands_.insert(std::make_pair(name, command_interface));
411 joint_commands_.push_back(command_interface);
412 command_interfaces.push_back(command_interface);
413 }
414
415 for (const auto & [name, descr] : gpio_command_interfaces_)
416 {
417 auto command_interface = std::make_shared<CommandInterface>(descr);
418 hardware_commands_.insert(std::make_pair(name, command_interface));
419 gpio_commands_.push_back(command_interface);
420 command_interfaces.push_back(command_interface);
421 }
422 return command_interfaces;
423 }
424
426
436 virtual return_type prepare_command_mode_switch(
437 const std::vector<std::string> & /*start_interfaces*/,
438 const std::vector<std::string> & /*stop_interfaces*/)
439 {
440 return return_type::OK;
441 }
442
443 // Perform switching to the new command interface.
453 virtual return_type perform_command_mode_switch(
454 const std::vector<std::string> & /*start_interfaces*/,
455 const std::vector<std::string> & /*stop_interfaces*/)
456 {
457 return return_type::OK;
458 }
459
461
472 const rclcpp::Time & time, const rclcpp::Duration & period)
473 {
475 status.result = return_type::ERROR;
476 if (info_.is_async)
477 {
478 status.result = read_return_info_.load(std::memory_order_acquire);
479 const auto read_exec_time = read_execution_time_.load(std::memory_order_acquire);
480 if (read_exec_time.count() > 0)
481 {
482 status.execution_time = read_exec_time;
483 }
484 const auto result = async_handler_->trigger_async_callback(time, period);
485 status.successful = result.first;
486 if (!status.successful)
487 {
488 RCLCPP_WARN(
489 get_logger(),
490 "Trigger read/write called while the previous async trigger is still in progress for "
491 "hardware interface : '%s'. Failed to trigger read/write cycle!",
492 info_.name.c_str());
493 status.result = return_type::OK;
494 return status;
495 }
496 }
497 else
498 {
499 const auto start_time = std::chrono::steady_clock::now();
500 status.successful = true;
501 status.result = read(time, period);
502 status.execution_time = std::chrono::duration_cast<std::chrono::nanoseconds>(
503 std::chrono::steady_clock::now() - start_time);
504 }
505 return status;
506 }
507
509
518 virtual return_type read(const rclcpp::Time & time, const rclcpp::Duration & period) = 0;
519
521
531 const rclcpp::Time & time, const rclcpp::Duration & period)
532 {
534 status.result = return_type::ERROR;
535 if (info_.is_async)
536 {
537 status.successful = true;
538 const auto write_exec_time = write_execution_time_.load(std::memory_order_acquire);
539 if (write_exec_time.count() > 0)
540 {
541 status.execution_time = write_exec_time;
542 }
543 status.result = write_return_info_.load(std::memory_order_acquire);
544 }
545 else
546 {
547 const auto start_time = std::chrono::steady_clock::now();
548 status.successful = true;
549 status.result = write(time, period);
550 status.execution_time = std::chrono::duration_cast<std::chrono::nanoseconds>(
551 std::chrono::steady_clock::now() - start_time);
552 }
553 return status;
554 }
555
557
565 virtual return_type write(const rclcpp::Time & /*time*/, const rclcpp::Duration & /*period*/)
566 {
567 return return_type::OK;
568 }
569
571
574 const std::string & get_name() const { return info_.name; }
575
577
580 const std::string & get_group_name() const { return info_.group; }
581
583
586 const rclcpp_lifecycle::State & get_lifecycle_state() const { return lifecycle_state_; }
587
589
592 void set_lifecycle_state(const rclcpp_lifecycle::State & new_state)
593 {
594 lifecycle_state_ = new_state;
595 }
596
598
605 template <typename T>
606 void set_state(const std::string & interface_name, const T & value)
607 {
608 auto it = hardware_states_.find(interface_name);
609 if (it == hardware_states_.end())
610 {
611 throw std::runtime_error(
612 fmt::format(
613 FMT_COMPILE(
614 "State interface not found: {} in hardware component: {}. "
615 "This should not happen."),
616 interface_name, info_.name));
617 }
618 auto & handle = it->second;
619 std::unique_lock<std::shared_mutex> lock(handle->get_mutex());
620 std::ignore = handle->set_value(lock, value);
621 }
622
624
631 template <typename T = double>
632 T get_state(const std::string & interface_name) const
633 {
634 auto it = hardware_states_.find(interface_name);
635 if (it == hardware_states_.end())
636 {
637 throw std::runtime_error(
638 fmt::format(
639 FMT_COMPILE(
640 "State interface not found: {} in hardware component: {}. "
641 "This should not happen."),
642 interface_name, info_.name));
643 }
644 auto & handle = it->second;
645 std::shared_lock<std::shared_mutex> lock(handle->get_mutex());
646 const auto opt_value = handle->get_optional<T>(lock);
647 if (!opt_value)
648 {
649 throw std::runtime_error(
650 fmt::format(
651 FMT_COMPILE("Failed to get state value from interface: {}. This should not happen."),
652 interface_name));
653 }
654 return opt_value.value();
655 }
656
658
666 template <typename T>
667 void set_command(const std::string & interface_name, const T & value)
668 {
669 auto it = hardware_commands_.find(interface_name);
670 if (it == hardware_commands_.end())
671 {
672 throw std::runtime_error(
673 fmt::format(
674 FMT_COMPILE(
675 "Command interface not found: {} in hardware component: {}. "
676 "This should not happen."),
677 interface_name, info_.name));
678 }
679 auto & handle = it->second;
680 std::unique_lock<std::shared_mutex> lock(handle->get_mutex());
681 std::ignore = handle->set_value(lock, value);
682 }
683
685
692 template <typename T = double>
693 T get_command(const std::string & interface_name) const
694 {
695 auto it = hardware_commands_.find(interface_name);
696 if (it == hardware_commands_.end())
697 {
698 throw std::runtime_error(
699 fmt::format(
700 FMT_COMPILE(
701 "Command interface not found: {} in hardware component: {}. "
702 "This should not happen."),
703 interface_name, info_.name));
704 }
705 auto & handle = it->second;
706 std::shared_lock<std::shared_mutex> lock(handle->get_mutex());
707 const auto opt_value = handle->get_optional<T>(lock);
708 if (!opt_value)
709 {
710 throw std::runtime_error(
711 fmt::format(
712 FMT_COMPILE("Failed to get command value from interface: {}. This should not happen."),
713 interface_name));
714 }
715 return opt_value.value();
716 }
717
719
722 rclcpp::Logger get_logger() const { return logger_; }
723
725
728 rclcpp::Clock::SharedPtr get_clock() const { return clock_; }
729
731
734 rclcpp::Node::SharedPtr get_node() const { return hardware_component_node_; }
735
737
740 const HardwareInfo & get_hardware_info() const { return info_; }
741
743
747 {
748 read_return_info_.store(return_type::OK, std::memory_order_release);
749 read_execution_time_.store(std::chrono::nanoseconds::zero(), std::memory_order_release);
750 write_return_info_.store(return_type::OK, std::memory_order_release);
751 write_execution_time_.store(std::chrono::nanoseconds::zero(), std::memory_order_release);
752 }
753
755
758 void enable_introspection(bool enable)
759 {
760 if (enable)
761 {
762 stats_registrations_.enableAll();
763 }
764 else
765 {
766 stats_registrations_.disableAll();
767 }
768 }
769
770protected:
771 HardwareInfo info_;
772 // interface names to InterfaceDescription
773 std::unordered_map<std::string, InterfaceDescription> joint_state_interfaces_;
774 std::unordered_map<std::string, InterfaceDescription> joint_command_interfaces_;
775
776 std::unordered_map<std::string, InterfaceDescription> sensor_state_interfaces_;
777
778 std::unordered_map<std::string, InterfaceDescription> gpio_state_interfaces_;
779 std::unordered_map<std::string, InterfaceDescription> gpio_command_interfaces_;
780
781 std::unordered_map<std::string, InterfaceDescription> unlisted_state_interfaces_;
782 std::unordered_map<std::string, InterfaceDescription> unlisted_command_interfaces_;
783
784 rclcpp_lifecycle::State lifecycle_state_;
785 std::unique_ptr<realtime_tools::AsyncFunctionHandler<return_type>> async_handler_;
786
787 // Exported Command- and StateInterfaces in order they are listed in the hardware description.
788 std::vector<StateInterface::SharedPtr> joint_states_;
789 std::vector<CommandInterface::SharedPtr> joint_commands_;
790
791 std::vector<StateInterface::SharedPtr> sensor_states_;
792
793 std::vector<StateInterface::SharedPtr> gpio_states_;
794 std::vector<CommandInterface::SharedPtr> gpio_commands_;
795
796 std::vector<StateInterface::SharedPtr> unlisted_states_;
797 std::vector<CommandInterface::SharedPtr> unlisted_commands_;
798
799private:
800 rclcpp::Clock::SharedPtr clock_;
801 rclcpp::Logger logger_;
802 rclcpp::Node::SharedPtr hardware_component_node_ = nullptr;
803 // interface names to Handle accessed through getters/setters
804 std::unordered_map<std::string, StateInterface::SharedPtr> hardware_states_;
805 std::unordered_map<std::string, CommandInterface::SharedPtr> hardware_commands_;
806 std::atomic<return_type> read_return_info_ = return_type::OK;
807 std::atomic<std::chrono::nanoseconds> read_execution_time_ = std::chrono::nanoseconds::zero();
808 std::atomic<return_type> write_return_info_ = return_type::OK;
809 std::atomic<std::chrono::nanoseconds> write_execution_time_ = std::chrono::nanoseconds::zero();
810
811protected:
812 pal_statistics::RegistrationsRAII stats_registrations_;
813};
814
815} // namespace hardware_interface
816#endif // HARDWARE_INTERFACE__HARDWARE_COMPONENT_INTERFACE_HPP_
Virtual base class for all hardware components (Actuators, Sensors, and Systems).
Definition hardware_component_interface.hpp:72
const std::string & get_name() const
Get name of the hardware.
Definition hardware_component_interface.hpp:574
void prepare_for_activation()
Prepare for the activation of the hardware.
Definition hardware_component_interface.hpp:746
T get_state(const std::string &interface_name) const
Get the value from a state interface.
Definition hardware_component_interface.hpp:632
virtual std::vector< StateInterface > export_state_interfaces()
Exports all state interfaces for this hardware interface.
Definition hardware_component_interface.hpp:263
const rclcpp_lifecycle::State & get_lifecycle_state() const
Get life-cycle state of the hardware.
Definition hardware_component_interface.hpp:586
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:565
virtual std::vector< StateInterface::ConstSharedPtr > on_export_state_interfaces()
Definition hardware_component_interface.hpp:291
virtual std::vector< hardware_interface::InterfaceDescription > export_unlisted_command_interface_descriptions()
Definition hardware_component_interface.hpp:368
virtual std::vector< hardware_interface::InterfaceDescription > export_unlisted_state_interface_descriptions()
Definition hardware_component_interface.hpp:278
void set_state(const std::string &interface_name, const T &value)
Set the value of a state interface.
Definition hardware_component_interface.hpp:606
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:471
void set_lifecycle_state(const rclcpp_lifecycle::State &new_state)
Set life-cycle state of the hardware.
Definition hardware_component_interface.hpp:592
virtual return_type perform_command_mode_switch(const std::vector< std::string > &, const std::vector< std::string > &)
Definition hardware_component_interface.hpp:453
const std::string & get_group_name() const
Get name of the hardware group to which it belongs to.
Definition hardware_component_interface.hpp:580
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:530
HardwareComponentInterface(const HardwareComponentInterface &other)=delete
HardwareComponentInterface copy constructor is actively deleted.
void set_command(const std::string &interface_name, const T &value)
Set the value of a command interface.
Definition hardware_component_interface.hpp:667
rclcpp::Node::SharedPtr get_node() const
Get the default node of the HardwareComponentInterface.
Definition hardware_component_interface.hpp:734
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:436
CallbackReturn init(const hardware_interface::HardwareComponentParams &params)
Definition hardware_component_interface.hpp:127
CallbackReturn init(const HardwareInfo &hardware_info, rclcpp::Logger logger, rclcpp::Clock::SharedPtr clock)
Definition hardware_component_interface.hpp:105
void enable_introspection(bool enable)
Enable or disable introspection of the hardware.
Definition hardware_component_interface.hpp:758
rclcpp::Logger get_logger() const
Get the logger of the HardwareComponentInterface.
Definition hardware_component_interface.hpp:722
T get_command(const std::string &interface_name) const
Get the value from a command interface.
Definition hardware_component_interface.hpp:693
virtual std::vector< CommandInterface > export_command_interfaces()
Exports all command interfaces for this hardware interface.
Definition hardware_component_interface.hpp:353
virtual std::vector< CommandInterface::SharedPtr > on_export_command_interfaces()
Definition hardware_component_interface.hpp:384
rclcpp::Clock::SharedPtr get_clock() const
Get the clock.
Definition hardware_component_interface.hpp:728
const HardwareInfo & get_hardware_info() const
Get the hardware info of the HardwareComponentInterface.
Definition hardware_component_interface.hpp:740
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:238
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:204
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:252
std::string type
Type of the hardware: actuator, sensor or system.
Definition hardware_info.hpp:256
int thread_priority
Async thread priority.
Definition hardware_info.hpp:264
std::string group
Hardware group to which the hardware belongs.
Definition hardware_info.hpp:258
bool is_async
Component is async.
Definition hardware_info.hpp:262
std::vector< ComponentInfo > gpios
Definition hardware_info.hpp:287
std::vector< ComponentInfo > joints
Definition hardware_info.hpp:273
std::string name
Name of the hardware.
Definition hardware_info.hpp:254
std::vector< ComponentInfo > sensors
Definition hardware_info.hpp:282