manipulation: add TransitionPlanner::planPathSingle to work around eigenpy (1,N) Ref<MatrixXd> corruption#124
Open
thanhndv212 wants to merge 1 commit intohumanoid-path-planner:develfrom
Open
Conversation
…genpy (1,N) Ref<MatrixXd> corruption When a (1,N) numpy array is passed as matrixIn_t (Eigen::Ref<const MatrixXd>), numpy marks it as both C- and F-contiguous (layout is irrelevant for a single row). eigenpy's is_arr_layout_compatible_with_mat_type<MatrixXd> checks only the F-contiguous flag, sees true, and creates a direct Map with NumpyMapStride = Stride<0,0>. The compile-time-zero strides override the actual numpy strides, so only element (0,0) maps correctly; all (0,c) for c > 0 read garbage memory. planPath(qInit, qGoals, reset) is preserved unchanged and works correctly for multi-row goals matrices (rows > 1), where C- and F-contiguous flags differ and eigenpy correctly allocates a copy. planPathSingle(qInit, qGoal, reset) is added as a safe single-goal alternative: it accepts two 1D ConfigurationIn_t (Ref<const VectorXd>, handled correctly by eigenpy's IsVectorAtCompileTime specialisation) and builds a C++-owned MatrixXd(1,n) internally before calling planPath.
Contributor
|
Hello @thanhndv212. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a (1,N) numpy array is passed as matrixIn_t (Eigen::Ref), numpy marks it as both C- and F-contiguous (layout is irrelevant for a single row). eigenpy's is_arr_layout_compatible_with_mat_type checks only the F-contiguous flag, sees true, and creates a direct Map with NumpyMapStride = Stride<0,0>. The compile-time-zero strides override the actual numpy strides, so only element (0,0) maps correctly; all (0,c) for c > 0 read garbage memory.
planPath(qInit, qGoals, reset) is preserved unchanged and works correctly for multi-row goals matrices (rows > 1), where C- and F-contiguous flags differ and eigenpy correctly allocates a copy.
planPathSingle(qInit, qGoal, reset) is added as a safe single-goal alternative: it accepts two 1D ConfigurationIn_t (Ref, handled correctly by eigenpy's IsVectorAtCompileTime specialisation) and builds a C++-owned MatrixXd(1,n) internally before calling planPath.