I develop a custom fullbody IK using MPXnode, MPXNode seem to be not able to drive all joints simultaneously

I develop a custom fullbody IK using MPXnode, MPXNode seem to be not able to drive all joints simultaneously

1240803839
Observer Observer
326 Views
1 Reply
Message 1 of 2

I develop a custom fullbody IK using MPXnode, MPXNode seem to be not able to drive all joints simultaneously

1240803839
Observer
Observer

    I develop a custom fullbody IK using MPXnode, MPXNode seem to be not able to drive all joints simultaneously.

All the rings's position and posture are inputs, the joints rotations are output of the IK MPXnode. 

   the IK algorthm in the compute function can assure that the foot is strictly anchored, so the jitter of the right foot must came from MPXNode and FK mechanism of the Maya. How could I fix this? 

 

 

 

def compute(self, plug, dataBlock):
if plug == followNode_AIIK.list_output[0]:
typelist_handle = dataBlock.inputValue(self.list_input[-1])
typelist_data = typelist_handle.data()
typelist = OpenMaya.MFnDoubleArrayData(typelist_data).array()

position_id = []
rotation_id = []
for i, name in enumerate(self.character_bone):
if typelist[i] < 0.5:
continue
position_id.append(i)
if "None" not in name:
input = dataBlock.inputValue(self.list_input[i])
value = input.asMatrix()
self.position[i] = np.array([value(3, 0), value(3, 1), value(3, 2)])
if typelist[i] > 1.5:
rotation_id.append(i)
self.rotation[i] = np.array([[value(0, 0), value(1, 0), value(2, 0)],
[value(0, 1), value(1, 1), value(2, 1)],
[value(0, 2), value(1, 2), value(2, 2)]])
print("Rotation is Now")

self.global_locapos = self.position


# for j in range(len(double_array)):
# print("doubleArray[{}] = {}".format(j, double_array[j]))

active_id_input = [7]
position_id = np.array(position_id).astype(int)
rotation_id = np.array(rotation_id).astype(int)

active_id_input = np.array(active_id_input).astype(int)
self.global_locapos /= self.scale_model

self.predicted_quat, self.translation_pred = self.ai_ik_.smpl_ik_onnx(
position_data=self.global_locapos[position_id].copy(),
position_id=position_id,
skeleton_in_smplxorder=self.standard_inputmodel,

active_id_input=active_id_input,
active_pos_or_rot=self.global_locapos[active_id_input].copy(),

rotation_data=self.rotation[rotation_id].copy(),
rotation_id=rotation_id,
lookdir=None,
lookid=[],
withpost_process=True)

self.translation_pred = self.translation_pred * self.scale_model# + self.ori_inmodel[0]

self.global_jntpos, self.global_eulers = global_rigid_transformation_quat_toEuler(self.predicted_quat.copy(),
J=self.ori_inmodel.copy(),
kintree_table=self.kintables,
trans=self.translation_pred,
degree=False)



output_euler = self.retargetr_bone.processing_to_tgtEuler(self.predicted_quat[:22], roo=self.rot_order, degree=False)

for i, name in enumerate(self.character_bone):
if "None" not in name:
outputData = dataBlock.outputValue(self.list_output[i])
outputData.set3Float(output_euler[i, 0], output_euler[i, 1], output_euler[i, 2])

outputData = dataBlock.outputValue(self.list_output[22])
outputData.set3Float(self.translation_pred[0], self.translation_pred[1], self.translation_pred[2])

for i, name in enumerate(self.character_bone):
if "None" not in name and typelist[i] < 0.5:
outputData = dataBlock.outputValue(self.list_output[22 + 1 + i * 2 + 0])
outputData.set3Float(self.global_eulers[i, 0], self.global_eulers[i, 1], self.global_eulers[i, 2])

outputData = dataBlock.outputValue(self.list_output[22 + 1 + i * 2 + 1])
outputData.set3Float(self.global_jntpos[i, 0], self.global_jntpos[i, 1], self.global_jntpos[i, 2])

if "None" not in name and typelist[i] == 1:
outputData = dataBlock.outputValue(self.list_output[22 + 1 + i * 2 + 0])
outputData.set3Float(self.global_eulers[i, 0], self.global_eulers[i, 1], self.global_eulers[i, 2])

if "None" not in name and typelist[i] == 2:
outputData = dataBlock.outputValue(self.list_output[22 + 1 + i * 2 + 1])
outputData.set3Float(self.global_jntpos[i, 0], self.global_jntpos[i, 1], self.global_jntpos[i, 2])

dataBlock.setClean(plug)



# return OpenMaya.kSuccess
else:
return OpenMaya.kUnknownParameter

The compute algorithm is shown as follows: 

0 Likes
327 Views
1 Reply
Reply (1)
Message 2 of 2

jmreinhart
Advisor
Advisor

Is this compute function something you wrote yourself or is it adapted from an existing ik solution? 

Could you maybe add some comments to the code so that it's easier to tell what the intended behaviour of each section is? 

0 Likes