I am currently making a robot controller using blender. The model of my robot and IK setup is already finished and I should say blender with its new IK solver, ItaSC makes rigging a bot a breeze. Unfortunately, when I started scripting in python, in order to retrieve bone joint angles, I stumbled in to an issue. My robot is a 6 axis robot, with a spherical wrist. I used obj.matrix_channel.to_euler() to figure out most of the joint angles and it worked except for the wrist pitch. My bot is controlled by ROBODK software for now, but I am trying to achieve same results with blender since, there is a good possibility that I can program it in real time. Here is the video of my bot just to give you an idea of how it should move. https://www.youtube.com/watch?v=a8kFMLZY6TQ

Unfortunately I can not upload my blend file since I am a new user. So I am pasting the python code I am currently using to get joint angles.

import bpy

from math import degrees

import mathutils

class SimpleBoneAnglesPanel(bpy.types.Panel):

bl_label = “Bone Angles”

bl_space_type = ‘VIEW_3D’

bl_region_type = ‘UI’

```
def draw(self, context):
arm = context.scene.objects['Armature']
bone = arm.pose.bones['Bone']
bone1 = arm.pose.bones['Bone.001']
bone2 = arm.pose.bones['Bone.002']
bone3 = arm.pose.bones['Bone.003']
bone4 = arm.pose.bones['Bone.004']
bone8 = arm.pose.bones['Bone.008']
mat = bone.matrix_channel.to_euler()
row = self.layout.row()
row.label(text='Bone')
#row.label(text='X: {:.3}'.format(degrees(mat.x)))
#row.label(text='Y: {:.3}'.format(degrees(mat.y)))
row.label(text='Z: {:.3}'.format(degrees(mat.z)))
mat1 = bone1.matrix_channel.to_euler()
row = self.layout.row()
row.label(text='Bone.001')
#row.label(text='X: {:.3}'.format(degrees(mat1.x)))
row.label(text='Y: {:.3}'.format(degrees(mat1.y)))
#row.label(text='Z: {:.3}'.format(degrees(mat1.z)))
mat2 = bone2.matrix_channel.to_euler()
row = self.layout.row()
row.label(text='Bone.002')
#row.label(text='X: {:.3}'.format(degrees(mat2.x)))
row.label(text='Y: {:.3}'.format(degrees(mat2.y-mat1.y)))
#row.label(text='Z: {:.3}'.format(degrees(mat2.z)))
mat3 = bone3.matrix_channel.to_euler()
row = self.layout.row()
row.label(text='Bone.003')
row.label(text='X: {:.3}'.format(degrees(mat3.x)))
#row.label(text='Y: {:.3}'.format(degrees(mat3.y)))
#row.label(text='Z: {:.3}'.format(degrees(mat3.z)))
mat4 = bone4.matrix_channel.to_euler()
row = self.layout.row()
row.label(text='Bone.004')
row.label(text='X: {:.3}'.format(degrees(mat4.x)))
row.label(text='Y: {:.3}'.format(degrees(mat4.y))) #this is where blender gets the angles wrong
row.label(text='Z: {:.3}'.format(degrees(mat4.z)))
mat8 = bone8.matrix_channel.to_euler()
row = self.layout.row()
row.label(text='Bone.008')
row.label(text='X: {:.3}'.format(degrees(mat8.x-mat4.x)))
#row.label(text='Y: {:.3}'.format(degrees(mat8.y)))
#row.label(text='Z: {:.3}'.format(degrees(mat8.z)))
```

bpy.utils.register_class(SimpleBoneAnglesPanel)

Should I be using another syntax to get the spherical joint angles, roll pitch and yaw correct?