-
Notifications
You must be signed in to change notification settings - Fork 38
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
Add the possibility to set the name of each element of a variable stored in the variables handler #429
Conversation
Besides the trivial comments, the code looks good to me. There is one thing I am not entirely convinced of. If you want to have sub-labels, you need to give a label to each sub-element. Also, in this way you can have only one level of sub-labelling. In some cases, it might be useful to have multiple levels. Like
I was wondering if we could use the variable labeller class iteratively. Basically, when adding a variable, you pass directly a In any case, if you are not convinced, or you think it is not very feasible, we can forget this and move on without issues. |
I see what you mean but I don't know how we can handle it |
Basically in bipedal-locomotion-framework/src/System/include/BipedalLocomotion/System/VariablesHandler.h Line 48 in 1db88e0
you would have VariablesHandler instead of ptrdiff_t . Then instead of getElementIndex you could have getElement returning a VariableDescription (as with getVariable ).
In order to set the sub labels, you would need to pass a bipedal-locomotion-framework/src/System/include/BipedalLocomotion/System/VariablesHandler.h Line 98 in 1db88e0
I am not entirely sure this is possible anyway. Also, when passing the In any case, this was just to drop an idea. Feel free to ignore this and the comment above. |
mmmh at this point I don't know if we should keep separated the auto x = variable.getElement('base_velocity').getElement('linear_velocity).getElement('x')
x.size ///---> 1
x.offset ///----> the offset in the entire variable (in this case is the offset of linear_velocity
auto base_velocity = variable.getElement('base_velocity') Tomorrow morning I try to figure out something. By the way just to give you the reason why I opened this PR because I would like to implement a task in TSID where we can regularize a variable to a given quantity passed to the user. Here the variable could be the joint torque but I don't want to regularize all of them but only 4 to a given quantity. |
By the way we should be carefull in the case a new variable is added in an already existing group. All the next existing variables offset must be shifted of the size of the new variable and the group containing that variable must be expanded |
A possibility could be also to just store the offset of the first element, and you add this offset everytime you want to retrieve an element. Hence, with
Inside std::std::ptrdiff_t VariableHandler::getBaseIndex() const
{
if (parent == 0) return 0;
if (parent->handler == 0) return -1; //The descriptor is not part of any handler
return parent->offset + parent->handler->getBaseIndex();
}
It seems a good idea! If what I have proposed so far is not helping for the use case you need, feel free to move on 😉 |
If it is fine with you I can handle the suggestion you proposed here: #429 (comment) and #429 (comment) and merge the PR as it is. Then I can open an issue to keep track of this idea and we may implement it later on since right now I don;t have a clear idea on how to do it in a clean and proper way. |
Ok no problem |
As written in the title with this PR it is possible to set the label of each element of a variable stored in the handler. Thanks to this it will be easier to retrieve the index of the variable
The feature is already implemented also for the python bindings