Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ceb4d67
Initial version of new package implementing components for controling…
destogl Jun 12, 2020
3ceb98c
Add control component interfaces.
destogl Jun 16, 2020
9ddc603
Added initial tests for Joint and JointInterface
destogl Jul 27, 2020
eeaff7e
Extended SensorInterface to work with hardware. Added Example for Dum…
destogl Jul 28, 2020
d7eae16
Remove component types since they are not used yet.
destogl Jul 28, 2020
818846d
Added tests for all interfaces and implemented review comments
destogl Jul 29, 2020
3fead1f
Added HardwareInfo as the main structure in the robot's URDF file
destogl Aug 17, 2020
2fea78d
Add Hardware and Component base classes and tests.
destogl Aug 17, 2020
182d7f1
Update hardware_interface/include/hardware_interface/sensor_hardware_…
destogl Aug 18, 2020
90b6ee2
Update hardware_interface/include/hardware_interface/system_hardware_…
destogl Aug 18, 2020
53e83c4
Update hardware_interface/include/hardware_interface/system_hardware_…
destogl Aug 18, 2020
7f922dd
Update hardware_interface/include/hardware_interface/system_hardware_…
destogl Aug 18, 2020
ef5a259
Split Component and Hardware Infos into two files
destogl Aug 18, 2020
374aeb0
Use separated headers for components_info and hardware_info
destogl Aug 18, 2020
daaac84
Style corrections
destogl Aug 18, 2020
5e4ed73
Add documentation for joint and sensor components
destogl Aug 18, 2020
3053824
Update hardware_interface/test/test_component_interfaces.cpp
destogl Aug 18, 2020
7089abe
Style corrections
destogl Aug 18, 2020
f9c1d15
The base classes for Joints and Sensors are implemented
destogl Aug 18, 2020
ed11e86
Add more tests to get better coverage
destogl Aug 19, 2020
f6a731a
Updated after comments and added helper header
destogl Aug 19, 2020
8dbe0bc
Implementation moved to cpp files
destogl Aug 19, 2020
f871d5e
Removed virtual function for checking limits
destogl Aug 19, 2020
fbed601
Use inline functions in helper header and make API-consistent return …
destogl Aug 20, 2020
62cf9ab
Correct faulty header guard
destogl Aug 20, 2020
567b774
Corrected depency export and sorting of includes and namespaces in te…
destogl Aug 20, 2020
71aafc2
remove helpers namespace
destogl Aug 21, 2020
3d5f7a5
osx touchups
Karsten1987 Aug 21, 2020
00b73ee
move components into components folder
Karsten1987 Aug 21, 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
18 changes: 14 additions & 4 deletions hardware_interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ 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")
Expand Down Expand Up @@ -74,13 +74,23 @@ if(BUILD_TESTING)
target_link_libraries(test_actuator_handle hardware_interface)
ament_target_dependencies(test_actuator_handle rcpputils)

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 hardware_interface)

Comment thread
destogl marked this conversation as resolved.
Outdated
endif()

ament_export_dependencies(
rclcpp
rcpputils
)
ament_export_include_directories(
include
)
ament_export_libraries(
hardware_interface)
hardware_interface
)
ament_export_dependencies(
control_msgs)
control_msgs
)
ament_package()
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// 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__ACTUATOR_HARDWARE_HPP_
#define HARDWARE_INTERFACE__ACTUATOR_HARDWARE_HPP_

#include <algorithm>
#include <memory>
#include <string>
#include <utility>

#include "hardware_interface/hardware_and_component_info.hpp"
#include "hardware_interface/actuator_hardware_interface.hpp"
#include "hardware_interface/joint.hpp"
Comment thread
destogl marked this conversation as resolved.
Outdated
#include "hardware_interface/types/hardware_interface_return_values.hpp"
#include "hardware_interface/types/hardware_interface_status_values.hpp"
#include "hardware_interface/visibility_control.h"

namespace hardware_interface
{

class ActuatorHardware final
{
public:
ActuatorHardware() = default;

explicit ActuatorHardware(std::unique_ptr<ActuatorHardwareInterface> impl)
: impl_(std::move(impl))
{}

~ActuatorHardware() = default;

HARDWARE_INTERFACE_PUBLIC
return_type configure(const HardwareInfo & actuator_info)
{
return impl_->configure(actuator_info);
}

HARDWARE_INTERFACE_PUBLIC
return_type start()
{
return impl_->start();
}

HARDWARE_INTERFACE_PUBLIC
return_type stop()
{
return impl_->stop();
}

HARDWARE_INTERFACE_PUBLIC
hardware_interface_status get_status()
{
return impl_->get_status();
}

HARDWARE_INTERFACE_PUBLIC
return_type read_joint(Joint & joint)
{
return impl_->read_joint(joint);
}

HARDWARE_INTERFACE_PUBLIC
return_type write(const Joint & joint)
{
return impl_->write(joint);
}

private:
std::unique_ptr<ActuatorHardwareInterface> impl_;
};

} // namespace hardware_interface
#endif // HARDWARE_INTERFACE__ACTUATOR_HARDWARE_HPP_
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// 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__ACTUATOR_HARDWARE_INTERFACE_HPP_
#define HARDWARE_INTERFACE__ACTUATOR_HARDWARE_INTERFACE_HPP_

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

#include "hardware_interface/hardware_and_component_info.hpp"
#include "hardware_interface/joint.hpp"
#include "hardware_interface/types/hardware_interface_return_values.hpp"
#include "hardware_interface/types/hardware_interface_status_values.hpp"
#include "hardware_interface/visibility_control.h"

namespace hardware_interface
{

/**
* \brief Virtual Class to implement when integrating a 1 DoF actuator into ros2_control.
* The typical examples are conveyors or motors.
*/
class ActuatorHardwareInterface
{
public:
HARDWARE_INTERFACE_PUBLIC
ActuatorHardwareInterface() = default;

HARDWARE_INTERFACE_PUBLIC
virtual
~ActuatorHardwareInterface() = default;

/**
* @brief Configuration of the actuator from data parsed from the robot's URDF.
Comment thread
destogl marked this conversation as resolved.
Outdated
*
* @param actuator_info structure with data from URDF.
* @return return_type::OK if required data are provided and can be parsed,
* return_type::ERROR otherwise.
*/
HARDWARE_INTERFACE_PUBLIC
virtual
return_type configure(const HardwareInfo & actuator_info) = 0;
Comment thread
Karsten1987 marked this conversation as resolved.

/**
* @brief Start exchange data with the hardware.
*
* @return return_type:OK if everything worked as expected, return_type::ERROR otherwise.
*/
HARDWARE_INTERFACE_PUBLIC
virtual
return_type start() = 0;

/**
* @brief Stop exchange data with the hardware.
*
* @return return_type:OK if everything worked as expected, return_type::ERROR otherwise.
*/
HARDWARE_INTERFACE_PUBLIC
virtual
return_type stop() = 0;

/**
* @brief Get current state of the system hardware.
*
* @return hardware_interface_status current status.
*/
HARDWARE_INTERFACE_PUBLIC
virtual
hardware_interface_status get_status() const = 0;

/**
* @brief Read data fromt the hardware into the joint using "set_state" function of the Joint class.
* This function is always called by the RessourceManger.
Comment thread
destogl marked this conversation as resolved.
Outdated
*
* @param joint joint where data from the hardware are stored.
* @return return_type:OK if everything worked as expected, return_type::ERROR otherwise.
*/
HARDWARE_INTERFACE_PUBLIC
virtual
return_type read_joint(Joint & joint) const = 0;

/**
* @brief Write data from the joint to the hardware using "get_command" function of the Joint class.
* This function is always called by the RessourceManger.
Comment thread
destogl marked this conversation as resolved.
Outdated
*
* @param joint the joint from which data are written to the hardware.
* @return return_type:OK if everything worked as expected, return_type::ERROR otherwise.
*/
HARDWARE_INTERFACE_PUBLIC
virtual
return_type write(const Joint & joint) = 0;
Comment thread
destogl marked this conversation as resolved.
Outdated
};

} // namespace hardware_interface
#endif // HARDWARE_INTERFACE__ACTUATOR_HARDWARE_INTERFACE_HPP_
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// 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__HARDWARE_AND_COMPONENT_INFO_HPP_
Comment thread
destogl marked this conversation as resolved.
Outdated
#define HARDWARE_INTERFACE__HARDWARE_AND_COMPONENT_INFO_HPP_

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

namespace hardware_interface
{

/**
* \brief This structure stores information about components defined for a specific hardware
* in 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 name of the command interfaces that can be set, e.g. "position", "velocity", etc.
* Used by joints.
*/
std::vector<std::string> command_interfaces;
/**
* \brief name of the state interfaces that can be read, e.g. "position", "velocity", etc.
* Used by Joints and Sensors.
*/
std::vector<std::string> state_interfaces;
/**
* \brief (optional) key-value pairs of components parameters.
*/
std::unordered_map<std::string, std::string> parameters;
};

/**
* \brief This structure stores information about hardware defined in a robot's URDF.
*/
struct HardwareInfo
{
/**
* \brief name of the hardware.
*/
std::string name;
/**
* \brief type of the hardware: actuator, sensor or system.
*/
std::string type;
/**
* \brief class of the hardware that will be dynamically loaded.
*/
std::string hardware_class_type;
/**
* \brief (optional) key-value pairs for hardware parameters.
*/
std::unordered_map<std::string, std::string> hardware_parameters;
/**
* \brief map of joints provided by the hardware where the key is the joint name.
* Required for Actuator and System Hardware.
*/
std::unordered_map<std::string, ComponentInfo> joints;
/**
* \brief map of joints provided by the hardware where the key is the joint name.
* Required for Sensor and optional for System Hardware.
*/
std::unordered_map<std::string, ComponentInfo> sensors;
/**
* \brief map of transmissions to calcualte ration between joints and physical actuators.
* Optional for Actuator and System Hardware.
*/
std::unordered_map<std::string, ComponentInfo> transmissions;
};

} // namespace hardware_interface
#endif // HARDWARE_INTERFACE__HARDWARE_AND_COMPONENT_INFO_HPP_
Loading