Skip to content

Commit

Permalink
Update tests to changed behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
fmauch committed May 4, 2023
1 parent 508e619 commit d6e6526
Showing 1 changed file with 40 additions and 28 deletions.
68 changes: 40 additions & 28 deletions hardware_interface/test/test_resource_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -961,15 +961,15 @@ TEST_F(ResourceManagerTest, resource_availability_and_claiming_in_lifecycle)
TEST_SYSTEM_HARDWARE_STATE_INTERFACES, TEST_SYSTEM_HARDWARE_COMMAND_INTERFACES, false);
}

// When actuator is configured all interfaces become available
// When actuator is configured state interfaces become available
configure_components(rm, {TEST_ACTUATOR_HARDWARE_NAME});
{
check_interfaces(
{"joint1/position"},
std::bind(&TestableResourceManager::command_interface_is_available, &rm, _1), true);
std::bind(&TestableResourceManager::command_interface_is_available, &rm, _1), false);
check_interfaces(
{"joint1/max_velocity"},
std::bind(&TestableResourceManager::command_interface_is_available, &rm, _1), true);
std::bind(&TestableResourceManager::command_interface_is_available, &rm, _1), false);
check_interfaces(
TEST_SYSTEM_HARDWARE_COMMAND_INTERFACES,
std::bind(&TestableResourceManager::command_interface_is_available, &rm, _1), false);
Expand All @@ -987,9 +987,9 @@ TEST_F(ResourceManagerTest, resource_availability_and_claiming_in_lifecycle)

// Can claim Actuator's interfaces
{
check_interface_claiming({}, {"joint1/position"}, true);
check_interface_claiming({}, {"joint1/position"}, false);
check_interface_claiming(
TEST_ACTUATOR_HARDWARE_STATE_INTERFACES, {"joint1/max_velocity"}, true);
TEST_ACTUATOR_HARDWARE_STATE_INTERFACES, {}, true);
check_interface_claiming(TEST_SENSOR_HARDWARE_STATE_INTERFACES, {}, false);
check_interface_claiming(
TEST_SYSTEM_HARDWARE_STATE_INTERFACES, TEST_SYSTEM_HARDWARE_COMMAND_INTERFACES, false);
Expand Down Expand Up @@ -1045,19 +1045,18 @@ TEST_F(ResourceManagerTest, resource_availability_and_claiming_in_lifecycle)
std::bind(&TestableResourceManager::state_interface_exists, &rm, _1), true);
}

// When Sensor and System are configured their state-
// and command- interfaces are available
// When Sensor and System are configured their state-interfaces are available
configure_components(rm, {TEST_SENSOR_HARDWARE_NAME, TEST_SYSTEM_HARDWARE_NAME});
{
check_interfaces(
TEST_ACTUATOR_HARDWARE_COMMAND_INTERFACES,
std::bind(&TestableResourceManager::command_interface_is_available, &rm, _1), true);
check_interfaces(
{"joint2/velocity", "joint3/velocity"},
std::bind(&TestableResourceManager::command_interface_is_available, &rm, _1), true);
std::bind(&TestableResourceManager::command_interface_is_available, &rm, _1), false);
check_interfaces(
{"joint2/max_acceleration", "configuration/max_tcp_jerk"},
std::bind(&TestableResourceManager::command_interface_is_available, &rm, _1), true);
std::bind(&TestableResourceManager::command_interface_is_available, &rm, _1), false);

check_interfaces(
TEST_ACTUATOR_HARDWARE_STATE_INTERFACES,
Expand All @@ -1073,15 +1072,15 @@ TEST_F(ResourceManagerTest, resource_availability_and_claiming_in_lifecycle)
// Can claim:
// - all Actuator's state interfaces and command interfaces
// - sensor's state interfaces
// - system's state and command interfaces
// - system's state interfaces
// Cannot claim:
// - system's command interfaces
{
check_interface_claiming(
TEST_ACTUATOR_HARDWARE_STATE_INTERFACES, TEST_ACTUATOR_HARDWARE_COMMAND_INTERFACES, true);
check_interface_claiming(TEST_SENSOR_HARDWARE_STATE_INTERFACES, {}, true);
check_interface_claiming({}, {"joint2/velocity", "joint3/velocity"}, true);
check_interface_claiming(
TEST_SYSTEM_HARDWARE_STATE_INTERFACES,
{"joint2/max_acceleration", "configuration/max_tcp_jerk"}, true);
check_interface_claiming(TEST_SYSTEM_HARDWARE_STATE_INTERFACES, {}, true);
check_interface_claiming({}, {"joint2/velocity", "joint3/velocity"}, false);
}

// All active - everything available
Expand Down Expand Up @@ -1122,10 +1121,10 @@ TEST_F(ResourceManagerTest, resource_availability_and_claiming_in_lifecycle)
{
check_interfaces(
{"joint1/position"},
std::bind(&TestableResourceManager::command_interface_is_available, &rm, _1), true);
std::bind(&TestableResourceManager::command_interface_is_available, &rm, _1), false);
check_interfaces(
{"joint1/max_velocity"},
std::bind(&TestableResourceManager::command_interface_is_available, &rm, _1), true);
std::bind(&TestableResourceManager::command_interface_is_available, &rm, _1), false);
check_interfaces(
TEST_SYSTEM_HARDWARE_COMMAND_INTERFACES,
std::bind(&TestableResourceManager::command_interface_is_available, &rm, _1), true);
Expand All @@ -1142,27 +1141,33 @@ TEST_F(ResourceManagerTest, resource_availability_and_claiming_in_lifecycle)
}

// Can claim everything
// - actuator's state and command interfaces
// - actuator's state interfaces
// - sensor's state interfaces
// - system's state and command interfaces
// Cannot claim:
// - actuator's command interface
{
check_interface_claiming({}, {"joint1/position"}, true);
check_interface_claiming(
TEST_ACTUATOR_HARDWARE_STATE_INTERFACES, {"joint1/max_velocity"}, true);
TEST_ACTUATOR_HARDWARE_STATE_INTERFACES, {}, true);
check_interface_claiming(TEST_SENSOR_HARDWARE_STATE_INTERFACES, {}, true);
check_interface_claiming(
TEST_SYSTEM_HARDWARE_STATE_INTERFACES, TEST_SYSTEM_HARDWARE_COMMAND_INTERFACES, true);
check_interface_claiming({}, {"joint1/position"}, false);
//check_interface_claiming(
//TEST_ACTUATOR_HARDWARE_STATE_INTERFACES, {"joint1/max_velocity"}, true);
// TODO(fmauch): Claiming the state interfaces should work but the check function expects both
// to fail.
}

// When sensor is cleaned up the interfaces are not available anymore
cleanup_components(rm, {TEST_SENSOR_HARDWARE_NAME});
{
check_interfaces(
{"joint1/position"},
std::bind(&TestableResourceManager::command_interface_is_available, &rm, _1), true);
std::bind(&TestableResourceManager::command_interface_is_available, &rm, _1), false);
check_interfaces(
{"joint1/max_velocity"},
std::bind(&TestableResourceManager::command_interface_is_available, &rm, _1), true);
std::bind(&TestableResourceManager::command_interface_is_available, &rm, _1), false);
check_interfaces(
TEST_SYSTEM_HARDWARE_COMMAND_INTERFACES,
std::bind(&TestableResourceManager::command_interface_is_available, &rm, _1), true);
Expand All @@ -1178,17 +1183,24 @@ TEST_F(ResourceManagerTest, resource_availability_and_claiming_in_lifecycle)
std::bind(&TestableResourceManager::state_interface_is_available, &rm, _1), true);
}

// Can claim everything
// - actuator's state and command interfaces
// - no sensor's interface
// Can claim:
// - actuator's state interfaces
// - system's state and command interfaces
// Cannot claim:
// - actuator's command interfaces
// - sensor's interface
{
check_interface_claiming({}, {"joint1/position"}, true);
check_interface_claiming(
TEST_ACTUATOR_HARDWARE_STATE_INTERFACES, {"joint1/max_velocity"}, true);
check_interface_claiming(TEST_SENSOR_HARDWARE_STATE_INTERFACES, {}, false);
check_interface_claiming(TEST_ACTUATOR_HARDWARE_STATE_INTERFACES, {}, true);
check_interface_claiming(
TEST_SYSTEM_HARDWARE_STATE_INTERFACES, TEST_SYSTEM_HARDWARE_COMMAND_INTERFACES, true);

check_interface_claiming(TEST_SENSOR_HARDWARE_STATE_INTERFACES, {}, false);
check_interface_claiming({}, {"joint1/position"}, false);

//check_interface_claiming(
//TEST_ACTUATOR_HARDWARE_STATE_INTERFACES, {"joint1/max_velocity"}, true);
// TODO(fmauch): Claiming the state interfaces should work but the check function expects both
// to fail.
}

// Check if all interfaces still exits
Expand Down

0 comments on commit d6e6526

Please sign in to comment.