# How to rotate a simple model if you have accelerator, gyroscope, magnetometer data?

I have accelerator, gyroscope, and magnetometer data in an excel spreadsheet right now - is there anyway to update the position of the model with this information?

I can turn this data into Euler angles (roll, pitch, yaw) as well.

[

[

0.09692 0.039491 -0.069455
0.10186 0.040769 -0.073018
0.10803 0.043278 -0.077164
0.11481 0.045181 -0.081301
0.12036 0.047688 -0.085457
0.12653 0.048973 -0.088998
0.13269 0.051484 -0.093142
0.13885 0.05277 -0.096683
0.14441 0.05467 -0.10084
0.14996 0.056563 -0.10439
0.15614 0.059082 -0.10914
0.16108 0.06159 -0.11331
0.16541 0.064088 -0.11687
0.17095 0.065983 -0.12042
0.1759  0.067882 -0.12459
0.18146 0.069784 -0.12875
0.18702 0.072303 -0.13351
0.19257 0.074809 -0.13705
0.19812 0.077322 -0.14121
0.20429 0.079845 -0.14596
0.20984 0.080516 -0.1489
0.21537 0.082406 -0.15184
0.22033 0.084925 -0.15661
0.22587 0.087433 -0.16015
0.23143 0.090565 -0.16491
0.23698 0.092471 -0.16906
0.24252 0.095589 -0.1726
0.24745 0.096869 -0.17555
0.25423 0.10001 -0.18029
0.26039 0.10375 -0.18442
0.26594 0.10627 -0.18856
0.2721  0.1094  -0.1927
0.27703 0.1119  -0.19625
0.2838  0.11504 -0.20037
0.28935 0.11695 -0.20452
0.29489 0.11945 -0.20745
0.30043 0.12135 -0.211
0.3066  0.12266 -0.21514
0.31215 0.12396 -0.2193
0.31707 0.12523 -0.22164
0.32199 0.12713 -0.22458
0.32753 0.12964 -0.22812
0.33368 0.13216 -0.23165
0.33862 0.13406 -0.2352
0.34417 0.13658 -0.23935
0.3491  0.13788 -0.24291
0.35528 0.13981 -0.24827
0.35959 0.14231 -0.25121
0.36573 0.14666 -0.25472
0.37129 0.14981 -0.25947
0.37684 0.15356 -0.26421
0.383   0.15732 -0.26895
0.3892  0.15927 -0.27552
0.39564 0.16147 -0.29734
0.40146 0.16365 -0.35821
0.40711 0.16567 -0.44775
0.41276 0.17016 -0.53849
0.41838 0.17402 -0.6274
0.42294 0.17745 -0.72731
0.42901 0.1812  -0.84672
0.43432 0.18607 -0.99723
0.43932 0.19251 -1.1691
0.44436 0.19903 -1.3452
0.44957 0.20578 -1.5341
0.45545 0.21203 -1.7285
0.46273 0.21914 -1.9363
0.4694  0.23062 -2.1489
0.47613 0.24224 -2.3683
0.48115 0.24915 -2.5968
0.48845 0.26086 -2.8186
0.49583 0.27767 -3.0519
0.50437 0.30436 -3.2905
0.51219 0.32678 -3.5274
0.51942 0.34508 -3.7704
0.52771 0.36452 -4.0073
0.52123 0.30253 -4.296
0.52421 0.30086 -4.6168
0.52835 0.30818 -5.0308
0.53244 0.31553 -5.4448
0.53733 0.32572 -5.8795
0.5419  0.3356  -6.2946
0.54674 0.34575 -6.6891


### Edit:

I am still having an issue. It seems that the rotation matrix is not functioning properly. I attached a picture above. If I type in 45 degrees into the X degree slot in the picture, the object will move 45 degrees. But if I force 45 degrees into the text editor and make that an input to the rotational matrix, the object moves at an noticeably larger angle than 45 degrees.

• This will probably need a python script
– Tim
Jan 9 '18 at 20:37
• Can you post a .csv file of some of the data? Jan 9 '18 at 22:43
• Im not exactly sure how to post csv files on here - anyway I could email the files to you?
– Joey
Jan 9 '18 at 23:42
• @ScottMilner See above
– Joey
Jan 9 '18 at 23:44
• @ScottMilner I also added pictures of the data files.
– Joey
Jan 9 '18 at 23:50

I'm not exactly sure what you want to do with the Accelerometer and Magnetometer data, but the rotation can be done pretty easily with Animation Nodes.

After installing Animation Nodes (link above), create a text block in Blender with all of your Euler Rotation data. Make sure that there is only one space between each of the elements so it can be parsed easier:

In the Animation Nodes node editor add a Text Block Reader node (press Ctrl + A to search all nodes or Shift + A to view the node menu). Then add a Split Text node and split by Lines:

Next, we need to parse all of these strings into vectors. To do this, add an Expression node and create a new input from the Text List output of the previous node and name it t. Use the gear icon to set the output type to Euler List. Paste the following code into the text box:

[[float(e) for e in a.split(" ")] for a in t]


If your data is in degrees, you'll need to convert to radians:

[[(float(e)*pi/180) for e in a.split(" ")] for a in t]


The rest of it is just inserting and connecting nodes. Here's the completed NodeTree:

You can replace the Cube object with whatever yours is named.

Here is the result:

• Are you in scripting/ animation/ other mode? @ScottMilner
– Joey
Jan 10 '18 at 14:19
• @Joey I'm in the Animation Nodes node editor. You have to install the addon to see it. Jan 10 '18 at 19:30
• This is great! I hadn't heard about Animation Nodes, will give it a try!
– uhoh
Feb 27 '18 at 19:52