Example #1
0
    def run(self, **kwargs):
        """
        Function to run the entire interface.
        Checks the desired setup and runs the correct function for the Fake/Real Robot
        """

        if self.setup == 'Testing':
            latest, output_directory = get_latest_file('Interface', test=False)
            filename = kwargs.get('filename', latest)
            self.__run_test(filename, output_directory)
        else:
            t = kwargs.get('t', 1000.0)
            self.__run_real(t, self.period)
Example #2
0
 def run(self, **kwargs):
     """
     Either kicks off testing from old data or collects off collection of data
     Args:
         t (optional for real mode): Maximum length of time the interface should run for (seconds)
         period (optional for real mode): Sampling period (seconds)
     """
     if self.setup == 'Testing':
         latest, output_directory = get_latest_file('Code', test=False)
         filename = kwargs.get('filename', latest)
         self.__run_test(filename, output_directory)
     else:
         t = kwargs.get('t', 1000.0)
         self.__run_real(t, self.period)
from graph_functions import *
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
import numpy as np
from sys import path

path.insert(0, '..')
from utility_functions import read_file, get_latest_file

# access latest file if underneath file name is blanked out
filename, output_data_directory = get_latest_file('Analysis')
angles = read_file(output_data_directory + filename)

t = angles['time']
be = angles['be']
algo = angles['algo']

fig, ax = plt.subplots(1, 1, figsize=(12, 8))
ax = format_graph(ax)

plt.sca(ax)
algorithm_change_indexes = shade_background_based_on_algorithm(t, algo)
plt.plot(t, be, label='Big Encoder Value')

# [-1] will be final finishing change if it interface finishes in line with algorithm, so [-2] will be when increasing
# algorithm starts
max_times, max_angles = times_and_values_maxima(
    t, be, start_time=t[algorithm_change_indexes[-2]])
pos_angles_indexes = np.where(max_angles > 0)
max_times = max_times[pos_angles_indexes]
max_angles = max_angles[pos_angles_indexes]