Skip to content

Commit 0dfe01a

Browse files
Ensure instantiation of hardware classes work for python bindings (#1058) (#1062)
(cherry picked from commit db34dfa) Co-authored-by: Olivier Stasse <[email protected]>
1 parent 5504b6a commit 0dfe01a

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

hardware_interface/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ if(BUILD_TESTING)
122122
target_include_directories(test_macros PRIVATE include)
123123
ament_target_dependencies(test_macros rcpputils)
124124

125+
ament_add_gmock(test_inst_hardwares test/test_inst_hardwares.cpp)
126+
target_link_libraries(test_inst_hardwares hardware_interface)
127+
ament_target_dependencies(test_inst_hardwares rcpputils)
128+
125129
ament_add_gmock(test_joint_handle test/test_handle.cpp)
126130
target_link_libraries(test_joint_handle ${PROJECT_NAME})
127131
ament_target_dependencies(test_joint_handle rcpputils)

hardware_interface/include/hardware_interface/system.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ class SystemInterface;
3535
class System final
3636
{
3737
public:
38+
System() = default;
39+
3840
HARDWARE_INTERFACE_PUBLIC
3941
explicit System(std::unique_ptr<SystemInterface> impl);
4042

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2023 LAAS CNRS
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include <gmock/gmock.h>
16+
17+
#include "hardware_interface/actuator.hpp"
18+
#include "hardware_interface/actuator_interface.hpp"
19+
#include "hardware_interface/sensor.hpp"
20+
#include "hardware_interface/sensor_interface.hpp"
21+
#include "hardware_interface/system.hpp"
22+
#include "hardware_interface/system_interface.hpp"
23+
24+
class TestInstantiationHardwares : public ::testing::Test
25+
{
26+
protected:
27+
static void SetUpTestCase() {}
28+
};
29+
30+
TEST_F(TestInstantiationHardwares, build_actuator) { hardware_interface::Actuator anActuator; }
31+
32+
TEST_F(TestInstantiationHardwares, build_sensor) { hardware_interface::Sensor aSensor; }
33+
34+
TEST_F(TestInstantiationHardwares, build_system) { hardware_interface::System aSystem; }

0 commit comments

Comments
 (0)