Relative Bone ObjectSpace Matrix

Hey guys…
I have an issue here… And I just don’t get the solution.

The following is my problem.

I have a pose_bone and I want to get its relative local object position. So not the position in its own bone space and relative to its parent bone.
Now posebones have three matrices.

Here are the matrices
pose_bone.matrix (Gives me the object space matrix, but not relative to its parent :frowning: )
The wiki says: “Final 4x4 matrix after constraints and drivers are applied (object space)”

pose_bone.matrix_basis (gives me a relative matrix to its parent, but not in object space :frowning: )
The wiki says: “Alternative access to location/scale/rotation relative to the parent and own rest bone”

The wiki says: “4x4 matrix, before constraints”

Wiki Link

Now I need the object space coordinates of a bone, but RELATIVE to its parent. So a combination of “matrix” and “matrix basis”. Is this somehow possible to get? I just don’t know how to get that matrix which is in object space but still always relative to its bone parents. Can someone, whith a better understanding of matrix manipulation, help me out here? ^^

Ok… I have the solution for my problem. This is how I translate the bone position from bone space to local object space relative to its parent:

active_bone = bpy.context.active_bone
active_p_bone = bpy.context.active_pose_bone
loc = ((active_bone.matrix_local.to_4x4() * active_p_bone.matrix_basis).to_translation()) - (active_bone.parent.matrix_local.to_4x4()).to_translation()