<jupyter_start><jupyter_text>Gyroscope Data RunThis is a Jupyter notebook. It provides an environmment for creating programming notebooks that allow a mix of text, code, and output among other things. setup to rerunTo be able to rerun the following, you will need some software on your machine.For Windows users, install python3. Ensure that you select the option to add it to your path.Open a command prompt or terminal and run the following:```pip3 install virtualenvvirtualenv venv```For Windows users run:```venv\Scripts\activate```For macOS or Linux run:```source venv/bin/activate```For either, run the following:```pip3 install -r requirements.txtjupyter notebook```Open "Gyro Ab=nalysis.ipynb" from the the newly opened webpage.Select "kernel" from the top followed by "Restart & run all". If you see the plots regenerated and no red output everything was successful.To fully reproduce this analysis, you would have to convert the original output file to a csv. The way this was originally done is sufficiently complex that it will be left out. If attempting to redi this, it is encouraged to try a reproducable method. AnalysisOn 7/31/17, we ran a P-Controller robot based on the gyroscope data. We had two encoders (different models) running as well, so I decided to look at the data.The run was roughly one second.First thing to do is set up our environment<jupyter_code># allows graphs to render in page
%matplotlib inline
import pandas as pd # data analysus library<jupyter_output><empty_output><jupyter_text>I mangled together the data in the word doc into a csv. I don't want to go into detail, but I will likely have us try better methods of recording data in the future,Changes were not made to the file, except the minimal to make it a csv.<jupyter_code>data = pd.read_csv('data.csv')
data[:3] # first 3 rows<jupyter_output><empty_output><jupyter_text>The above has a few weird features.The time doesn't look useful. This is what is known as unix time, the number of milliseconds since January 1, 1970.There is a column that I labeled ignore. There were two gyroscope readings. The second one was deemed more useful.The encoders are going in opposite directions. It is easier to consider forwards to be positive.Here we will manipulate the data to make it a bit cleaner. The time is still off by an hour but that is unimportant for our use case.<jupyter_code>del data['ignore']
data.enc2 = -1 * data.enc2
data['time'] = pd.DatetimeIndex(pd.to_datetime(data['time'], unit='ms'))\
                 .tz_localize('UTC' )\
                 .tz_convert('America/New_York')
data.set_index('time', inplace=True)
data[:3]
data['gyro'].plot()<jupyter_output><empty_output><jupyter_text>The above data plot is our gyroscope data, It shows oscillation, but unfortunately it shows an unstable system where error grows over time,Now we need to look into the encoders. Due to the different models, we will need to apply a correction factor, To do so, I have chosen a data point where the wheel turns should be equal (0 angle). I have found a near-zero point and chose to use that,<jupyter_code>data.loc['2017-07-31 21:57:17.303000-04:00']<jupyter_output><empty_output><jupyter_text>Now, let's attempt to use this to create a graph that should be proportional to angle.<jupyter_code>(849 / 2388 *(data.enc2) - (data.enc1)).plot()<jupyter_output><empty_output><jupyter_text>Unfortunately, we had no luck with this,What do we do now?<jupyter_code>encs = data[['enc1', 'enc2']].copy(deep=True)
encs.enc2 = 849 / 2388 * encs.enc2
encs.plot()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07789296721770804, 'fraction_numerical': 0.017932193891846457, 'mean_word_length': 5.0, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '267380', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1076, 'n_tokens_neox': 1008, 'n_words': 478, 'path': 'Gyro Analysis.ipynb', 'repo_name': 'zliebowitz/frc-gyro-encoder-analysis', 'size': '3569'}