1818#define MOCK_COMPONENTS__GENERIC_SYSTEM_HPP_
1919
2020#include < string>
21+ #include < unordered_map>
22+ #include < unordered_set>
2123#include < vector>
2224
2325#include " hardware_interface/handle.hpp"
@@ -41,9 +43,7 @@ class HARDWARE_INTERFACE_PUBLIC GenericSystem : public hardware_interface::Syste
4143public:
4244 CallbackReturn on_init (const hardware_interface::HardwareInfo & info) override ;
4345
44- std::vector<hardware_interface::StateInterface> export_state_interfaces () override ;
45-
46- std::vector<hardware_interface::CommandInterface> export_command_interfaces () override ;
46+ std::vector<hardware_interface::InterfaceDescription> export_command_interfaces_2 () override ;
4747
4848 return_type prepare_command_mode_switch (
4949 const std::vector<std::string> & start_interfaces,
@@ -71,54 +71,43 @@ class HARDWARE_INTERFACE_PUBLIC GenericSystem : public hardware_interface::Syste
7171 const std::vector<std::string> standard_interfaces_ = {
7272 hardware_interface::HW_IF_POSITION, hardware_interface::HW_IF_VELOCITY,
7373 hardware_interface::HW_IF_ACCELERATION, hardware_interface::HW_IF_EFFORT};
74+ // added dynamically during on_init
75+ std::vector<std::string> non_standard_interfaces_;
7476
75- // / The size of this vector is (standard_interfaces_.size() x nr_joints)
76- std::vector<std::vector< double >> joint_commands_;
77- std::vector<std::vector< double >> joint_states_ ;
78-
79- std::vector<std::string> other_interfaces_ ;
80- // / The size of this vector is (other_interfaces_.size() x nr_joints)
81- std::vector<std::vector< double >> other_commands_ ;
82- std::vector<std::vector< double >> other_states_;
83-
84- std::vector<std::string> sensor_interfaces_;
85- // / The size of this vector is (sensor_interfaces_.size() x nr_joints)
86- std::vector <std::vector< double >> sensor_mock_commands_ ;
87- std::vector <std::vector< double >> sensor_states_ ;
88-
89- std:: vector<std::string> gpio_interfaces_;
90- // / The size of this vector is (gpio_interfaces_.size() x nr_joints)
91- std::vector<std::vector< double >> gpio_mock_commands_ ;
92- std::vector <std::vector< double >> gpio_commands_ ;
93- std::vector <std::vector< double >> gpio_states_ ;
77+ struct MimicJoint
78+ {
79+ std::string joint_name ;
80+ std::string mimic_joint_name;
81+ double multiplier = 1.0 ;
82+ };
83+ std::vector<MimicJoint> mimic_joints_ ;
84+
85+ // All the joints that are of type defined by standard_interfaces_ vector -> In {pos, vel, acc,
86+ // effort}
87+ std:: vector<std::string> std_joint_names_;
88+ std::unordered_set <std::string> std_joint_command_interface_names_ ;
89+ std::unordered_set <std::string> std_joint_state_interface_names_ ;
90+
91+ // All the joints that are of not of a type defined by standard_interfaces_ vector -> Not in {pos,
92+ // vel, acc, effort}
93+ std::vector<std::string> other_joint_names_ ;
94+ std::unordered_set <std::string> other_joint_command_interface_names_ ;
95+ std::unordered_set <std::string> other_joint_state_interface_names_ ;
9496
9597private:
96- template <typename HandleType>
97- bool get_interface (
98- const std::string & name, const std::vector<std::string> & interface_list,
99- const std::string & interface_name, const size_t vector_index,
100- std::vector<std::vector<double >> & values, std::vector<HandleType> & interfaces);
101-
102- void initialize_storage_vectors (
103- std::vector<std::vector<double >> & commands, std::vector<std::vector<double >> & states,
104- const std::vector<std::string> & interfaces,
105- const std::vector<hardware_interface::ComponentInfo> & component_infos);
106-
107- template <typename InterfaceType>
108- bool populate_interfaces (
98+ void search_and_add_interface_names (
10999 const std::vector<hardware_interface::ComponentInfo> & components,
110- std::vector<std::string> & interfaces, std::vector<std::vector<double >> & storage,
111- std::vector<InterfaceType> & target_interfaces, bool using_state_interfaces);
100+ const std::vector<std::string> & interface_list, std::vector<std::string> & vector_to_add);
112101
113102 bool use_mock_gpio_command_interfaces_;
114103 bool use_mock_sensor_command_interfaces_;
115104
116105 double position_state_following_offset_;
117106 std::string custom_interface_with_following_offset_;
118- size_t index_custom_interface_with_following_offset_ ;
107+ std::string custom_interface_name_with_following_offset_ ;
119108
120109 bool calculate_dynamics_;
121- std::vector< size_t > joint_control_mode_;
110+ std::unordered_map<std::string, size_t > joint_control_mode_;
122111
123112 bool command_propagation_disabled_;
124113};
0 commit comments