simple_pendulum.utilities

Utilities

Subpackages

Submodules

simple_pendulum.utilities.parse

Parsing

simple_pendulum.utilities.parse.syntax()

simple_pendulum.utilities.performance_profiler

Performance Profiling

simple_pendulum.utilities.performance_profiler.motor_send_n_commands(numTimes)
simple_pendulum.utilities.performance_profiler.motor_speed_test(motor_id='0x01', can_port='can0', n=1000)
simple_pendulum.utilities.performance_profiler.profiler(data_dict, start, end, meas_dt)

validate avg dt of the control loop with (start time - end time) / numSteps

simple_pendulum.utilities.plot

Plotting

simple_pendulum.utilities.plot.grav_comp(args, output_folder, data_dict)
simple_pendulum.utilities.plot.swingup(save, output_folder, data_dict)
simple_pendulum.utilities.plot.sys_id_comparison(output_folder, meas_time, vel_dict, tau_dict, acc_dict)
simple_pendulum.utilities.plot.sys_id_result(output_folder, t, ref_trq, est_trq)
simple_pendulum.utilities.plot.sys_id_unified(output_folder, meas_time=None, meas_pos=None, meas_vel=None, meas_tau=None, acc=None)

simple_pendulum.utilities.process_data

Data Processing

simple_pendulum.utilities.process_data.cut_trajectory(data_dict, key='meas_time')
simple_pendulum.utilities.process_data.data_dict_from_TXU(T, X, U)
simple_pendulum.utilities.process_data.getEllipseFromCsv(csv_path, index)
simple_pendulum.utilities.process_data.load_trajectory(csv_path)

Load trajectory from csv file. The csv file should have 4 columns with values for [time, position, velocity, torque] respectively. The values shopuld be separated with a comma. Each row in the file is one timestep. The number of rows can vary. The values are assumed to be in SI units, i.e. time in s, position in rad, velocity in rad/s, torque in Nm. The first line in the csv file is reserved for comments and will be skipped during read out.

Example

# des_time, despos, des_vel, des_tau 0.00, 0.00, 0.00, 0.10 0.01, 0.01, 0.01, -0.20 0.02, ….

Parameters:
csv_path: string

path to a csv file containing a trajectory in the below specified format

Returns:
dictdictionary with trajectory data
the dictionary keys are:
  • “des_time”

  • “des_pos”

  • “des_vel”

  • “des_tau”

  • “meas_time”

  • “meas_pos”

  • “meas_vel”

  • “meas_tau”

  • “vel_filt”

If the csv file contains no data for one of the keys they are filled with zeroes.

simple_pendulum.utilities.process_data.prepare_empty_data_dict(dt, tf, n=None)

Prepare empty data/trajectory dictionary. Used in real time experiments.

Parameters:
dtfloat

timestep in [s]

tffloat

final time in [s]

Returns:
dictdata dictionary

all entries are filled with zeros

simple_pendulum.utilities.process_data.saveFunnel(rho, S_t, time, max_dt, N, estMethod='')
simple_pendulum.utilities.process_data.save_trajectory(csv_path, data_dict)

Save trajectory data to csv file.

Parameters:
csv_path: string

path where a csv file containing the trajectory data will be stored

data_dictdict

dictionary containing the trajectory data. expected dictionary keys:

  • “des_time”

  • “des_pos”

  • “des_vel”

  • “des_tau”

  • “meas_time”

  • “meas_pos”

  • “meas_vel”

  • “meas_tau”

  • “vel_filt”

simple_pendulum.utilities.unit_conversion

Units

simple_pendulum.utilities.unit_conversion.deg_to_rad(theta_deg)
simple_pendulum.utilities.unit_conversion.rad_to_deg(theta_rad)