3
$\begingroup$

I have a simple scene with a motor and its shaft on which a spool is attached. The animation works, the shaft is rotating and I can control its value from python using :

bpy.data.objects['Constraint.motor'].rigid_body_constraint.motor_ang_target_velocity = 0.5

It must be possible to get the actual rotation (angular position) of the shaft, but when I do :

bpy.data.objects['Spool'].rotation_euler

it only gives me the Euler angles at keyframe 0, but not the actual value as the animation is being played. Is their a way to access this value ?

The final goal is to simulate a motor encoder for a robotics simulation. Thanks !

$\endgroup$
1
$\begingroup$

The Object's matrix_world is what you're after. Call to_euler(...) to get the Euler angles.

bpy.data.objects['Spool'].matrix_world.to_euler('XYZ')

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.