Skip to content

Instantly share code, notes, and snippets.

@shauvik
Created October 20, 2016 21:36
Show Gist options
  • Save shauvik/c889dac450c1290537fef02e76a4bba7 to your computer and use it in GitHub Desktop.
Save shauvik/c889dac450c1290537fef02e76a4bba7 to your computer and use it in GitHub Desktop.
Print Autonomous Car Events to console
(function() {
"use strict";
var events = [
"INFO: Car passed on the right",
"INFO: Car passed on the left",
"SIGN: STOP sign ahead",
"SIGN: Signal turned RED",
"SIGN: Signal turned GREEN",
"WARN: Car stopped ahead",
"WARN: Pedestrian crossing ahead",
"INFO: Right turn ahead",
"INFO: Left turn ahead",
"WARN: Speed limit 55mph",
"WARN: Speed limit 20mph"
];
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min;
}
var outputEvent = function () {
// Print event to console
console.log(events[getRandomInt(0, 11)])
setTimeout(outputEvent, getRandomInt(500,5000))
}
setTimeout(outputEvent, getRandomInt(500,5000))
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment