{"action":"created","issue":{"url":"https://api.github.com/repos/mjs513/VPythonIMUGui/issues/1","labels_url":"https://api.github.com/repos/mjs513/VPythonIMUGui/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/mjs513/VPythonIMUGui/issues/1/comments","events_url":"https://api.github.com/repos/mjs513/VPythonIMUGui/issues/1/events","html_url":"https://github.com/mjs513/VPythonIMUGui/issues/1","id":72367116,"number":1,"title":"IMU animation","user":{"login":"akhilmohan4487","id":5743851,"avatar_url":"https://avatars.githubusercontent.com/u/5743851?v=3","gravatar_id":"","url":"https://api.github.com/users/akhilmohan4487","html_url":"https://github.com/akhilmohan4487","followers_url":"https://api.github.com/users/akhilmohan4487/followers","following_url":"https://api.github.com/users/akhilmohan4487/following{/other_user}","gists_url":"https://api.github.com/users/akhilmohan4487/gists{/gist_id}","starred_url":"https://api.github.com/users/akhilmohan4487/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akhilmohan4487/subscriptions","organizations_url":"https://api.github.com/users/akhilmohan4487/orgs","repos_url":"https://api.github.com/users/akhilmohan4487/repos","events_url":"https://api.github.com/users/akhilmohan4487/events{/privacy}","received_events_url":"https://api.github.com/users/akhilmohan4487/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-05-01T06:24:46Z","updated_at":"2015-05-05T11:19:53Z","closed_at":null,"body":"Hello,\r\n\r\nI am trying to make the animation using IMU and I have edited the code of Jose Julio @2009. The code executes with out error but IMU visualization window is not showing the object and then the changes according to movement. It would be great if you can help me to sort this.Here is my test code. \r\n\r\nfrom visual import *\r\nimport serial\r\nimport string\r\nimport struct\r\nimport csv\r\nimport math\r\nimport time\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nfrom time import time\r\n\r\nmsg = ''\r\nfull_msg = None\r\ndeg2rad = 3.141592/180.0\r\nser = serial.Serial(port='COM15',baudrate=115200,timeout=1)\r\n\r\nscene=display(title=\"IMU Visualization 1\")\r\nscene.range=(1.2,1.2,1.2)\r\nscene.forward = (1,0,-0.25)\r\nscene.up=(0,0,1)\r\n\r\nscene2 = display(title='IMU Visualization 2',x=0, y=0, width=500, height=200,center=(0,0,0), background=(0,0,0))\r\nscene2.range=(1,1,1)\r\nscene.width=500\r\nscene.y=200\r\n\r\nscene2.select()\r\ncil_roll = cylinder(pos=(-0.4,0,0),axis=(0.2,0,0),radius=0.01,color=color.red)\r\ncil_roll2 = cylinder(pos=(-0.4,0,0),axis=(-0.2,0,0),radius=0.01,color=color.red)\r\ncil_pitch = cylinder(pos=(0.1,0,0),axis=(0.2,0,0),radius=0.01,color=color.green)\r\ncil_pitch2 = cylinder(pos=(0.1,0,0),axis=(-0.2,0,0),radius=0.01,color=color.green)\r\narrow_course = arrow(pos=(0.6,0,0),color=color.cyan,axis=(-0.2,0,0), shaftwidth=0.02, fixedwidth=1)\r\n\r\nlabel(pos=(-0.4,0.3,0),text=\"Roll\",box=0,opacity=0)\r\nlabel(pos=(0.1,0.3,0),text=\"Pitch\",box=0,opacity=0)\r\nlabel(pos=(0.55,0.3,0),text=\"Yaw\",box=0,opacity=0)\r\nlabel(pos=(0.6,0.22,0),text=\"N\",box=0,opacity=0,color=color.yellow)\r\nlabel(pos=(0.6,-0.22,0),text=\"S\",box=0,opacity=0,color=color.yellow)\r\nlabel(pos=(0.38,0,0),text=\"W\",box=0,opacity=0,color=color.yellow)\r\nlabel(pos=(0.82,0,0),text=\"E\",box=0,opacity=0,color=color.yellow)\r\nlabel(pos=(0.75,0.15,0),height=7,text=\"NE\",box=0,color=color.yellow)\r\nlabel(pos=(0.45,0.15,0),height=7,text=\"NW\",box=0,color=color.yellow)\r\nlabel(pos=(0.75,-0.15,0),height=7,text=\"SE\",box=0,color=color.yellow)\r\nlabel(pos=(0.45,-0.15,0),height=7,text=\"SW\",box=0,color=color.yellow)\r\n\r\nL1 = label(pos=(-0.4,0.22,0),text=\"-\",box=0,opacity=0)\r\nL2 = label(pos=(0.1,0.22,0),text=\"-\",box=0,opacity=0)\r\nL3 = label(pos=(0.7,0.3,0),text=\"-\",box=0,opacity=0)\r\n\r\nscene.select()\r\narrow(color=color.green,axis=(1,0,0), shaftwidth=0.02, fixedwidth=1)\r\narrow(color=color.green,axis=(0,-1,0), shaftwidth=0.02 , fixedwidth=1)\r\narrow(color=color.green,axis=(0,0,-1), shaftwidth=0.02, fixedwidth=1)\r\nlabel(pos=(0,0,0.8),text=\"IMU Visualization 1\",box=0,opacity=0)\r\nlabel(pos=(1,0,0),text=\"X\",box=0,opacity=0)\r\nlabel(pos=(0,-1,0),text=\"Y\",box=0,opacity=0)\r\nlabel(pos=(0,0,-1),text=\"Z\",box=0,opacity=0)\r\nplatform = box(length=1, height=0.05, width=1, color=color.red)\r\np_line = box(length=1,height=0.08,width=0.1,color=color.yellow)\r\nplat_arrow = arrow(color=color.green,axis=(1,0,0), shaftwidth=0.06, fixedwidth=1)\r\n\r\nroll    = 0\r\npitch   = 0\r\nyaw     = 0\r\n\r\ndef Euler():\r\n    global msg\r\n    while(ser != 0):\r\n        if (ser.inWaiting() != 0):\r\n            msg += str(ser.read(ser.inWaiting()))\r\n            # Look for full message.\r\n            full_msg = msg.split('Z')\r\n            for f in full_msg:\r\n                # print f\r\n                # print len(f)\r\n                if (len(f) == 12):\r\n                    # Packing the data in to 8bit format so that struct.unpack module can be used to obtain the float val\r\n                    roll_hex = f[0:4] + '0000'\r\n                    pitch_hex = f[4:8] + '0000'\r\n                    yaw_hex = f[8:12] + '0000'\r\n                    # print yaw_hex,pitch_hex,roll_hex\r\n                    Yaw = struct.unpack('!f', yaw_hex.decode('hex'))[0]\r\n                    Pitch = struct.unpack('!f', pitch_hex.decode('hex'))[0]\r\n                    Roll = struct.unpack('!f', roll_hex.decode('hex'))[0]\r\n                    return Roll,Pitch,Yaw\r\n                    # print Yaw,Pitch,Roll\r\n\r\ndef main():\r\n    while 1:\r\n        R,P,Y = Euler()\r\n        rot_angle = [R,P,Y]\r\n        if len(rot_angle) > 2:\r\n            try:\r\n              roll  = float(rot_angle[0])\r\n              pitch = float(rot_angle[1])\r\n              yaw   = float(rot_angle[2])\r\n            except:\r\n              print(\"Invalid line\")\r\n            axis=(math.cos(pitch)*math.cos(yaw),-math.cos(pitch)*math.sin(yaw),math.sin(pitch))\r\n            up=(math.sin(roll)*math.sin(yaw) + math.cos(roll)*math.sin(pitch)*math.cos(yaw),math.sin(roll)*math.cos(yaw) - math.cos(roll)*math.sin(pitch)*math.sin(yaw),-math.cos(roll)*math.cos(pitch))\r\n            # print axis,up\r\n            platform.axis=axis\r\n            platform.up=up\r\n            platform.length=1.0\r\n            platform.width=0.65\r\n            plat_arrow.axis=axis\r\n            plat_arrow.up=up\r\n            plat_arrow.length=0.8\r\n            p_line.axis=axis\r\n            p_line.up=up\r\n            temp_cos_roll = math.cos(roll)\r\n            temp_sin_roll = math.sin(roll)\r\n            temp_cos_pitch = math.cos(pitch)\r\n            temp_sin_pitch = math.sin(pitch)\r\n            temp_cos_yaw = math.cos(yaw)\r\n            temp_sin_yaw = math.sin(yaw)\r\n            cil_roll.axis=(0.2*temp_cos_roll,0.2*temp_sin_roll,0)\r\n            cil_roll2.axis=(-0.2*temp_cos_roll,-0.2*temp_sin_roll,0)\r\n            cil_pitch.axis=(0.2*temp_cos_pitch,0.2*temp_sin_pitch,0)\r\n            cil_pitch2.axis=(-0.2*temp_cos_pitch,-0.2*temp_sin_pitch,0)\r\n            arrow_course.axis=(0.2*temp_sin_yaw,0.2*temp_cos_yaw,0)\r\n            L1.text = str(float(rot_angle[0]))\r\n            L2.text = str(float(rot_angle[1]))\r\n            L3.text = str(float(rot_angle[2]))\r\n            # print L1.text,L2.text,L3.text\r\n    ser.close\r\n\r\nif __name__ == '__main__':\r\n  while(ser != 0):\r\n      main()\r\n\r\nThanks and Regards,\r\nAkhil."},"comment":{"url":"https://api.github.com/repos/mjs513/VPythonIMUGui/issues/comments/99037089","html_url":"https://github.com/mjs513/VPythonIMUGui/issues/1#issuecomment-99037089","issue_url":"https://api.github.com/repos/mjs513/VPythonIMUGui/issues/1","id":99037089,"user":{"login":"akhilmohan4487","id":5743851,"avatar_url":"https://avatars.githubusercontent.com/u/5743851?v=3","gravatar_id":"","url":"https://api.github.com/users/akhilmohan4487","html_url":"https://github.com/akhilmohan4487","followers_url":"https://api.github.com/users/akhilmohan4487/followers","following_url":"https://api.github.com/users/akhilmohan4487/following{/other_user}","gists_url":"https://api.github.com/users/akhilmohan4487/gists{/gist_id}","starred_url":"https://api.github.com/users/akhilmohan4487/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akhilmohan4487/subscriptions","organizations_url":"https://api.github.com/users/akhilmohan4487/orgs","repos_url":"https://api.github.com/users/akhilmohan4487/repos","events_url":"https://api.github.com/users/akhilmohan4487/events{/privacy}","received_events_url":"https://api.github.com/users/akhilmohan4487/received_events","type":"User","site_admin":false},"created_at":"2015-05-05T11:19:53Z","updated_at":"2015-05-05T11:19:53Z","body":"Hello,\r\n\r\nThe animation started working, but it does not follow the movement that I perform. (When I rotate the sensor by 45 deg, it does not happens on animation side). I have taken the raw data from sensors and done a simple calibration for calculating bias for accelro, gyro and magneto (fs= 200 Hz). This is fed to a Madgwick filter to obtain the absolute orientation in quaternion form (beta = 0.097). From this I calculated the Euler angle and this data is sent to PC at 115200kbps.\r\nOn the PC side I unpack the data as I have shown in the code before with rate = 30. Is there any mistake in the process. What is your suggestion to resolve the issue ?\r\n\r\nThanks and Regards.\r\nAkhil"}}