This repository was archived by the owner on Sep 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Jarius - telemetry update (4/5/2022) #1
Open
jthomas845
wants to merge
5
commits into
master
Choose a base branch
from
jarius-fix-2020-errors
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
|
|
@@ -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++){ | ||
|
|
@@ -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...'; | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.