Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions public/css/dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ h6 {
.magnitude {
position: relative;
display: inline;
top: -10px;
top: 110px;
left: -17px;
}

Expand Down Expand Up @@ -84,15 +84,17 @@ h6 {
#map-container{
z-index: 0;
position: fixed;
left: 5vw;
top: 2vh;
left: 20vw;
bottom: 2vh;
}

#mapCanvas{
height: 90vh;
width: 90vw;
height: 69vh;
width: 55vw;
position: relative;
overflow: hidden;
/*top: 25vh;
left: 30vh;*/
}

/*#apparentWind{
Expand Down
61 changes: 49 additions & 12 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@

<title>Sailbot Dashboard</title>
<meta name="description" content="Recieves and Displays data from WPI Sailbot">
<meta name="author" content="Sailbot Team 20-21">
<meta name="author" content="Sailbot Team 20-21 & Sailbot Team 21-22">

<link rel="stylesheet" href="css/dashboard.css">
<link rel="stylesheet" href="css/simple-grid.min.css">
<link rel="stylesheet" href="css/foundation.css">
<link rel="shortcut icon" href="/assets/favicon.ico" type="image/x-icon">
<link rel="icon" href="/assets/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="./assets/favicon.ico" type="image/x-icon">
<link rel="icon" href="./assets/favicon.ico" type="image/x-icon">
</head>

<body>
<!-- Dependencies -->
<script type="text/javascript" src="/js/dependencies/socket.io.min.js"></script>
<script type="text/javascript" src="https://maps.google.com/maps/api/js?key=AIzaSyAqEpMAFofxAxfTmpXh_u_vNm0VDSQ-VqE"></script>
<script type="text/javascript" src="/js/dependencies/d3.min.js" charset="utf-8"></script>
<script type="text/javascript" src="/js/dependencies/d3gauge.js" charset="utf-8"></script>
<script type="text/javascript" src="/js/dependencies/FileSaver.min.js" charset="utf-8"></script>
<script type="text/javascript" src="./js/dependencies/socket.io.min.js"></script>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<script type="text/javascript" src="./js/dependencies/socket.io.min.js"></script>
<script type="text/javascript" src="js/dependencies/socket.io.min.js"></script>

<script type="text/javascript" src="https://maps.google.com/maps/api/js?key=AIzaSyANLnjPosvfrcYA9AZRGoknt8qciDAqbz0"></script>
<script type="text/javascript" src="./js/dependencies/d3.min.js" charset="utf-8"></script>
<script type="text/javascript" src="./js/dependencies/d3gauge.js" charset="utf-8"></script>
<script type="text/javascript" src="./js/dependencies/FileSaver.min.js" charset="utf-8"></script>

<!-- Componenents -->
<script type="text/javascript" src="js/pitchrollGen.js"></script>
Expand Down Expand Up @@ -57,7 +57,25 @@ <h4 class="horiList" style="margin-left: 20px;">Grid Corners:</h4>
<div class="grid-container fluid">
<div id="data-display">
<div class="grid-x center">
<div class="cell small-3"></div>
<div class="cell small-2">
<div id="currentHeading" class=" center">
<div class="degree">
<h6 id="currentHeadingAngle" class="font-light">60</h6>
<h6 class="font-light">°</h6>
</div>
<div id="currentHeadingVector" class="vector"></div>
<h6 id="currentHeadingTitle" class="bot-text font-heavy">Current Heading</h6>
</div>
</div>
<div id="intendedHeading" class=" center">
<div class="degree">
<h6 id="intendedHeadingAngle" class="font-light">60</h6>
<h6 class="font-light">°</h6>
</div>
<div id="intendedHeadingVector" class="vector"></div>
<h6 id="intendedHeadingTitle" class="bot-text font-heavy">Intended Heading</h6>
</div>

<div id="coursetrack" class="datum cell small-2">
<div id="coursetrackDisp"></div>
<h6 id="coursetrackTitle" class="font-heavy">Course Track Error</h6>
Expand Down Expand Up @@ -120,13 +138,14 @@ <h6 id="theoreticalWindTitle" class="bot-text font-heavy">True Wind</h6>
<text>Psi:</text>
</div>
<div class="values">
<text id="phi">420.69</text>
<text id="theta">420</text>
<text id="psi">-420.69</text>
<text id="phi">0.1</text>
<text id="theta">0.1</text>
<text id="psi">0.1</text>
</div>
</div>
<h6 id="gyroTitle" class="font-heavy">Rate Gyro</h6>
</div>

</div>

<div class="cell small-4 grid-x">
Expand All @@ -136,6 +155,24 @@ <h6 id="gyroTitle" class="font-heavy">Rate Gyro</h6>
<h6 id="pitchrollTitle" class="font-heavy">Pitch and Roll</h6>
</div>
</div>
<div id="batteryVoltage" class="datum cell small-2 small-offset-8 center">
<div id="batteryVoltageDisp" class="module center" style="
width: 13vw;">
<div class="labels">
<text>Hull Battery:</text>
<text>Bluetooth:</text>
<text>Trim Battery:</text>
</div>
<div class="values">
<text id="hullBatteryState">14.8 V</text>
<text id="btstatus">OK</text>
<text id="trimtab-voltage-percentage">99%</text>

</div>
</div>
<h6 id="gyroTitle" class="font-heavy">Electronics Status: </h6>
</div>
</div>
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions public/js/dependencies/socket.io.min.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions public/js/initGauges.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ const gaugeInit = () => {

groundspeed = new drawGauge({divID: 'speedDisp',
minVal: 0,
maxVal: 25,
maxVal: 10, //25,
needleVal: 0,
tickSpaceMajVal: 5,
tickSpaceMajVal: 1,
gaugeUnits: 'Knots',
...options});

Expand Down
89 changes: 73 additions & 16 deletions public/js/simulator/sim.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
const socket = io(); // socket initialization
//const socket = io("http://localhost:3000/", { transports: ['polling', 'flashsocket'] }); // socket initialization

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep this. This way we won't need to manually change this IP address every time we use a different one.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be re-implemented using localhost

//const socket = io("http://192.168.17.20:3000/", { transports: ['polling', 'flashsocket'] }); // socket initialization
const socket = io("localhost:3000/", { transports: ['polling', 'flashsocket'] }); // socket initialization
console.log("we think weve connected to port 3000")
socket.emit('client');
socket.on('updateDashboard', (data) => {
console.log("we do not care");
});

let counter = 0;
let dataInterval;
Expand Down Expand Up @@ -31,6 +38,31 @@ while (waypoints.length > 0){
console.log(boatWaypoints);
}

function recalculateSimWaypoints()
{
console.log("re-simulating......");
boatWaypoints = [];
let waypoints2 = [
{ x: 3, y: 6, lat: 42.84780, lng: -70.9849 },
{ x: 7, y: 6, lat: 42.84780, lng: -70.9809 },
{ x: 5, y: 4, lat: 42.8499, lng: -70.9829 },
{ x: 0, y: 4, lat: 42.84964938719152, lng: -70.98783200038395 },
];
while (waypoints2.length > 0){
let tempDest = waypoints2.shift();
console.log(boatStart[0], tempDest);
let path = runAstar(boatStart, tempDest).reverse()
waypoints2.length > 1 ? path.pop() : undefined;
boatWaypoints.push(...path);
boatStart = [{ weight: 0, ...tempDest }]; // has to be in an array so it looks like a path
console.log(boatWaypoints);
}
}

function randomizer(multiplier) {
return (Math.random() * multiplier);
}

// getting intermediate points
// let mockCoords = [];
// for (let i = 0; i < boatWaypoints.length - 1; i++){
Expand All @@ -44,25 +76,50 @@ while (waypoints.length > 0){
// }
// console.log(mockCoords);

function dataMaker(){ //the 'simulator'
var rand_ground_speed = randomizer(25);

var data_JSON = {
apparentWind: {speed: 10 + Math.floor(randomizer(50)), direction: Math.floor(randomizer(295))},
trueWind: {speed: 10 + Math.floor(randomizer(50)), direction: Math.floor(randomizer(295))},
intendedHeading: 60 + Math.floor(randomizer(180)),
currentHeading: 20 + Math.floor(randomizer(179)),
magneticSensorHeading: Math.floor(randomizer(360)),
hullVoltage: Math.floor(randomizer(15)),
trimtabVoltage:Math.floor(randomizer(5)),
compass: {x: Math.floor(randomizer(360)), y: Math.floor(randomizer(360)), z: 'garbo'},
//airtemp: Math.floor(Math.random() * 35),
//windchill: Math.floor(Math.random() * 35),
//pressure: 950 + Math.floor(Math.random() * 100),
groundspeed: rand_ground_speed,
Latitude: boatWaypoints[counter].lat,
Longitude: boatWaypoints[counter].lng,
pitchroll: {pitch: 15+Math.floor(randomizer(20)) - 20, roll: Math.floor(Math.random() * 180) - 90},
gyro: {phi: Math.floor(randomizer(100000)/1000), theta: Math.floor(randomizer(100000)/1000), psi: Math.floor(randomizer(100000))/1000}
};

return data_JSON;
}

// sends data every 500ms
const sendMockMessages = () => {
var sendMockMessages = () => {
// timeout variable holds the timeout
dataInterval = setInterval(() => {socket.emit('data', {
apparentWind: {speed: 10 + Math.floor(Math.random() * 50), direction: Math.floor(Math.random() * 295)},
theoreticalWind: {speed: 10 + Math.floor(Math.random() * 50), direction: Math.floor(Math.random() * 295)},
compass: {x: Math.floor(Math.random() * 360), y: Math.floor(Math.random() * 360), z: 'garbo'},
airtemp: Math.floor(Math.random() * 35),
windchill: Math.floor(Math.random() * 35),
pressure: 950 + Math.floor(Math.random() * 100),
groundspeed: Math.floor(Math.random() * 25),
gps: {latitude: boatWaypoints[counter].lat, longitude: boatWaypoints[counter].lng},
pitchroll: {pitch: Math.floor(Math.random() * 20) - 20, roll: Math.floor(Math.random() * 180) - 90},
gyro: {phi: Math.floor(Math.random() * 100000)/1000, theta: Math.floor(Math.random() * 100000)/1000, psi: Math.floor(Math.random() * 100000)/1000}
});



dataInterval = setInterval(() => {
data_JSON = dataMaker();
socket.emit('data', data_JSON);
counter++;
console.log(boatWaypoints[counter].lat +' '+ boatWaypoints[counter].lng);
if (typeof boatWaypoints[counter] === 'undefined') { //re-simulate when data runs out!
recalculateSimWaypoints();
counter = 0;
}
//console.log(boatWaypoints[counter].lat +' '+ boatWaypoints[counter].lng);
console.log('counter: ' + counter + "/" + boatWaypoints.length);
var today = new Date();
var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
console.log(time)
console.log('lat: ' + boatWaypoints[counter].lat + " long: " + boatWaypoints[counter].lng);
}, 1000);

document.querySelector('#message').innerHTML = 'Sending...';
Expand Down
Loading