Skip to content

Instantly share code, notes, and snippets.

View moorepants's full-sized avatar

Jason K. Moore moorepants

View GitHub Profile
>>> R = ReferenceFrame('R')
>>> A = R.orientnew('A', rotation) # rotation is just the args need to set a direction cosine matrix with some method
>>> B = R.orientnew('B', rotation)
# At this point reference frame A know about R, reference frame B knows
# about R, but A and B don't know about each other. But each frame has unit
# vectors available to work with.
>>> v = a * A.x + b * A.y
@moorepants
moorepants / barge.py
Created May 28, 2014 16:53
Notes on a barge model
####Frames
Seabottom = SM.ReferenceFrame('Seabottom')
Barge_Frame = Seabottom.orientnew('Barge_Frame', 'Body', [phi_barge, theta_barge, psi_barge], 'XYZ') #roll, pitch, yaw: phi, theta, psi
"""So in the line above you set the body fixed xyz angles (these
are Euler angles) of the barge, but in the line below you set the angular
velocity vector as Space fixed rotations. Before you set the angular velocity with explicit generalized speeds you should run this:
In [2]: Barge_Frame.ang_vel_in(Seabottom)
Out[2]: (sin(psi_barge)*theta_barge' + cos(psi_barge)*cos(theta_barge)*phi_barge')*Barge_Frame.x + (-sin(psi_barge)*cos(theta_barge)*phi_barge' + cos(psi_barge)*theta_barge')*Barge_Frame.y + (sin(theta_barge)*phi_barge' + psi_barge')*Barge_Frame.z
@moorepants
moorepants / prediction_simulation.py
Created May 29, 2014 00:08
Comparing SISO ARX one step ahead prediction to inf step ahead prediction (simulation). This uses this branch of DTK: https://github.com/moorepants/DynamicistToolKit/tree/system-id
import numpy as np
from scipy.optimize import leastsq
import pandas
import matplotlib.pyplot as plt
from dtk.process import butterworth
from dtk.systemid import ARX
df = pandas.read_csv('RandomSlowSpeed1.txt', delimiter='\t')
sample_rate = 100.0 # hz
cutoff = 6.0 # hz
@moorepants
moorepants / prep_data_for_nick.py
Created June 25, 2014 22:02
Creates a zip file of basic ankle data from 11 subjects.
#!/usr/bin/env python
# standard library
import os
import zipfile
# external
from scipy.io import savemat
# local
@moorepants
moorepants / pendsi.m
Created July 24, 2014 18:43
Parameter ID for a simple pendulum using direct collocation.
function pendsi;
% System identification on a simple pendulum system
% The problem was described and solved by shooting in Vyasarayani et al., Multibody Syst Dyn (2011) 26:411–424
% Here we use Direct Collocation
global problem
close all
tic
% run a simulation to generate data
@moorepants
moorepants / gist:69cde73989dc3a9adaf2
Created August 6, 2014 16:16
latex errors in sympy docs
This file has been truncated, but you can view the full file.
This is XeTeX, Version 3.1415926-2.5-0.9999.3 (TeX Live 2013/Debian) (format=xelatex 2014.8.6) 6 AUG 2014 09:14
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**sympy-0.7.5-git.tex
(./sympy-0.7.5-git.tex
LaTeX2e <2011/06/27>
Babel <3.9h> and hyphenation patterns for 2 languages loaded.
(./sphinxmanual.cls
Document Class: sphinxmanual 2009/06/02 Document class (Sphinx manual)
@moorepants
moorepants / example_results.txt
Last active August 12, 2022 16:54
Figuring out how to do speedy evaluation of lists of SymPy expressions.
Testing results.
Timing the functions.
Timing: cython
cython time: 0.00288254904747 s
Timing: numpy_broadcast
numpy_broadcast time: 0.00597401690483 s
@moorepants
moorepants / environment_info.txt
Last active August 29, 2015 14:06
Demonstration of missing symbols in anaconda's libm library when using the --ffast-math flag.
(inverted-pendulum-id)moorepants@moorepants-2170p:inverted-pendulum-sys-id(master)$ conda info
Current conda install:
platform : linux-64
conda version : 3.6.4
conda-build version : 1.3.3
python version : 2.7.8.final.0
requests version : 2.4.1
root environment : /home/moorepants/anaconda (writable)
default environment : /home/moorepants/anaconda/envs/inverted-pendulum-id
@moorepants
moorepants / specified_acceleration_example.py
Last active August 29, 2015 14:07
A simple example to demonstrate the issues with having specified positions, velocities, and accelerations.
#!/usr/bin/env python
"""This derives the equations of motion for a point mass pendulum on a
laterally moving base, i.e. the classic inverted pendulum on a moving cart.
iy
^ E
| o m
| l / |
| / v g
@moorepants
moorepants / sympy-0.7.6-tests-01
Last active August 29, 2015 14:09
0.7.6 run on ubuntu 14.04
moorepants@moorepants-2170p:sympy(0.7.6)$ bin/test
================================================================ test process starts =================================================================
executable: /home/moorepants/anaconda/bin/python (2.7.8-final-0) [CPython]
architecture: 64-bit
cache: yes
ground types: python
random seed: 57272380
hash randomization: on (PYTHONHASHSEED=362442982)
sympy/assumptions/tests/test_assumptions_2.py[5] ..... [OK]