orocos_kinematics_dynamics
orocos_kinematics_dynamics copied to clipboard
Prevent segfault in PyKDL when asking for nonexisting segment of chain
Added methodcode to the Chain class to throw an IndexError when trying to retrieve a segment that doesn't exist.
It should be noted that this change is not consistent with the C++ version of getSegment(), which deliberately does not implement any checks on the index, probably for performance reasons. In C++ it is up to the caller to make sure that the given index is valid.
https://github.com/orocos/orocos_kinematics_dynamics/blob/a2a2dff5eae7671c2d8db23d1173f6bb3cff6a29/orocos_kdl/src/chain.hpp#L78-L96
@meyerj Do you think we should implement such checks for all index functions in PyKDL? I will work on a new PR as this one is outdated.