.. _program_listing_file_include_mock_components_generic_system.hpp: Program Listing for File generic_system.hpp =========================================== |exhale_lsh| :ref:`Return to documentation for file ` (``include/mock_components/generic_system.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // Copyright (c) 2021 PickNik, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Author: Jafar Abdi, Denis Stogl #ifndef MOCK_COMPONENTS__GENERIC_SYSTEM_HPP_ #define MOCK_COMPONENTS__GENERIC_SYSTEM_HPP_ #include #include #include "hardware_interface/handle.hpp" #include "hardware_interface/hardware_info.hpp" #include "hardware_interface/system_interface.hpp" #include "hardware_interface/types/hardware_interface_return_values.hpp" #include "hardware_interface/types/hardware_interface_type_values.hpp" using hardware_interface::return_type; namespace mock_components { using CallbackReturn = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn; static constexpr size_t POSITION_INTERFACE_INDEX = 0; static constexpr size_t VELOCITY_INTERFACE_INDEX = 1; static constexpr size_t ACCELERATION_INTERFACE_INDEX = 2; class HARDWARE_INTERFACE_PUBLIC GenericSystem : public hardware_interface::SystemInterface { public: CallbackReturn on_init(const hardware_interface::HardwareInfo & info) 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 perform_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 { return return_type::OK; } protected: const std::vector standard_interfaces_ = { hardware_interface::HW_IF_POSITION, hardware_interface::HW_IF_VELOCITY, hardware_interface::HW_IF_ACCELERATION, hardware_interface::HW_IF_EFFORT}; std::vector> joint_commands_; std::vector> joint_states_; std::vector other_interfaces_; std::vector> other_commands_; std::vector> other_states_; std::vector sensor_interfaces_; std::vector> sensor_mock_commands_; std::vector> sensor_states_; std::vector gpio_interfaces_; std::vector> gpio_mock_commands_; std::vector> gpio_commands_; std::vector> gpio_states_; private: template bool get_interface( const std::string & name, const std::vector & interface_list, const std::string & interface_name, const size_t vector_index, std::vector> & values, std::vector & interfaces); void initialize_storage_vectors( std::vector> & commands, std::vector> & states, const std::vector & interfaces, const std::vector & component_infos); template bool populate_interfaces( const std::vector & components, std::vector & interfaces, std::vector> & storage, std::vector & target_interfaces, bool using_state_interfaces); bool use_mock_gpio_command_interfaces_; bool use_mock_sensor_command_interfaces_; double position_state_following_offset_; std::string custom_interface_with_following_offset_; size_t index_custom_interface_with_following_offset_; bool calculate_dynamics_; std::vector joint_control_mode_; bool command_propagation_disabled_; }; typedef GenericSystem GenericRobot; } // namespace mock_components #endif // MOCK_COMPONENTS__GENERIC_SYSTEM_HPP_