def run_timings_vs_num_landmarks():
    np.random.seed(0)

    options = simulator_options.copy()
    options['num_landmarks'] = 1000

    calibration = structures.Calibration.random()

    trials = []
    true_trajectory, measurements, spline_template, true_frame_timestamps = simulation.simulate_trajectory(
        calibration, **options)
    all_features = measurements.features
    for n in np.linspace(10, 400, 25):
        measurements.features = filter(lambda f: f.track_id < n, all_features)
        try:
            spline_socp.estimate_trajectory(
                calibration,
                measurements,
                spline_template,
                estimator='mixed',
                feature_tolerance=options['feature_noise']*3)
            trials.append((n, socp.timings['last_solve']))
        except spline_socp.InsufficientObservationsError:
            print 'Simulator failed to generate trajectory. Retrying...'

    np.savetxt('results/timings_vs_num_landmarks.txt', trials)
def evaluate(calibration, measurements, spline_template, estimator, tol, true_trajectory):
    estimated_trajectory = spline_socp.estimate_trajectory(
        calibration,
        measurements,
        spline_template,
        estimator=estimator,
        feature_tolerance=tol)
    pos_err = mean_position_error(true_trajectory, estimated_trajectory, measurements.frame_timestamps)
    vel_err = mean_velocity_error(true_trajectory, estimated_trajectory, measurements.frame_timestamps)
    bias_err = accel_bias_error(true_trajectory, estimated_trajectory)
    g_err = gravity_direction_error(true_trajectory, estimated_trajectory)
    return pos_err, vel_err, bias_err, g_err
def run_timings_vs_num_knots():
    np.random.seed(0)

    calibration = structures.Calibration.random()

    trials = []
    true_trajectory, measurements, spline_template, true_frame_timestamps = simulation.simulate_trajectory(
        calibration, **simulator_options)
    for n in np.arange(2, 21):
        spline_template.knots = np.linspace(0, simulator_options['duration'], n)
        try:
            spline_socp.estimate_trajectory(
                calibration,
                measurements,
                spline_template,
                estimator='mixed',
                feature_tolerance=simulator_options['feature_noise']*3)
            trials.append((n, socp.timings['last_solve']))
        except spline_socp.InsufficientObservationsError:
            print 'Simulator failed to generate trajectory. Retrying...'

    np.savetxt('results/timings_vs_num_knots.txt', trials)