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

Avoid redeclaration of parameters (automatically declared parameters) #224

Merged

Conversation

livanov93
Copy link
Contributor

@livanov93 livanov93 commented Aug 16, 2021

PR addresses #149. Parameters are needed for checks within jtc.
As mentioned here in the future adjusting detailed per joint parameters could be done dynamically.

EDIT:
PR enables existence of parameters uploaded via overrides (e.g. yaml files). It is blocked by #ros2_control/PR504

@destogl
Copy link
Member

destogl commented Aug 16, 2021

Are you sure this didn't work before? Controllers should have auto-declaration of parameters enabled...

Would be nice to get some test for this, showing what exactly wasn't working.

@livanov93
Copy link
Contributor Author

Pretty sure, I will try to make tests to show the problem.

@destogl
Copy link
Member

destogl commented Aug 17, 2021

This line enables auto-declaration of parameters. That's the reason I am asking...

@Ace314159
Copy link
Contributor

I can confirm that this is needed. If you change the log level to debug, it will log the parameters. Regardless of the parameters specified, it is always 0.

Copy link
Member

@bmagyar bmagyar left a comment

Choose a reason for hiding this comment

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

Ok. We may need to revisit this in Galactic but if it's blocking on Foxy, I'm tempted to merge it now

@bmagyar
Copy link
Member

bmagyar commented Aug 25, 2021

Speaking too soon perhaps :D

@livanov93 @Ace314159 , what ROS distro are you guys running?
The tests came back with this:

 - joint_trajectory_controller.PositionVelocityAccelerationTrajectoryControllers/TrajectoryControllerTestParameterized correct_initialization_using_parameters/1
  <<< failure message
    unknown file
    C++ exception with description "parameter 'constraints.joint1.trajectory' has already been declared" thrown in the test body.
  >>>
- joint_trajectory_controller.PositionVelocityAccelerationTrajectoryControllers/TrajectoryControllerTestParameterized correct_initialization_using_parameters/2
  <<< failure message
    unknown file
    C++ exception with description "parameter 'constraints.joint1.trajectory' has already been declared" thrown in the test body.
  >>>

Is something wrong with how we test this perhaps? Or some bug in rclcpp that makes it work with the test setup but not otherwise?

@livanov93
Copy link
Contributor Author

livanov93 commented Aug 25, 2021

@bmagyar
I am on foxy, however f996475 will fix the test passing where configure is called multiple times (like here and here) within the same test. The controller should be configurable multiple times definitely, so this commit tackles that problem.

Still I think that there is a misunderstanding of allow_undeclared_parameters in controller_interface.
In documentation we can find that this is enough for putting the parameters into node's namespace without declaration.
If you take a closer look few lines on a flag automatically_declare_parameters_from_overrides and its documentation it says if it is false the parameters from overrides (yaml files) won't appear even though allow_undeclared_parameters is true.

There is a small discussion on the documentation improvements here and here.

So in my understanding controller_interface should have allow_undeclared_parameters and automatically_declare_parameters_from_overrides to true and then in each instance of controller (e.g. joint_trajectory_controller, JointGroupVelocityController...) we should check if node has some parameter or not, and then act accordingly.

@bmagyar
Copy link
Member

bmagyar commented Aug 25, 2021

Using automatically_declare_parameters_from_overrides sounds like a better fix than this.
I vaguely remember something about removing that for some reason... let's check

@bmagyar
Copy link
Member

bmagyar commented Aug 25, 2021

ros-controls/ros2_control#276

It seems this was removed due to some error report from you earlier ;) could you test locally that fixing in controller_interface.cpp actually works?

@livanov93
Copy link
Contributor Author

livanov93 commented Aug 25, 2021

Yes, it is correct. Still I realized we had wrong approach in ros_controls/ros2_control#276. We just had to add check if some parameter already exist before its declaration in all of the controllers (everything that inherits from controller_interface). Something like this.
I will test it, but I am also sure that we need change in controller_interface (put automatically_declare_parameters_from_overrides to true ) and in all controllers add check if any parameter exists before its declaration.

@livanov93 livanov93 closed this Aug 27, 2021
@livanov93 livanov93 force-pushed the livanov/declare_per_joint_params branch from f996475 to 3c61e4f Compare August 27, 2021 08:29
@livanov93 livanov93 reopened this Aug 27, 2021
@livanov93 livanov93 changed the title [JointTrajectoryController] Declaration of detailed jtc parameters [JointTrajectoryController] Avoid redeclaration of parameters (automatically declared parameters) Aug 27, 2021
@livanov93 livanov93 changed the title [JointTrajectoryController] Avoid redeclaration of parameters (automatically declared parameters) Avoid redeclaration of parameters (automatically declared parameters) Aug 27, 2021
@livanov93 livanov93 requested a review from bmagyar August 27, 2021 12:59
Copy link
Member

@destogl destogl left a comment

Choose a reason for hiding this comment

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

Looks good and sensible chnage! Thanks!

@bmagyar bmagyar merged commit 413a663 into ros-controls:master Aug 30, 2021
gwalck pushed a commit to StoglRobotics-forks/ros2_controllers that referenced this pull request Jun 7, 2023
* introducing handles

Signed-off-by: Karsten Knese <[email protected]>

* component interfaces & tests

Signed-off-by: Karsten Knese <[email protected]>

* linters

Signed-off-by: Karsten Knese <[email protected]>

* import resource manager

Signed-off-by: Karsten Knese <[email protected]>

* correct year

Signed-off-by: Karsten Knese <[email protected]>

* import handles from loaded components

Signed-off-by: Karsten Knese <[email protected]>

* wip / debug

Signed-off-by: Karsten Knese <[email protected]>

* parse components

Signed-off-by: Karsten Knese <[email protected]>

* changes after rebase

Signed-off-by: Karsten Knese <[email protected]>

* component parser as shared library

Signed-off-by: Karsten Knese <[email protected]>

* validate urdf configuratin

Signed-off-by: Karsten Knese <[email protected]>

* documentation

Signed-off-by: Karsten Knese <[email protected]>

* remove default constructor

Signed-off-by: Karsten Knese <[email protected]>

* resource loaning

Signed-off-by: Karsten Knese <[email protected]>

* loan state interface

Signed-off-by: Karsten Knese <[email protected]>

* import externally declared components

Signed-off-by: Karsten Knese <[email protected]>

* move resource manager to hardware interface (ros-controls#226)

* move resource manager to hardware interface

Signed-off-by: Karsten Knese <[email protected]>

* include functional for std::function

Co-authored-by: Bence Magyar <[email protected]>

* address review comments

Signed-off-by: Karsten Knese <[email protected]>

Co-authored-by: Bence Magyar <[email protected]>
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.

4 participants