Skip to content

Commit

Permalink
Merge branch 'master' into hw-components-initial-state
Browse files Browse the repository at this point in the history
  • Loading branch information
destogl authored Jun 21, 2023
2 parents 7ea83fa + db34dfa commit eacc33c
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 5 deletions.
7 changes: 4 additions & 3 deletions controller_manager/src/controller_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,17 @@ void ControllerManager::subscribe_to_robot_description_topic()
{
// set QoS to transient local to get messages that have already been published
// (if robot state publisher starts before controller manager)
RCLCPP_INFO(
get_logger(), "Subscribing to '~/robot_description' topic for robot description file.");
robot_description_subscription_ = create_subscription<std_msgs::msg::String>(
"~/robot_description", rclcpp::QoS(1).transient_local(),
std::bind(&ControllerManager::robot_description_callback, this, std::placeholders::_1));
RCLCPP_INFO(
get_logger(), "Subscribing to '%s' topic for robot description.",
robot_description_subscription_->get_topic_name());
}

void ControllerManager::robot_description_callback(const std_msgs::msg::String & robot_description)
{
RCLCPP_INFO(get_logger(), "Received robot description file.");
RCLCPP_INFO(get_logger(), "Received robot description from topic.");
RCLCPP_DEBUG(
get_logger(), "'Content of robot description file: %s", robot_description.data.c_str());
// TODO(Manuel): errors should probably be caught since we don't want controller_manager node
Expand Down
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; }
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,17 @@ def main(self, *, args):

for idx, component in enumerate(hardware_components.component):
print(
f"Hardware Component {idx}\n\tname: {component.name}\n\ttype: {component.type}"
f"Hardware Component {idx+1}\n\tname: {component.name}\n\ttype: {component.type}"
)
if hasattr(component, "plugin_name"):
plugin_name = component.plugin_name
else:
plugin_name = f"{bcolors.WARNING}plugin name missing!{bcolors.ENDC}"

print(
f"\tplugin name: {plugin_name}\n\tstate: id={component.state.id} label={component.state.label}\n\tcommand interfaces"
f"\tplugin name: {plugin_name}\n"
f"\tstate: id={component.state.id} label={component.state.label}\n"
f"\tcommand interfaces"
)
for cmd_interface in component.command_interfaces:
if cmd_interface.is_available:
Expand Down

0 comments on commit eacc33c

Please sign in to comment.