Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def fftfreqcenter2(samples, speed_step, doppler_min_speed):
- speeds = [doppler_min_speed]
- for _ in range(samples):
- speeds.append(speeds[-1] + speed_step)
- return speeds
- function fftfreqcenter(samples, speed_step, doppler_min_speed) {
- var result = [doppler_min_speed];
- for (var i=1; i < samples; i++) {
- result[i] = result[i-1] + speed_step
- }
- return result;
- }
- You receive every 20th frame a state over websocket with following content:
- "state": {"mode": "CW", "sample_rate": 122880, "window_size": 512, "bandwidth": 180000000, "fft": true, "window_function": "hanning", "vco_signal": null, "doppler": {"min_speed": null, "max_speed": null}, "motor": {"start": 0, "stop": 360, "run": false}}}
- Now I see it, min_speed and max_speed should never be null. After fixing my bug they have always a valid value.
- To calculate the speed for the distance axis (X on A, Y on B), you need to know the number of samples, speed_step (in m/s) and doppler_min_speed as offset.
- fftfreqcenter(14, 3.0, 0);
- # Array(14) [ 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, … ]
- This means the first sample is for 0 m/s, second sample 3.0 m/s ...
- After starting the server, it's set automatically to it's maximum range (from negative to 0 to positive).
- ######################OLD########################################
- # I have copied parts from:
- # https://github.com/numpy/numpy/blob/v1.15.0/numpy/fft/helper.py#L124-L169
- #
- # The task was, to have a fftfreqcenter function in JavaScript, which
- # uses instead of a sampling space, a provided value, which can be anything
- # In our case: Distance (FMCW) or Speed (CW)
- def fftfreqcenter(samples, multiplicator):
- NP = (samples-1) // 2 + 1
- NN = -samples // 2
- pos = list(range(0, NP))
- neg = list(range(NN, 0))
- result = neg + pos
- return [r * multiplicator for r in result]
- function fftfreqcenter(samples, multiplicator) {
- var NP = Math.floor((samples - 1) / 2 + 1);
- var NN = Math.floor(-(samples / 2));
- var pos = [];
- var neg = [];
- var idx = 0;
- for (var i=0; i < NP; i++) {
- pos[idx] = i * multiplicator;
- idx++;
- }
- idx = 0;
- for (var i=NN; i < 0; i++) {
- neg[idx] = i * multiplicator;
- idx++;
- }
- return neg.concat(pos);
- }
- // fftfreqcenter(16, 1)
- // [-8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7]
- fftfreqcenter(16, 1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement