Skip to content

Commit

Permalink
[MockHardware] Remove all deprecated options and deprecated plugins f…
Browse files Browse the repository at this point in the history
…rom the library. (#1150)

* Rename HW for simpler debugging and remove deprecated initial value handling.
* Remove fake from parameters.
* Remove FakeSystem
* Cleanup fake from tests.
  • Loading branch information
destogl authored Nov 7, 2023
1 parent b33e579 commit 0863acd
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 361 deletions.
18 changes: 0 additions & 18 deletions hardware_interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,6 @@ target_compile_definitions(mock_components PRIVATE "HARDWARE_INTERFACE_BUILDING_
pluginlib_export_plugin_description_file(
hardware_interface mock_components_plugin_description.xml)

add_library(fake_components SHARED
src/mock_components/generic_system.cpp
src/mock_components/fake_generic_system.cpp
)
target_compile_features(fake_components PUBLIC cxx_std_17)
target_include_directories(fake_components PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/hardware_interface>
)
ament_target_dependencies(fake_components PUBLIC ${THIS_PACKAGE_INCLUDE_DEPENDS})
# Causes the visibility macros to use dllexport rather than dllimport,
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(fake_components PRIVATE "HARDWARE_INTERFACE_BUILDING_DLL")

pluginlib_export_plugin_description_file(
hardware_interface fake_components_plugin_description.xml)

if(BUILD_TESTING)

find_package(ament_cmake_gmock REQUIRED)
Expand Down Expand Up @@ -145,7 +128,6 @@ install(
)
install(
TARGETS
fake_components
mock_components
hardware_interface
EXPORT export_hardware_interface
Expand Down
9 changes: 0 additions & 9 deletions hardware_interface/fake_components_plugin_description.xml

This file was deleted.

29 changes: 0 additions & 29 deletions hardware_interface/include/fake_components/generic_system.hpp

This file was deleted.

49 changes: 0 additions & 49 deletions hardware_interface/include/fake_components/visibility_control.h

This file was deleted.

19 changes: 0 additions & 19 deletions hardware_interface/src/mock_components/fake_generic_system.cpp

This file was deleted.

55 changes: 2 additions & 53 deletions hardware_interface/src/mock_components/generic_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,7 @@ CallbackReturn GenericSystem::on_init(const hardware_interface::HardwareInfo & i
}
else
{
// check if fake_sensor_commands was set instead and issue warning.
it = info_.hardware_parameters.find("fake_sensor_commands");
if (it != info_.hardware_parameters.end())
{
use_mock_sensor_command_interfaces_ = hardware_interface::parse_bool(it->second);
RCUTILS_LOG_WARN_NAMED(
"mock_generic_system",
"Parameter 'fake_sensor_commands' has been deprecated from usage. Use"
"'mock_sensor_commands' instead.");
}
else
{
use_mock_sensor_command_interfaces_ = false;
}
use_mock_sensor_command_interfaces_ = false;
}

// check if to create mock command interface for gpio
Expand All @@ -103,20 +90,7 @@ CallbackReturn GenericSystem::on_init(const hardware_interface::HardwareInfo & i
}
else
{
// check if fake_gpio_commands was set instead and issue warning
it = info_.hardware_parameters.find("fake_gpio_commands");
if (it != info_.hardware_parameters.end())
{
use_mock_gpio_command_interfaces_ = hardware_interface::parse_bool(it->second);
RCUTILS_LOG_WARN_NAMED(
"mock_generic_system",
"Parameter 'fake_gpio_commands' has been deprecated from usage. Use"
"'mock_gpio_commands' instead.");
}
else
{
use_mock_gpio_command_interfaces_ = false;
}
use_mock_gpio_command_interfaces_ = false;
}

// check if there is parameter that disables commands
Expand Down Expand Up @@ -707,7 +681,6 @@ void GenericSystem::initialize_storage_vectors(
}

// Initialize with values from URDF
bool print_hint = false;
for (auto i = 0u; i < component_infos.size(); i++)
{
const auto & component = component_infos[i];
Expand All @@ -725,33 +698,9 @@ void GenericSystem::initialize_storage_vectors(
{
states[index][i] = parse_double(interface.initial_value);
}
else
{
// Initialize the value in old way with warning message
auto it2 = component.parameters.find("initial_" + interface.name);
if (it2 != component.parameters.end())
{
states[index][i] = parse_double(it2->second);
print_hint = true;
}
else
{
print_hint = true;
}
}
}
}
}
if (print_hint)
{
RCUTILS_LOG_WARN_ONCE_NAMED(
"mock_generic_system",
"Parsing of optional initial interface values failed or uses a deprecated format. Add "
"initial values for every state interface in the ros2_control.xacro. For example: \n"
"<state_interface name=\"velocity\"> \n"
" <param name=\"initial_value\">0.0</param> \n"
"</state_interface>");
}
}

template <typename InterfaceType>
Expand Down
Loading

0 comments on commit 0863acd

Please sign in to comment.