.. _program_listing_file__tmp_ws_src_schunk_svh_ros_driver_schunk_svh_driver_include_schunk_svh_driver_system_interface.hpp: Program Listing for File system_interface.hpp ============================================= |exhale_lsh| :ref:`Return to documentation for file ` (``/tmp/ws/src/schunk_svh_ros_driver/schunk_svh_driver/include/schunk_svh_driver/system_interface.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // // © Copyright 2022 SCHUNK Mobile Greifsysteme GmbH, Lauffen/Neckar Germany // © Copyright 2022 FZI Forschungszentrum Informatik, Karlsruhe, Germany // // This file is part of the Schunk SVH Driver. // // The Schunk SVH Driver is free software: you can redistribute it and/or // modify it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or (at your // option) any later version. // // The Schunk SVH Driver is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General // Public License for more details. // // You should have received a copy of the GNU General Public License along with // the Schunk SVH Driver. If not, see . // //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- #pragma once #include #include #include #include "hardware_interface/handle.hpp" #include "hardware_interface/hardware_info.hpp" #include "hardware_interface/system_interface.hpp" #include "rclcpp/macros.hpp" #include "rclcpp/rclcpp.hpp" #include "rclcpp_lifecycle/node_interfaces/lifecycle_node_interface.hpp" #include "rclcpp_lifecycle/state.hpp" #include "schunk_svh_library/control/SVHFingerManager.h" namespace schunk_svh_driver { // Additional hardware interfaces for the SVH: constexpr char HW_IF_CURRENT[] = "current"; class SystemInterface : public hardware_interface::SystemInterface { public: using return_type = hardware_interface::return_type; RCLCPP_SHARED_PTR_DEFINITIONS(SystemInterface) CallbackReturn on_init(const hardware_interface::HardwareInfo & info) override; CallbackReturn on_activate(const rclcpp_lifecycle::State & previous_state) override; CallbackReturn on_shutdown(const rclcpp_lifecycle::State & previous_state) override; std::vector export_state_interfaces() override; std::vector export_command_interfaces() override; return_type prepare_command_mode_switch( const std::vector & start_interfaces, const std::vector & stop_interfaces) override; return_type read(const rclcpp::Time & time, const rclcpp::Duration & period) override; return_type write(const rclcpp::Time & time, const rclcpp::Duration & period) override; private: // Initialization of the SVH in a separate thread to meet ROS2-control's // timing requirements. void init(); std::atomic m_initialized{false}; std::thread m_init_thread; // Handle to the SVH driver library std::unique_ptr m_svh; // Command buffers for the controllers std::vector m_position_commands; // State buffers for the controllers std::vector m_positions; std::vector m_velocities; std::vector m_efforts; std::vector m_currents; // Parameters std::string m_device_file; }; } // namespace schunk_svh_driver