├── motor_analysis ├── 350kvTP.PNG ├── 350kvVelli.PNG └── VelliPlot.m ├── numeric_path_opt ├── predictionmatrices.m └── Main.m ├── .gitignore ├── LICENSE ├── various └── path.c └── README.md /motor_analysis/350kvTP.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madcowswe/ODriveTopOld/HEAD/motor_analysis/350kvTP.PNG -------------------------------------------------------------------------------- /motor_analysis/350kvVelli.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madcowswe/ODriveTopOld/HEAD/motor_analysis/350kvVelli.PNG -------------------------------------------------------------------------------- /numeric_path_opt/predictionmatrices.m: -------------------------------------------------------------------------------- 1 | function [Phi, Gamma, Lambda] = predictionmatrices(A, B, C, N) 2 | %UNTITLED2 Summary of this function goes here 3 | % Detailed explanation goes here 4 | 5 | n = size(A,1); 6 | Atilde = [A; zeros((N-1)*n, n)]; 7 | k = [zeros(n, N*n); -kron(eye(N-1), A) zeros((N-1)*n,n)] + eye(N*n); 8 | 9 | Phi = k\Atilde; 10 | Gamma = k\kron(eye(N), B); 11 | Lambda = kron(eye(N), C); 12 | 13 | end 14 | 15 | -------------------------------------------------------------------------------- /numeric_path_opt/Main.m: -------------------------------------------------------------------------------- 1 | %Params 2 | AccelPerA = 3000; 3 | phaseR = 0.033; 4 | Ts = 0.001; 5 | N = 50; 6 | thetaFinal = 200; 7 | x0 = [0;0]; 8 | 9 | %system definition 10 | %X = [theta; omega] 11 | Ac = [0 1; 12 | 0 0]; 13 | Bc = [0; 14 | AccelPerA]; 15 | C = 0; 16 | D = 0; 17 | 18 | SYSC = ss(Ac, Bc, [], []); 19 | SYSD = c2d(SYSC, Ts, 'zoh'); 20 | [Phi, Gamma] = predictionmatrices(SYSD.a, SYSD.b, SYSD.c, N); 21 | 22 | Df = Gamma(end-1:end,:); 23 | ff = [thetaFinal; 0]; 24 | 25 | H = 2*eye(N)*(3/2)*phaseR*Ts; 26 | [u, fval] = quadprog(H,[],[],[],Df,ff); 27 | 28 | xv = reshape(Gamma*u, 2,N)'; 29 | x = xv(:,1); 30 | v = xv(:,2); 31 | 32 | kv350_lambda = 2.2e-3; 33 | power = u.*v.*(3/2)*kv350_lambda; 34 | 35 | Vbus = 24; 36 | Ib = power/Vbus; 37 | Im = u; 38 | duty = Ib./Im; 39 | CapIsqr = (duty.*(Ib-Im)).^2 + ((1-duty).*Ib).^2; 40 | CapIrms = sqrt(sum(CapIsqr)/N); 41 | CapR = 0.08; 42 | Ncaps = 8; 43 | Cappow = (CapIrms/Ncaps)^2 * CapR 44 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | 27 | # PyInstaller 28 | # Usually these files are written by a python script from a template 29 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 30 | *.manifest 31 | *.spec 32 | 33 | # Installer logs 34 | pip-log.txt 35 | pip-delete-this-directory.txt 36 | 37 | # Unit test / coverage reports 38 | htmlcov/ 39 | .tox/ 40 | .coverage 41 | .coverage.* 42 | .cache 43 | nosetests.xml 44 | coverage.xml 45 | *,cover 46 | .hypothesis/ 47 | 48 | # Translations 49 | *.mo 50 | *.pot 51 | 52 | # Django stuff: 53 | *.log 54 | 55 | # Sphinx documentation 56 | docs/_build/ 57 | 58 | # PyBuilder 59 | target/ 60 | 61 | #Ipython Notebook 62 | .ipynb_checkpoints 63 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Oskar Weigl (madcowswe) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /various/path.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | void output(float x, float y, float str, float param) { 6 | printf("{ %05.1ff, %05.1ff, %1.1ff, %06.1ff },\n", (x+1)*75, (y+1)*75, str, param); 7 | } 8 | 9 | void searchat(float x, float y) { 10 | output(x, y, 0.4, 500); 11 | //output(x+0.02, y, 0.4, 1000); 12 | //output(x, y+0.02, 0.4, 1000); 13 | //output(x-0.02, y, 0.4, 1000); 14 | //output(x, y-0.02, 0.4, 1000); 15 | } 16 | 17 | void pickupto(float x, float y) { 18 | output(x, y, 0.4, 0); 19 | //output(x, y, 0.4, 1000); 20 | output(x, y, 0, 1000); 21 | } 22 | 23 | void moveto(float x, float y) { 24 | output(x, y, 0, 0); 25 | } 26 | 27 | #define POINTS 15 28 | #define TWOPI (3.1415*2.0) 29 | 30 | int main(int argc, char** argv) { 31 | moveto(-1,-1); 32 | 33 | for (int j=0; j<2; j++) 34 | for (int i=0; i