Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f57147f
Initial version of new package implementing components for controling…
destogl Jun 12, 2020
fe1acd1
Parsing of ros2_control Robot from URDF and added interface structure…
destogl Jun 16, 2020
64e22a7
Added test for component_parser.
destogl Jun 16, 2020
1b40e73
Add forgoten parser files
destogl Jun 16, 2020
8325d77
Update package.xml
destogl Jun 16, 2020
dc8f303
Added initial sensor and actuator implementations.
destogl Jun 16, 2020
3dc9426
move interfaces into hardware_interface package
Karsten1987 Jun 17, 2020
085748a
Add configure to robot_hardware. Correct header file protection names…
destogl Jun 22, 2020
cdc9eb9
Use unordered_map instead of map.
destogl Jun 22, 2020
5f9978d
Correct lint and uncrustify errors.
destogl Jun 22, 2020
6c43b2a
Added resource manager.
destogl Jun 29, 2020
8339225
Using enum class for return type
destogl Jun 29, 2020
afff3aa
Change hw_ret_type to enum class
destogl Jun 29, 2020
1bc5dce
Correct some thing accoring to comments in PR
destogl Jul 4, 2020
4034cef
Removed resource manager and utils
destogl Jul 4, 2020
16e7f31
Update hw_return types in components
destogl Jul 4, 2020
191b15d
Added SystemInfo to implement structural dependency of components in …
destogl Jul 4, 2020
cf9ea6c
hardware_interface_ret_t -> return_type
destogl Jul 4, 2020
6af1296
Added documentation for component_info.hpp
destogl Jul 4, 2020
488b90d
Correct repo name in the licence headers
destogl Jul 4, 2020
b88faec
Remove default constructor/destructor from cpp
destogl Jul 4, 2020
c59575a
correct style
destogl Jul 4, 2020
3d4b282
Merge branch 'master' into hardware_control_components-design
destogl Jul 9, 2020
cdbb2cc
rename actuator -> joint
destogl Jul 14, 2020
5b7919d
Correct parser bug with type attribute
destogl Jul 14, 2020
075312a
Component parser correction
destogl Jul 14, 2020
9f24c3d
Merge branch 'hardware_control_components-design' of https://github.c…
destogl Jul 14, 2020
355048d
Correct lint check
destogl Jul 14, 2020
e0aa6f3
Correct typo
destogl Jul 15, 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
40 changes: 34 additions & 6 deletions hardware_interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ endif()

find_package(ament_cmake REQUIRED)
find_package(control_msgs REQUIRED)
find_package(pluginlib REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rcpputils REQUIRED)
find_package(tinyxml2_vendor REQUIRED)
find_package(TinyXML2 REQUIRED)

add_library(
hardware_interface
Expand All @@ -26,26 +29,41 @@ add_library(
target_include_directories(
hardware_interface
PUBLIC
include)
include
)
ament_target_dependencies(
hardware_interface
control_msgs
rclcpp
rcpputils
)

# Causes the visibility macros to use dllexport rather than dllimport,
# 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/utils/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")

install(
DIRECTORY include/
DESTINATION include
)

install(
TARGETS
hardware_interface
TARGETS hardware_interface component_parser
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib)
Expand All @@ -64,6 +82,11 @@ if(BUILD_TESTING)
target_include_directories(test_robot_hardware_interfaces PRIVATE include)
target_link_libraries(test_robot_hardware_interfaces hardware_interface)


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

ament_add_gmock(test_register_actuators test/test_register_actuators.cpp)
target_include_directories(test_register_actuators PRIVATE include)
target_link_libraries(test_register_actuators hardware_interface)
Expand All @@ -73,14 +96,19 @@ if(BUILD_TESTING)
target_include_directories(test_actuator_handle PRIVATE include)
target_link_libraries(test_actuator_handle hardware_interface)
ament_target_dependencies(test_actuator_handle rcpputils)

endif()

ament_export_dependencies(
rclcpp
rcpputils
)
ament_export_include_directories(
include
)
ament_export_libraries(
hardware_interface)
hardware_interface
component_parser
)
ament_export_dependencies(
control_msgs)
ament_package()
103 changes: 103 additions & 0 deletions hardware_interface/include/hardware_interface/component_info.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// 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_INFO_HPP_
#define HARDWARE_INTERFACE__COMPONENT_INFO_HPP_

#include <string>
#include <unordered_map>
#include <vector>

namespace hardware_interface
{

/**
* \brief constants for types of components.
*/
constexpr const auto robotType = "robot";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be systemType?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really. Those types are for definitions for ResourceManager to get correct type from type property when initializing components.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I understand this.

constexpr const auto actuatorType = "actuator";
constexpr const auto sensorType = "sensor";

/**
* \brief This structure stores information about components defined in a robot's URDF.
*/
struct ComponentInfo
{
/**
* \brief name of the component.
*/
std::string name;
/**
* \brief type of the component: sensor or actuator.
*/
std::string type;
/**
* \brief component's class, which will be dynamically loaded.
*/
std::string class_type;
/**
* \brief joint where component is placed.
*/
std::string joint;
/**
* \brief name of the interface, e.g. "position", "velocity", etc. for meaning of data this component holds.
*/
std::vector<std::string> interface_names;
/**
* \brief (optional) key-value pairs of components parameters.
*/
std::unordered_map<std::string, std::string> parameters;

/**
* \brief (optional) hardware class of the component that will be dynamically loaded. If not defined, the system's hardware class has to be defined.
*/
std::string hardware_class_type;
/**
* \brief (optional) key-value pairs for components hardware.
*/
std::unordered_map<std::string, std::string> hardware_parameters;
Comment on lines +67 to +70
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the difference here to parameters?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parameters are for component and hardware_parameters are hardware-specific stuff. It could be that in some cases one have the same parameter for the component but uses different hardware/interface.

};

/**
* \brief This structure stores informations about system defined in robot's URDF, i.e. "ros2_control"-tag.
*/
struct SystemInfo
{
/**
* \brief name of the system.
*/
std::string name;
/**
* \brief type of the system: robot, actuator or sensor. Note: URDF always needs a "robot" tag, nevertheless in terms of ros2_control, it can hold a definition for an actuator or sensor.
*/
std::string type;
/**
* \brief (optional) hardware class of the system, which will be dynamically loaded. If not defined, a hardware class for each subcomponent has to be defined.
*/
std::string hardware_class_type;
/**
* \brief (optional) key-value pairs for systems hardware.
*/
std::unordered_map<std::string, std::string> hardware_parameters;

/**
* \brief list of subcomponents in the system, i.e., list of sensors and actuators.
*/
std::vector<ComponentInfo> subcomponents;
Comment on lines +95 to +98
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't understand why we need this. Can a system not be treated as a single black-box component?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to your figure yes. You are right, this is not the best way, at least it shouldn't be placed inside SystemInfo type. Nevertheless, we need one top "container" which corresponds to the robot tag in URDF, as there could be System, Sensor and Joints defined, and they are like "subcomponents" of this robot.

The SystemInfo here represents exactly this robot level in URDF. IMHO it is better name than RobotInfo since one can define a good deal of different stuff with URDF, not only robots.

I hope you got my idea, and if you have any proposal, I would be happy to discuss it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair enough. I am cross-posting here as I just went through #121 but I think we definitely need a piece of URDF here which dictates how the individual components as well as the systems are supposed to be specified.

};

} // namespace hardware_interface

#endif // HARDWARE_INTERFACE__COMPONENT_INFO_HPP_
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// 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_INTERFACES__JOINT_INTERFACE_HPP_
#define HARDWARE_INTERFACE__COMPONENT_INTERFACES__JOINT_INTERFACE_HPP_

#include <algorithm>
#include <array>
#include <string>
#include <vector>

#include "hardware_interface/component_info.hpp"
#include "hardware_interface/types/hardware_interface_return_values.hpp"
#include "hardware_interface/visibility_control.h"

namespace hardware_interface
{

class JointInterface
{
public:
HARDWARE_INTERFACE_PUBLIC
JointInterface() = default;

HARDWARE_INTERFACE_PUBLIC
virtual
~JointInterface() = default;

HARDWARE_INTERFACE_PUBLIC
virtual
return_type configure(const ComponentInfo & actuator_info) = 0;

HARDWARE_INTERFACE_PUBLIC
virtual
std::string get_interface_name() const = 0;

HARDWARE_INTERFACE_PUBLIC
virtual
return_type start() = 0;

HARDWARE_INTERFACE_PUBLIC
virtual
return_type stop() = 0;

HARDWARE_INTERFACE_PUBLIC
virtual
bool is_started() const = 0;

HARDWARE_INTERFACE_PUBLIC
virtual
return_type read(double & data) = 0;

HARDWARE_INTERFACE_PUBLIC
virtual
return_type write(const double & data) = 0;
};

} // namespace hardware_interface
#endif // HARDWARE_INTERFACE__COMPONENT_INTERFACES__JOINT_INTERFACE_HPP_
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// 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_INTERFACES__SENSOR_INTERFACE_HPP_
#define HARDWARE_INTERFACE__COMPONENT_INTERFACES__SENSOR_INTERFACE_HPP_

#include <string>

#include "hardware_interface/component_info.hpp"
#include "hardware_interface/types/hardware_interface_return_values.hpp"
#include "hardware_interface/visibility_control.h"

namespace hardware_interface
{

class SensorInterface
{
public:
HARDWARE_INTERFACE_PUBLIC
SensorInterface() = default;

HARDWARE_INTERFACE_PUBLIC
virtual
~SensorInterface() = default;

HARDWARE_INTERFACE_PUBLIC
virtual
return_type configure(const ComponentInfo & sensor_info) = 0;

HARDWARE_INTERFACE_PUBLIC
virtual
std::string get_interface_name() const = 0;

HARDWARE_INTERFACE_PUBLIC
virtual
return_type start() = 0;

HARDWARE_INTERFACE_PUBLIC
virtual
return_type stop() = 0;

HARDWARE_INTERFACE_PUBLIC
virtual
bool is_started() const = 0;

HARDWARE_INTERFACE_PUBLIC
virtual
return_type read(double & data) = 0;
};

} // namespace hardware_interface
#endif // HARDWARE_INTERFACE__COMPONENT_INTERFACES__SENSOR_INTERFACE_HPP_
Loading