timeDur_s = 10.0 numCycles = 1 freqMinDes_rps = (numCycles/timeDur_s) * hz2rps * np.ones(numChan) #freqMaxDes_rps = (freqRate_hz/2) * hz2rps * np.ones(numChan) freqMaxDes_rps = 10 * hz2rps * np.ones(numChan) freqStepDes_rps = (10 / freqRate_hz) * hz2rps methodSW = 'zip' # "zippered" component distribution ## Generate MultiSine Frequencies freqElem_rps, sigIndx, time_s = GenExcite.MultiSineComponents(freqMinDes_rps, freqMaxDes_rps, freqRate_hz, numCycles, freqStepDes_rps, methodSW) timeDur_s = time_s[-1] - time_s[0] ## Generate Schroeder MultiSine Signal ampElem_nd = np.ones_like(freqElem_rps) ## Approximate relative signal amplitude, create flat sigList, phaseElem_rad, sigElem = GenExcite.MultiSine(freqElem_rps, ampElem_nd, sigIndx, time_s, costType = 'Norm2', phaseInit_rad = 0, boundPhase = 1, initZero = 1, normalize = 'peak'); ## Results peakFactor = GenExcite.PeakFactor(sigList) peakFactorRel = peakFactor / np.sqrt(2) print(peakFactorRel) # Signal Power sigPowerRel = (ampElem_nd / max(ampElem_nd))**2 / len(ampElem_nd) if True: fig, ax = plt.subplots(ncols=1, nrows=numChan, sharex=True) for iChan in range(0, numChan): ax[iChan].plot(time_s, sigList[iChan])
methodSW = 'zip' # "zippered" component distribution # Generate MultiSine Frequencies freqExc_rps, sigIndx, time_s = GenExcite.MultiSineComponents( freqMinDes_rps, freqMaxDes_rps, freqRate_hz, numCycles, freqStepDes_rps, methodSW) freqNull_rps = freqExc_rps[0:-1] + 0.5 * np.diff(freqExc_rps) # Generate Schroeder MultiSine Signal ampExc_nd = np.linspace(ampInit, ampFinal, len(freqExc_rps)) / np.sqrt( len(freqExc_rps)) vExc, _, sigExc = GenExcite.MultiSine(freqExc_rps, ampExc_nd, sigIndx, time_s, phaseInit_rad=0, boundPhase=1, initZero=1, normalize='peak', costType='Schroeder') vExcNames = ['excP', 'excQ', 'excR'] # Excited Frequencies per input channel freqChan_rps = freqExc_rps[sigIndx] # Null Frequencies freqGap_rps = freqExc_rps[0:-1] + 0.5 * np.diff(freqExc_rps) # Reference Inputs ref_names = ['refPhi', 'refTheta', 'refYaw'] sigma = 0.0 * ampInit * deg2rad
freqMaxDes_rps = 15 * hz2rps * np.ones(numChan) freqStepDes_rps = (20 / 50) * hz2rps tBinWidth = FreqTrans.FreqStep2TimeBin(freqStepDes_rps) timeDur_s = binSel * tBinWidth freqMinDes_rps = (1/timeDur_s) * hz2rps * np.ones(numChan) methodSW = 'zip' # "zippered" component distribution ## Generate MultiSine Frequencies freqExc_rps, sigIndx, time_s = GenExcite.MultiSineComponents(freqMinDes_rps, freqMaxDes_rps, freqRate_hz, numCycles, freqStepDes_rps, methodSW) freqGap_rps = freqExc_rps[0:-1] + 0.5 * np.diff(freqExc_rps) ## Generate Schroeder MultiSine Signal ampExc_nd = np.ones_like(freqExc_rps) ## Approximate relative signal amplitude, create flat sigList, phaseElem_rad, sigElem = GenExcite.MultiSine(freqExc_rps, ampExc_nd, sigIndx, time_s, costType = 'Schroeder', phaseInit_rad = 0, boundPhase = True, initZero = True, normalize = 'rms'); sigPeakFactor = GenExcite.PeakFactor(sigList) ampExc_nd *= 0.5 sigList *= 0.5 # Excited Amplitude per input channel ampChan_nd = ampExc_nd[sigIndx] # Excited Frequencies per input channel freqChan_rps = freqExc_rps[sigIndx] freqChan_hz = freqChan_rps * rps2hz #%% Setup Servo Model freqNat_hz = 6.0 freqNat_rps = freqNat_hz * hz2rps