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

URDF <gpio> component state interface "initial_value" param not getting read. #1277

Closed
Nibanovic opened this issue Jan 8, 2024 · 5 comments
Assignees
Labels

Comments

@Nibanovic
Copy link

Describe the bug
I've been trying to set up scaled_joint_trajectory_controller for my manipulator, like in UR_robot_driver, and test it using mocked hardware.
To do that, I need a <gpio> component which will hold the scaling_factor value.

Example component:

<gpio name="speed_scaling">
  <state_interface name="speed_scaling_factor">
    <param name="initial_value">1.0</param>
  </state_interface>
</gpio>

When setting the initial_value param, like in <joint> components for example, the param is not getting read.

To Reproduce

  1. Add the above component to your <ros2_control> tag in URDF
  2. Use mock_components/GenericSystem as hardware
  3. Add the speed_scaling_state_broadcaster controller from ur_controllers, which publishes the state interface of the component
  4. Launch the ros2_control node, robot_state_publisher node and the speed_scaling_state_broadcaster
  5. ros2 topic echo /speed_scaling_state_broadcaster/speed_scaling

Expected behavior
I would expect the topic to echo 100.0, as speed_scaling_state_broadcaster outputs the factor as %.
The actual output is .nan.

More Context
If I change the <gpio> tag to <joint>, so that the component looks like this:

<joint name="speed_scaling">
  <state_interface name="speed_scaling_factor">
    <param name="initial_value">1.0</param>
  </state_interface>
</joint>

... the component behaves as expected with mocked hardware. This leads me to believe that there could be an issue with the way <gpio> param initial value is parsed in the mock_components/GenericSystem

Environment:

  • OS: Ubuntu
  • Version: Humble -> both ros2_control and ur_controllers packages are humble
@christophfroehlich
Copy link
Contributor

I was not able to reproduce your issue with ros-controls/ros2_control_demos#429, neither on rolling or humble. Can you have a look at this PR, if there is a difference to your configuration?

Btw there is already a test for that

TEST_F(TestGenericSystem, gpio_with_initial_value)
{
auto urdf = ros2_control_test_assets::urdf_head + gpio_with_initial_value_ +
ros2_control_test_assets::urdf_tail;
TestableResourceManager rm(urdf);
// Activate components to get all interfaces available
activate_components(rm, {"GPIOWithInitialValue"});
// Check interfaces
EXPECT_EQ(1u, rm.system_components_size());
ASSERT_EQ(1u, rm.state_interface_keys().size());
EXPECT_TRUE(rm.state_interface_exists("sample_io/output_1"));
// Check initial values
hardware_interface::LoanedStateInterface state = rm.claim_state_interface("sample_io/output_1");
ASSERT_EQ(1, state.get_value());
}

@bailaC
Copy link
Contributor

bailaC commented Jan 12, 2024

@Nibanovic , will you be able to check this behavior with rolling? I see some code changes around the mock components in rolling. Just asking to verify this behavior on rolling.

@bailaC
Copy link
Contributor

bailaC commented Jan 13, 2024

Thank you @christophfroehlich for enhancing example 10. Your changes are working well for me for rolling. Humble yet to be checked.

@bailaC
Copy link
Contributor

bailaC commented Jan 14, 2024

Tried your test @christophfroehlich with humble also. Working as expected.

@Nibanovic
Copy link
Author

I have rebuilt my packages and retested everything as described in the issue. Funnily enough, now it is working as expected. Thanks for your time, apologies for the non-issue.

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

No branches or pull requests

3 participants