viewof amplitude = Inputs.range([0, 3], {value: 1, step: 0.1, label: "Amplitude"})
viewof frequency = Inputs.range([0, 2], {value: 1, step: 0.1, label: "Frequency"})
viewof phase = Inputs.range([0, 4], {value: 0, step: 0.1, label: "Phase"})
viewof offset = Inputs.range([-1, 1], {value: 0, step: 0.1, label: "Offset"})
viewof noise = Inputs.range([0, 1], {value: 0, step: 0.1, label: "Noise"})
viewof alpha = Inputs.range([0, 1], {value: 0.5, step: 0.01, label: "alpha"})
function sineWave(t, amp, freq, phase, offset, noise) {
return amp * Math.sin(2 * Math.PI * freq * t + phase) + offset + gaussianRandom(0, noise);
}
function generateNoisySineWave(amp, freq, phase, offset, noise) {
const signal = [];
for (let t = 0; t < 4; t += 0.01) {
signal.push({t, value: sineWave(t, amp, freq, phase, offset, noise)});
}
return signal;
}
function ema(signal, alpha) {
let ema = signal[0].value;
return signal.map((d, i) => {
ema = alpha * d.value + (1 - alpha) * ema;
return {t: d.t, value: ema};
});
}
trueSignal = generateNoisySineWave(amplitude, frequency, phase, offset, noise);
smoothSignal = ema(trueSignal, alpha);
Plot.plot({
x: {domain: [0, 4]},
y: {domain: [-5, 5]},
marks: [
Plot.lineY(trueSignal, {x: "t", y: "value", strokeWidth: 8}),
Plot.lineY(smoothSignal, {x: "t", y: "value", stroke: "orange"})
]
})
Sensor Fusion
What you will learn
- How to “fuse” data from multiple sources
Terminology
- sensor fusion
- The process of combining data from multiple sources to improve an estimation
Lecture
Links
Sensor fusion
Interactive
Exponential Moving Average (EMA)
Sensor Fusion
Exercise
Today you will implement sensor fusion.
You will submit your responses on gradescope. Only one partner should submit. The submitter will add the other partner through the gradescope interface.
Additional details for using gradescope can be found here:
You should open the gradescope assignment now so that you know what to work complete.
Grading
I will grade all exercises using a scale of “Nailed It” / “Not Yet”. See the course grading policy for more information, and check gradescope for deadlines.
Overview
This part ot the exercise has two components:
- Use the interactive widget to gain a better understanding of sensor fusion.
- Implement sensor fusion on your robot.
Using the Widget
For each scenario below, please make sure you click the “Restart Simulation” button several times.
- Set the compass weight to
0
and set the left and right wheel noise levels to non-zero values. Report on the effect of the noise on the robot’s trajectory. - Set the compass weight to
1
, set the wheel noise values to0
, and set the compass noise to20
. Report on the effect of the compass noise on the robot’s trajectory. - Set the compass noise to
8
, set the wheel noise values to5
, and adjust the compass weight values up and down. Report on the effect of the compass weight on the robot’s trajectory. - Set the compass noise to
8
, set the wheel noise values to5
, and adjust the compass smoothing values up and down. Report on the effect of the compass smoothing on the robot’s trajectory.
Implementing Sensor Fusion
Finally, you will use your simulation from the previous chapter (and the widget above) to implement sensor fusion on your robot. Specifically, you should use the simulation to guess at good values for the compass weight and the compass smoothing factor (alpha
).
Wrap-Up
Moving forward, we’ll add vision to our robot to improve its ability to react to its environment.