When you drive a pose bone's location, you're actually driving its local, rather than global location (I guess that's true for any location, but still worth mentioning).
I've been trying to find the easiest way to drive the global location. I already know I can find the global location using either of these methods:
armature.matrix_world * pb.matrix * pb.location
So I thought that I'll write a custom driver function that will find the global location and drive the local location values according to a converting back from global-to-local.
But I can't seem to convert the global value back to the original local value. I tried:
armature.matrix_world.inverted() * pb.matrix.inverted() * globalLoc
pb.matrix.inverted() * globalLoc
But I could not get that original local value back. Since the order of these mutliplications is important, I tried to re-order the multiplicated variables in any arrangement possible but no luck.
I'm open to other methods for achieving this or any suggestions on how to solve it this way.