-
Notifications
You must be signed in to change notification settings - Fork 20
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
Fix copy of TrajOptProblem #265
Fix copy of TrajOptProblem #265
Conversation
Hi @abussy-aldebaran, thanks for using aligator! And thanks for opening a PR 😁 This class is definitely expected to be copyable and movable. I guess we were missing a test for that though! I was a bit surprised when reading your issue that the pointer wasn't properly copied over. As for your fix, I'd prefer letting the compiler generate the ctor and operators, because it'd be easier to maintain and update this class. The problem is that pointers aren't "regular" values semantically speaking. We could find a better way to cache the fact we can downcast the pointer to the initial error. I initially just stored the downcasted pointer to avoid dynamic_cast at runtime. What we could do is store a flag which indicates the initial condition is a What do you think? |
I agree, I was not a fan of adding the ctor/assignement and rather stick to the rule of zero, for the reason you mentionned. But maybe you don't need to support multiple inheritance ? A more robust solution could be to use an
Then we would perform the right cast when accessing the initial condition. The optimization would be lost in the case of multiple inheritance. Maybe that's what you had in mind ? Note that I'm not an expert in polymorphism/inheritance 🙄 . |
I think we just need to have a Boolean flag which states whether the initial condition is a StateErrorResidual. There's no use for (the troublemaker concept of) multiple inheritance here. Once we have that flag we can just static_cast our way to victory. |
fc8b11b
to
5090add
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes @abussy-aldebaran ! I just have some modifications to suggest. What do you think !
Also @abussy-aldebaran, could you please format your code? You just need to install |
5090add
to
45793b7
Compare
I added your suggestions. I also added:
|
45793b7
to
0982718
Compare
Thanks a lot for this PR @abussy-aldebaran ! Feel free to add yourself to the README if you want (especially if you think you would send in more contributions). |
You're welcome ! Thanks for your reactive feedback ! |
Hi,
When I tried to run the solo12 scenario from https://gitlab.laas.fr/gepetto/quadruped-reactive-walking, I got crashes from aligator.
I identified the following bug : the pointer
init_state_error_
inTrajOptProblemTpl
was not updated across copy/move, which could result in wrong values or crashes.I tried to make
TrajOptProblemTpl
non copyable nor movable, but I couldn't find a fix that would not break the python binding.So I went for the obvious fix. Please let me know if you prefer another solution.