-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef76bdd
commit 996ecd6
Showing
1 changed file
with
194 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,194 @@ | ||
{ | ||
"metadata": { | ||
"name": "roll_pitch_from_accel" | ||
}, | ||
"nbformat": 3, | ||
"nbformat_minor": 0, | ||
"worksheets": [ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"collapsed": false, | ||
"input": [ | ||
"import sympy as sym" | ||
], | ||
"language": "python", | ||
"metadata": {}, | ||
"outputs": [], | ||
"prompt_number": 1 | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"collapsed": true, | ||
"input": [ | ||
"import sympy.physics.mechanics as me" | ||
], | ||
"language": "python", | ||
"metadata": {}, | ||
"outputs": [], | ||
"prompt_number": 2 | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"The bicycle rear frame is oriented in the Newtonian reference frame by the yaw, roll and pitch angles which are Euler 312 body fixed rotation coordinates." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"collapsed": true, | ||
"input": [ | ||
"yaw, roll, pitch = sym.symbols('yaw roll pitch')" | ||
], | ||
"language": "python", | ||
"metadata": {}, | ||
"outputs": [], | ||
"prompt_number": 3 | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"collapsed": true, | ||
"input": [ | ||
"N = me.ReferenceFrame('N')" | ||
], | ||
"language": "python", | ||
"metadata": {}, | ||
"outputs": [], | ||
"prompt_number": 4 | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"collapsed": true, | ||
"input": [ | ||
"rearFrame = N.orientnew('C', 'Body', [yaw, roll, pitch], '312')" | ||
], | ||
"language": "python", | ||
"metadata": {}, | ||
"outputs": [], | ||
"prompt_number": 5 | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"The VectorNav accelerometer reads out the acceleration in the three rear frame body fixed coordinates and give the measure numbers of the gravity vector.\n", | ||
"$$\\bar{g} = c_x\\hat{c}_x + c_y\\hat{c}_y + c_z\\hat{c}_z$$" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"collapsed": true, | ||
"input": [ | ||
"cx, cy, cz = sym.symbols('cx cy cz')" | ||
], | ||
"language": "python", | ||
"metadata": {}, | ||
"outputs": [], | ||
"prompt_number": 6 | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"collapsed": true, | ||
"input": [ | ||
"gravity = cx * rearFrame.x + cy * rearFrame.y + cz * rearFrame.z" | ||
], | ||
"language": "python", | ||
"metadata": {}, | ||
"outputs": [], | ||
"prompt_number": 7 | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"The gravity vector must equal $|\\bar{g}|\\hat{n}_z$ because it is always in the direction of the gravitational field. This means the measure numbers of $|\\bar{g}|\\hat{n}_z$ in the rear frame must equal the accelerometer readings." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"collapsed": true, | ||
"input": [ | ||
"eqx = me.dot(gravity.magnitude() * N.z, rearFrame.x) - cx" | ||
], | ||
"language": "python", | ||
"metadata": {}, | ||
"outputs": [], | ||
"prompt_number": 8 | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"collapsed": true, | ||
"input": [ | ||
"eqy = me.dot(gravity.magnitude() * N.z, rearFrame.y) - cy" | ||
], | ||
"language": "python", | ||
"metadata": {}, | ||
"outputs": [], | ||
"prompt_number": 9 | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"collapsed": true, | ||
"input": [ | ||
"eqz = me.dot(gravity.magnitude() * N.z, rearFrame.z) - cz" | ||
], | ||
"language": "python", | ||
"metadata": {}, | ||
"outputs": [], | ||
"prompt_number": 10 | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"collapsed": false, | ||
"input": [ | ||
"sym.solve(eqy, roll)" | ||
], | ||
"language": "python", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"output_type": "pyout", | ||
"prompt_number": 11, | ||
"text": [ | ||
"[asin(cy/sqrt(cx**2 + cy**2 + cz**2))]" | ||
] | ||
} | ||
], | ||
"prompt_number": 11 | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"collapsed": false, | ||
"input": [ | ||
"\n", | ||
"sym.solve(eqx, pitch)" | ||
], | ||
"language": "python", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"output_type": "pyout", | ||
"prompt_number": 12, | ||
"text": [ | ||
"[-asin(cx/(sqrt(cx**2 + cy**2 + cz**2)*cos(roll)))]" | ||
] | ||
} | ||
], | ||
"prompt_number": 12 | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"collapsed": true, | ||
"input": [], | ||
"language": "python", | ||
"metadata": {}, | ||
"outputs": [], | ||
"prompt_number": 12 | ||
} | ||
], | ||
"metadata": {} | ||
} | ||
] | ||
} |