Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests for hardware spawner. #1682

Closed
wants to merge 1 commit into from
Closed

Conversation

destogl
Copy link
Member

@destogl destogl commented Aug 15, 2024

No description provided.

@destogl destogl self-assigned this Aug 15, 2024

int call_spawner(const std::string extra_args)
{
std::string spawner_script = "ros2 run controller_manager hardware_spawner ";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::string spawner_script = "ros2 run controller_manager hardware_spawner ";
std::string spawner_script = "python3 -m coverage run --append --branch " +
"$(ros2 pkg prefix controller_manager)/lib/controller_manager/hardware_spawner ";

this will create branch coverage data.

Copy link
Contributor

mergify bot commented Aug 19, 2024

This pull request is in conflict. Could you fix it @destogl?

Copy link
Contributor

@fmauch fmauch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this still has the problem of not fully deciding whether the hardware spawner should be able to spawn multiple components or not.

is_hardware_component_loaded checks for one single string, while activate_components and configure_components expect a list. This PR changes the input argument to a list, but leaves the parameter name and description as singular. I think to make it clear (and to actually make the hardware spawner work) some more work is required, as in fmauch@9a65fc6.

@@ -117,11 +92,12 @@ def configure_components(node, controller_manager_name, components_to_configure)
def main(args=None):
rclpy.init(args=args, signal_handler_options=SignalHandlerOptions.NO)
parser = argparse.ArgumentParser()
activate_or_confiigure_grp = parser.add_mutually_exclusive_group(required=True)
activate_or_configure_grp = parser.add_mutually_exclusive_group(required=True)

parser.add_argument(
"hardware_component_name",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I suggest renaming this to hardware_component_names. This will be CLI-breaking but a) is this probably not being used by anybody, since it has been broken since introduced from what I can tell b) it would be good to make the name consistent with the controller spawner and to what it actually expects (a list).

Comment on lines +138 to +140
print(f"CMD Arguments: {command_line_args}")
print(f"Arguments: {args}")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was probably put in for debugging purposes.

Suggested change
print(f"CMD Arguments: {command_line_args}")
print(f"Arguments: {args}")

Comment on lines +163 to +164
EXPECT_EQ(call_spawner("TestSystemHardware --configure -c test_controller_manager"), 1)
<< "could not activate control because not robot description";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you wanted to test here, but I think that would make sense:

Suggested change
EXPECT_EQ(call_spawner("TestSystemHardware --configure -c test_controller_manager"), 1)
<< "could not activate control because not robot description";
EXPECT_EQ(
call_spawner(
"TestSystemHardware --configure -c test_controller_manager --controller-manager-timeout 1.0"),
256)
<< "could not activate control because not robot description";
EXPECT_EQ(
call_spawner(
"TestSystemHardware --configure -c test_controller_manager --controller-manager-timeout 2.5"),
0);

TestHardwareSpawnerWithoutRobotDescription()
: ControllerManagerFixture<controller_manager::ControllerManager>("")
{
cm_->set_parameter(rclcpp::Parameter("hardware_components_initial_state.unconfigured", "TestSystemHardware"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the error rising from this is actually behind a race condition and only shows up with the delay test, since we are waiting here.

Suggested change
cm_->set_parameter(rclcpp::Parameter("hardware_components_initial_state.unconfigured", "TestSystemHardware"));
cm_->set_parameter(rclcpp::Parameter("hardware_components_initial_state.unconfigured", std::vector<std::string>{"TestSystemHardware"}));

@fmauch
Copy link
Contributor

fmauch commented Sep 12, 2024

Also note: If we go with the changed parameter name we should probably add migration notes, unless we decide to backport this, as well, since probably nobody ever used it since it isn't working like that, anyway.

I've implemented my suggested changes in https://github.com/fmauch/ros2_control/commits/add-tests-for-hw-spawner/ since I needed that on a robot, anyway.

@destogl
Copy link
Member Author

destogl commented Sep 24, 2024

Closing in favor of #1759

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants