epfl-lasa / control-libraries

A collection of library modules to facilitate the creation of full control loop algorithms, including state representation, motion planning, kinematics, dynamics and control.
https://epfl-lasa.github.io/control-libraries
GNU General Public License v3.0
27 stars 2 forks source link

Add the set_parameter_value #236

Closed buschbapti closed 2 years ago

buschbapti commented 2 years ago

The set_parameter_value function was not implemented forcing to use set_parameter(std::make_shared<...>) syntax which is very verbose and not friendly to use at all. It is also misleading because you would think that it would reset the underlying pointer to set it as the newly provided (expected behavior).

This is not what is happening in the background as the nested implementation of the set_parameter function at the end just copy the value of the new pointer into the old pointer. This would be the expected behavior of the set_parameter_value but not a set_parameter function in which you throw a pointer.

Unfortunately, I haven't found yet a proper way to write those functions with their correct expected behavior. For now, I have moved the set_parameter(std::make_shared<...>) syntax in the set_parameter_value function which, at least, lighten a bit the syntax of setting new values for parameters.

I have also made a few corrections with missing const and [[nodiscard]] keywords. One of the biggest refactor concerns the JointState implementation. It does not make sense to provide a base_frame for it which should be only needed for Spatial DS. I have, therefore, updated the template implementations to remove this need.

buschbapti commented 2 years ago

Thanks a lot for your contribution as well. I am waiting for this to merge before opening the PR on Modulo.