예제 #1
0
def stepDetection(dataSet):
	xs = []
	ys = []
	zs = []
	timestamps = []
	headings = []
	for data in dataSet:
		xs.append(data[1])
		ys.append(data[2])
		zs.append(data[3])
		timestamps.append(data[0])
		headings.append(data[4])

	x,y,z,timestamps,headings = np.array(xs), np.array(ys),np.array(zs), np.array(timestamps), np.array(headings)
		
	# Filter Params
	order = 3
	fs = 50.0       # sample rate, Hz
	cutoff = 3.667  # desired cutoff frequency of the filter, Hz
		
	lowPassX = lpf.butter_lowpass_filter(x,cutoff,fs,order)
	peaks,troughs,average, headingMovedX = ajpb.adaptive_jerk_pace_buffer(lowPassX, timestamps, headings)
	
	lowPassY = lpf.butter_lowpass_filter(y,cutoff,fs,order)
	peaks,troughs,average, headingMovedY = ajpb.adaptive_jerk_pace_buffer(lowPassY, timestamps, headings)
	
	lowPassZ = lpf.butter_lowpass_filter(z,cutoff,fs,order)
	peaks,troughs,average, headingMovedZ = ajpb.adaptive_jerk_pace_buffer(lowPassZ, timestamps, headings)
	
	print("X: ",headingMovedX)
	print("Y: ",headingMovedY)
	print("Z: ",headingMovedZ)
	
	return headingMovedY
예제 #2
0
import adaptiveJerkPaceBuffer as ajpb
import lowPassFilter as lpf
import math
import numpy as np
import json

f = open("accel.json", "r")
values = json.load(f)
f.close()

x = []
timestamps = []
for val in values:
	timestamps.append(val[0])
	x.append(val[3])			#Change the axis where values are used

timestamps = np.array(timestamps)
x = np.array(x)

# Filter Params
order = 3
fs = 50.0       # sample rate, Hz
cutoff = 3.667  # desired cutoff frequency of the filter, Hz

lowPassR = lpf.butter_lowpass_filter(x,cutoff,fs,order)

peaks,troughs,average = ajpb.adaptive_jerk_pace_buffer(lowPassR, timestamps)

print("No of steps: %d" %len(troughs))
예제 #3
0
				crossings = pat.peak_accel_threshold(r, timestamps, 10.5)
				# print "Peak Acceleration Threshold Steps:", len(crossings)/2
				pat_sum = pat_sum + len(crossings)/2

				# Peak Jerk Threshold
				jumps, zeroes = sjt.step_jerk_threshold(r, timestamps)
				# print "Step Jerk Threshold Steps:", len(jumps)
				pjt_sum = pjt_sum + len(jumps)

				# Adaptive Step Jerk Threshold
				jumps, avgs = asjt.adaptive_step_jerk_threshold(r, timestamps)
				# print "Adaptive Step Jerk Threshold Steps:", len(jumps)
				# print "Final Step Jerk Average:", avgs[-1][1]
				apjt_sum = apjt_sum + len(jumps)

				peaks, troughs, avgs = ajpb.adaptive_jerk_pace_buffer(r, timestamps)
				# print "Adaptive Step Jerk Pace Buffer Steps:", len(troughs)
				ajpb_sum = ajpb_sum + len(peaks)

				#Android Steps
				a_steps = android_steps(trial)
				# print "Android Steps:", a_steps
				andr_sum = andr_sum + a_steps

				trial_count = trial_count + 1

		print "Peak Acceleration Average:", pat_sum/trial_count, pat_sum, trial_count
		print "Step Jerk Average:", pjt_sum/trial_count, pjt_sum, trial_count
		print "Adaptive Step Jerk Average:",apjt_sum/trial_count, apjt_sum, trial_count 
		print "Adaptive Jerk Pace Buffer Average:",ajpb_sum/trial_count, ajpb_sum, trial_count 
		print "Android Steps:", andr_sum/trial_count, andr_sum, trial_count
예제 #4
0
                crossings = pat.peak_accel_threshold(r, timestamps, 10.5)
                # print "Peak Acceleration Threshold Steps:", len(crossings)/2
                pat_sum = pat_sum + len(crossings) / 2

                # Peak Jerk Threshold
                jumps, zeroes = sjt.step_jerk_threshold(r, timestamps)
                # print "Step Jerk Threshold Steps:", len(jumps)
                pjt_sum = pjt_sum + len(jumps)

                # Adaptive Step Jerk Threshold
                jumps, avgs = asjt.adaptive_step_jerk_threshold(r, timestamps)
                # print "Adaptive Step Jerk Threshold Steps:", len(jumps)
                # print "Final Step Jerk Average:", avgs[-1][1]
                apjt_sum = apjt_sum + len(jumps)

                peaks, troughs, avgs = ajpb.adaptive_jerk_pace_buffer(
                    r, timestamps)
                # print "Adaptive Step Jerk Pace Buffer Steps:", len(troughs)
                ajpb_sum = ajpb_sum + len(peaks)

                #Android Steps
                a_steps = android_steps(trial)
                # print "Android Steps:", a_steps
                andr_sum = andr_sum + a_steps

                trial_count = trial_count + 1

        print "Peak Acceleration Average:", pat_sum / trial_count, pat_sum, trial_count
        print "Step Jerk Average:", pjt_sum / trial_count, pjt_sum, trial_count
        print "Adaptive Step Jerk Average:", apjt_sum / trial_count, apjt_sum, trial_count
        print "Adaptive Jerk Pace Buffer Average:", ajpb_sum / trial_count, ajpb_sum, trial_count
        print "Android Steps:", andr_sum / trial_count, andr_sum, trial_count