Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
3359de4
Added HardwareInfo as the main structure in the robot's URDF file
destogl Aug 17, 2020
1a10488
Added new version of parser. Files checkout from #122
destogl Aug 17, 2020
a8785cb
Split Component and Hardware Infos into two files
destogl Aug 18, 2020
227a42d
Correct build and typos
destogl Aug 18, 2020
1a070c5
Correct uncrustify issues
destogl Aug 18, 2020
add3b04
Add more tests to get better coverage
destogl Aug 19, 2020
ec7d4de
Added also missing values tests
destogl Aug 19, 2020
a2e7e01
Correct lint and uncrustify
destogl Aug 19, 2020
fd97b80
Added also missing values tests
destogl Aug 19, 2020
285e42c
Correct all tests
destogl Aug 19, 2020
19cba1f
Initial version of new package implementing components for controling…
destogl Jun 12, 2020
c783704
Add control component interfaces.
destogl Jun 16, 2020
02d3ea7
Added initial tests for Joint and JointInterface
destogl Jul 27, 2020
7443f6b
Extended SensorInterface to work with hardware. Added Example for Dum…
destogl Jul 28, 2020
e4bd372
Added tests for all interfaces and implemented review comments
destogl Jul 29, 2020
e236fd0
Added HardwareInfo as the main structure in the robot's URDF file
destogl Aug 17, 2020
cf500cd
Add Hardware and Component base classes and tests.
destogl Aug 17, 2020
8151f6b
Update hardware_interface/include/hardware_interface/sensor_hardware_…
destogl Aug 18, 2020
d8257b4
Update hardware_interface/include/hardware_interface/system_hardware_…
destogl Aug 18, 2020
7051ae2
Update hardware_interface/include/hardware_interface/system_hardware_…
destogl Aug 18, 2020
91c5705
Update hardware_interface/include/hardware_interface/system_hardware_…
destogl Aug 18, 2020
9bf0c43
Split Component and Hardware Infos into two files
destogl Aug 18, 2020
36e53a5
Use separated headers for components_info and hardware_info
destogl Aug 18, 2020
9d16847
Style corrections
destogl Aug 18, 2020
b072519
Add documentation for joint and sensor components
destogl Aug 18, 2020
b22a283
Update hardware_interface/test/test_component_interfaces.cpp
destogl Aug 18, 2020
efb8b17
Style corrections
destogl Aug 18, 2020
c65af54
The base classes for Joints and Sensors are implemented
destogl Aug 18, 2020
73ff012
Add more tests to get better coverage
destogl Aug 19, 2020
2269faf
Updated after comments and added helper header
destogl Aug 19, 2020
ea4a2f8
Implementation moved to cpp files
destogl Aug 19, 2020
5cbd7a4
Removed virtual function for checking limits
destogl Aug 19, 2020
31a5d4e
Use inline functions in helper header and make API-consistent return …
destogl Aug 20, 2020
25b39f4
Correct faulty header guard
destogl Aug 20, 2020
c829d2e
Added package robot_control_components with basic component implement…
destogl Jul 15, 2020
b3df2f3
Initial verison of PositionJoint in ros2_control_components
destogl Aug 20, 2020
95cd51e
Merge remote-tracking branch 'origin/master' into robot_control_compo…
Karsten1987 Aug 24, 2020
210694b
linters
Karsten1987 Aug 24, 2020
e6cc5d7
fix package.xml
Karsten1987 Aug 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions hardware_interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ find_package(ament_cmake REQUIRED)
find_package(control_msgs REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rcpputils REQUIRED)
find_package(tinyxml2_vendor REQUIRED)
find_package(TinyXML2 REQUIRED)

add_library(
hardware_interface
Expand Down Expand Up @@ -41,6 +43,21 @@ ament_target_dependencies(
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(hardware_interface PRIVATE "HARDWARE_INTERFACE_BUILDING_DLL")

add_library(
component_parser
src/component_parser.cpp
)
target_include_directories(
component_parser
PUBLIC
include
)
ament_target_dependencies(
component_parser
TinyXML2
)
target_compile_definitions(component_parser PRIVATE "HARDWARE_INTERFACE_BUILDING_DLL")

add_library(
components
SHARED
Expand All @@ -52,8 +69,6 @@ target_include_directories(
PUBLIC
include
)
# Causes the visibility macros to use dllexport rather than dllimport,
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(components PRIVATE "HARDWARE_INTERFACE_BUILDING_DLL")

install(
Expand All @@ -63,6 +78,7 @@ install(

install(
TARGETS
component_parser
components
hardware_interface
RUNTIME DESTINATION bin
Expand Down Expand Up @@ -93,6 +109,11 @@ if(BUILD_TESTING)
target_link_libraries(test_actuator_handle hardware_interface)
ament_target_dependencies(test_actuator_handle rcpputils)

ament_add_gmock(test_component_parser test/test_component_parser.cpp)
target_include_directories(test_component_parser PRIVATE include)
target_link_libraries(test_component_parser component_parser)
ament_target_dependencies(test_component_parser TinyXML2)

ament_add_gmock(test_component_interfaces test/test_component_interfaces.cpp)
target_include_directories(test_component_interfaces PRIVATE include)
target_link_libraries(test_component_interfaces components hardware_interface)
Expand All @@ -102,6 +123,7 @@ ament_export_include_directories(
include
)
ament_export_libraries(
component_parser
components
hardware_interface
)
Expand Down
127 changes: 127 additions & 0 deletions hardware_interface/include/hardware_interface/component_parser.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
// Copyright 2020 ros2_control Development Team
//
// 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.

#ifndef HARDWARE_INTERFACE__COMPONENT_PARSER_HPP_
#define HARDWARE_INTERFACE__COMPONENT_PARSER_HPP_

#include <tinyxml2.h>
#include <string>
#include <unordered_map>
#include <vector>

#include "hardware_interface/components/component_info.hpp"
#include "hardware_interface/hardware_info.hpp"
#include "hardware_interface/visibility_control.h"

namespace hardware_interface
{

/**
* \brief Search XML snippet from URDF for information about a control component.
*
* \param urdf string with robot's URDF
* \return vector filled with information about robot's control resources
* \throws std::runtime_error if a robot attribute or tag is not found
*/
HARDWARE_INTERFACE_PUBLIC
std::vector<HardwareInfo> parse_control_resources_from_urdf(const std::string & urdf);

/**
* \brief Parse a control resource from an "ros2_control" tag.
*
* \param ros2_control_it pointer to ros2_control element with informtions about resource.
* \return robot_control_components::ComponentInfo filled with information about the robot
* \throws std::runtime_error if a attributes or tag are not found
*/
HARDWARE_INTERFACE_PUBLIC
HardwareInfo parse_resource_from_xml(const tinyxml2::XMLElement * ros2_control_it);

/**
* \brief Gets value of the attribute on an XMLelement.
* If attribute is not found throws an error.
*
* \param element_it XMLElement iterator to search for the attribute
* \param attribute_name atribute name to serach for and return value
* \param tag_name parent tag name where attribute is searched for (used for error output)
* \return attribute value
* \throws std::runtime_error if attribute is not found
*/
HARDWARE_INTERFACE_PUBLIC
std::string get_attribute_value(
const tinyxml2::XMLElement * element_it,
const char * attribute_name, const char * tag_name);

/**
* \brief Gets value of the text between tags.
*
* \param element_it XMLElement iterator to search for the text.
* \param tag_name parent tag name where text is searched for (used for error output)
* \return text of for the tag
* \throws std::runtime_error if text is not found
*/
HARDWARE_INTERFACE_PUBLIC
std::string get_text_for_element(
const tinyxml2::XMLElement * element_it,
const std::string & tag_name);

/**
* \brief Gets value of the attribute on an XMLelement.
* If attribute is not found throws an error.
*
* \param element_it XMLElement iterator to search for the attribute
* \param attribute_name atribute name to serach for and return value
* \param tag_name parent tag name where attribute is searched for (used for error output)
* \return attribute value
* \throws std::runtime_error if attribute is not found
*/
HARDWARE_INTERFACE_PUBLIC
std::string get_attribute_value(
const tinyxml2::XMLElement * element_it,
const char * attribute_name, std::string tag_name);

/**
* \brief Search XML snippet from URDF for information about a control component.
*
* \param component_it pointer to the iterator where component info should be found
* \return robot_control_components::ComponentInfo filled with information about component
* \throws std::runtime_error if a component attribute or tag is not found
*/
HARDWARE_INTERFACE_PUBLIC
components::ComponentInfo parse_component_from_xml(const tinyxml2::XMLElement * component_it);

/**
* \brief Search XML snippet for definition of interfaceTypes.
*
* \param interfaces_it pointer to the interator over interfaces
* \param interfaceTag interface type tag (command or state)
* \return std::vector< std::__cxx11::string > list of interface types
* \throws std::runtime_error if the interfaceType text not set in a tag
*/
HARDWARE_INTERFACE_PUBLIC
std::vector<std::string> parse_interfaces_from_xml(
const tinyxml2::XMLElement * interfaces_it, const char * interfaceTag);

/**
* \brief Search XML snippet from URDF for parameters.
*
* \param params_it pointer to the iterator where parameters info should be found
* \return std::map< std::__cxx11::string, std::__cxx11::string > key-value map with parameters
* \throws std::runtime_error if a component attribute or tag is not found
*/
HARDWARE_INTERFACE_PUBLIC
std::unordered_map<std::string, std::string> parse_parameters_from_xml(
const tinyxml2::XMLElement * params_it);

} // namespace hardware_interface
#endif // HARDWARE_INTERFACE__COMPONENT_PARSER_HPP_
Loading