orocos_kinematics_dynamics icon indicating copy to clipboard operation
orocos_kinematics_dynamics copied to clipboard

Should ChainIkSolverPos__LMA store a KDL::Chain as a const ref?

Open diogoalmeida opened this issue 7 years ago • 4 comments

When the Levenberg-Marquardt solver stores the kinematic chain as a const ref,

https://github.com/orocos/orocos_kinematics_dynamics/blob/a7a8d282a5a94948176f2c5af58fbd047d849030/orocos_kdl/src/chainiksolverpos_lma.hpp#L160

It allows scenarios where the chain passed in the constructor is destroyed, and the solver will eventually segfault when its called, without warning for what has happened. If the intention is to not copy the chain, a shared pointer should be used.

Just spent a couple hours trying to understand why suddenly my IK solver was segfaulting :)

diogoalmeida avatar May 27 '18 17:05 diogoalmeida

Sorry to here about time being wasted over this. Having a reference instead of a copy is intentional see https://github.com/orocos/orocos_kinematics_dynamics/pull/63 . A solution with shared pointers is welcomed, but I imagine this will most probably break the API

smits avatar Dec 27 '18 14:12 smits

Just out of curiosity, what is the reasoning behind the const refs?

Thanks for taking the time to reply, happy holidays!

diogoalmeida avatar Dec 27 '18 16:12 diogoalmeida

It was mostly to support changing masses and end effectors including extra joints without having to recreate the solvers.

Op do 27 dec. 2018 17:41 schreef Diogo Almeida [email protected]:

Just out of curiosity, what is the reasoning behind the const refs?

Thanks for taking the time to reply, happy holidays!

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/orocos/orocos_kinematics_dynamics/issues/147#issuecomment-450187308, or mute the thread https://github.com/notifications/unsubscribe-auth/AAG0m5BrZynZ7rgj8I4hjreekvpy3JQ9ks5u9PgjgaJpZM4UPWyA .

-- Ruben Smits, VP of Engineering - Founder +32 479 511 786 Pickit - Gaston Geenslaan 9, 3001 Heverlee - BELGIUM www.pickit3d.com

smits avatar Dec 27 '18 17:12 smits

From my viewpoint it is bad design decision. I commented it here https://github.com/orocos/orocos_kinematics_dynamics/pull/63#issuecomment-455871763

disRecord avatar Jan 20 '19 14:01 disRecord