import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import scipy.interpolate as si
import math
from IPython.display import HTML
from IPython.display import Image
ee1=pd.read_csv(r'Vid1ee.txt', sep=',')
base1=pd.read_csv(r'Vid1Base.txt', sep=',')
ee2=pd.read_csv(r'Vid2ee.txt', sep=',')
base2=pd.read_csv(r'Vid2Base.txt', sep=',')
ee3=pd.read_csv(r'Vid3ee.txt', sep=',')
base3=pd.read_csv(r'Vid3Base.txt', sep=',')
ee4=pd.read_csv(r'Vid4ee.txt', sep=',')
base4=pd.read_csv(r'Vid4Base.txt', sep=',')
ee5=pd.read_csv(r'Vid5ee.txt', sep=',')
base5=pd.read_csv(r'Vid5Base.txt', sep=',')
ee6=pd.read_csv(r'Vid6ee.txt', sep=',')
base6=pd.read_csv(r'Vid6Base.txt', sep=',')
ee7=pd.read_csv(r'Vid7ee.txt', sep=',')
base7=pd.read_csv(r'Vid7Base.txt', sep=',')
ee8=pd.read_csv(r'Vid8ee.txt', sep=',')
base8=pd.read_csv(r'Vid8Base.txt', sep=',')
#ee9=pd.read_csv(r'E:\OneDrive - Arizona State University\Spring 2021\EGR 557 Foldable Robotics\Data collection\Vid9ee.txt', sep=',')
#base9=pd.read_csv(r'E:\OneDrive - Arizona State University\Spring 2021\EGR 557 Foldable Robotics\Data collection\Vid9Base.txt', sep=',')
def extract_plot(ee,base,amplitude,freq,vshift):
x2 = ee.x.to_numpy()
y2 = ee.y.to_numpy()
t2 = ee.t.to_numpy()
x2b = base.x.to_numpy()
y2b = base.y.to_numpy()
t2b = base.t.to_numpy()
theta = np.r_[0:t2[-1]*1000:1]
out = vshift + amplitude*np.sin(theta*freq)*180/np.pi
xy2 = np.array([x2,y2]).T
xy2b = np.array([x2b,y2b]).T
XYee2 = si.interp1d(t2,xy2.T,fill_value='extrapolate',kind='quadratic')
XYbase2 = si.interp1d(t2,xy2b.T,fill_value='extrapolate',kind='quadratic')
new_t2 = np.r_[0:t2[-1]:.1]
avg2 = np.mean(XYbase2(new_t2)[0])
Xee2 = (XYee2(new_t2)[0]-avg2)*-1
Xbase2 = (XYbase2(new_t2)[0]-avg2)*-1
height = XYbase2(new_t2)[1][-1]- XYbase2(new_t2)[1][0]
Vel = height/new_t2[-1]
fig1, axs = plt.subplots(3,2)
#plt.plot(t,x)
axs[0,0].plot(new_t2,Xee2)
axs[0,1].plot(new_t2,Xbase2)
#plt.plot(t,y)
axs[1,0].plot(new_t2,XYee2(new_t2)[1])
axs[1,1].plot(new_t2,XYbase2(new_t2)[1])
axs[2,0].plot(Xee2,XYee2(new_t2)[1])
axs[2,1].plot(Xbase2,XYbase2(new_t2)[1])
plt.figure()
plt.plot(Xee2,XYee2(new_t2)[1])
plt.plot(Xbase2,XYbase2(new_t2)[1])
plt.figure()
plt.plot(theta/1000,out)
print(height)
print(Vel)
Image(filename='setup1.jpg')
Image(filename='setup2.jpg')
Image(filename='setup3.jpg')
Image(filename='setup4.jpg')
*Note data is mirrored to help better match the dynamic code
amp = np.deg2rad(45)
vshift = 110
freq = 0.005
extract_plot(ee6,base6,amp,freq,vshift)
0.18155234989999983
0.019733951076086935
amp = np.deg2rad(45)
vshift = 110
freq = 0.007
extract_plot(ee3,base3,amp,freq,vshift)
0.15047987119999984
0.012972402689655157
amp = np.deg2rad(45)
vshift = 90
freq=0.007
extract_plot(ee2,base2,amp,freq,vshift)
-0.005773203300000029
-0.0006344179450549483
amp = np.deg2rad(45)
vshift = 100
freq = 0.005
extract_plot(ee4,base4,amp,freq,vshift)
0.0009551232000000187
8.452417699115209e-05
x2 = ee6.x.to_numpy()
y2 = ee6.y.to_numpy()
t2 = ee6.t.to_numpy()
x2b = base6.x.to_numpy()
y2b = base6.y.to_numpy()
t2b = base6.t.to_numpy()
xy2 = np.array([x2,y2]).T
xy2b = np.array([x2b,y2b]).T
XYee2 = si.interp1d(t2,xy2.T,fill_value='extrapolate',kind='quadratic')
XYbase2 = si.interp1d(t2,xy2b.T,fill_value='extrapolate',kind='quadratic')
new_t2 = np.r_[0:t2[-1]:.1]
avg2 = np.mean(XYbase2(new_t2)[0])
Xee2 = (XYee2(new_t2)[0]-avg2)*-1
Xbase2 = (XYbase2(new_t2)[0]-avg2)*-1
height = XYbase2(new_t2)[1][-1]- XYbase2(new_t2)[1][0]
Vel = height/new_t2[-1]
plt.figure()
plt.plot(new_t2,XYbase2(new_t2)[1]*100)
plt.xlim([0,1.3])
plt.ylim([23,30])
(23.0, 30.0)
What was difficult to control?
It was most difficult to control the inversion of the wing. This wing has two degrees of freedom, but we are only actuating one base link. We are relying on the dynamics of the wing including its joint stiffness and damping and the aerodynamic forces to extend and tuck the wing through the stroke. We cannot directly control the geometry of the wing.
How would you improve your testing setup or procedure next time?
To improve the accuracy of the data next time, we would like to use a fixed camera mount with a perfectly perpendicular perspective. Additionally, we would like to use a better mount that connects the wing top the motor to better transmit the torque to the wing.
How well does your data mirror your simulated results? What is similar, what is different?
The data generally matches the simulated result. In the hardware test, the position of the base advances slowly after each flap. The simulation also shows a positive displacement after one full flap. The simulator has slightly greater displacement than the hardware test. The angles achieved by each link throughout the motion are slightly different between the hardware test and the simulation, but overall, the wing is more extended during the downstroke of both and tucked more during the upstroke of both
Is it possible to add a modeling element which models/captures discrepancies between these two results? What element if added to your simulation has the biggest impact on its fidelity?
To capture some of the discrepancies between the simulation and the hardware test, we could model the rolling resistance of the rail, the position control of the servo, and the multiple flaps.