Skip to content

Commit

Permalink
Ensure instantiation of hardware classes work for python bindings (ro…
Browse files Browse the repository at this point in the history
  • Loading branch information
olivier-stasse authored Jun 21, 2023
1 parent e14497e commit db34dfa
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions hardware_interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ if(BUILD_TESTING)
target_include_directories(test_macros PRIVATE include)
ament_target_dependencies(test_macros rcpputils)

ament_add_gmock(test_inst_hardwares test/test_inst_hardwares.cpp)
target_link_libraries(test_inst_hardwares hardware_interface)
ament_target_dependencies(test_inst_hardwares rcpputils)

ament_add_gmock(test_joint_handle test/test_handle.cpp)
target_link_libraries(test_joint_handle hardware_interface)
ament_target_dependencies(test_joint_handle rcpputils)
Expand Down
2 changes: 2 additions & 0 deletions hardware_interface/include/hardware_interface/system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class SystemInterface;
class System final
{
public:
System() = default;

HARDWARE_INTERFACE_PUBLIC
explicit System(std::unique_ptr<SystemInterface> impl);

Expand Down
34 changes: 34 additions & 0 deletions hardware_interface/test/test_inst_hardwares.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2023 LAAS CNRS
//
// 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.

#include <gmock/gmock.h>

#include "hardware_interface/actuator.hpp"
#include "hardware_interface/actuator_interface.hpp"
#include "hardware_interface/sensor.hpp"
#include "hardware_interface/sensor_interface.hpp"
#include "hardware_interface/system.hpp"
#include "hardware_interface/system_interface.hpp"

class TestInstantiationHardwares : public ::testing::Test
{
protected:
static void SetUpTestCase() {}
};

TEST_F(TestInstantiationHardwares, build_actuator) { hardware_interface::Actuator anActuator; }

TEST_F(TestInstantiationHardwares, build_sensor) { hardware_interface::Sensor aSensor; }

TEST_F(TestInstantiationHardwares, build_system) { hardware_interface::System aSystem; }

0 comments on commit db34dfa

Please sign in to comment.