Skip to content

Commit 2a2b09b

Browse files
committed
lots of features
1 parent 75719e9 commit 2a2b09b

8 files changed

+62
-78
lines changed

config/sensorConfig.json

+24-24
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
11
{
22
"0" : {
3-
"title": "Left Suspension Angle",
3+
"title": "Left Front Suspension Angle",
44
"description": "Angular data from accelerometer mounted on frame body in X direction.",
5-
"min": -4,
6-
"max": 4
5+
"min": 0,
6+
"max": 100
77
},
88
"1": {
9-
"title": "Left Suspension Angle2",
9+
"title": "Right Front Suspension Angle",
1010
"description": "Angular data from accelerometer mounted on frame body in X direction.",
11-
"min": -4,
12-
"max": 4
11+
"min": 0,
12+
"max": 100
1313
},
1414
"2": {
15-
"title": "Left Suspension Angle3",
15+
"title": "X Acceleration",
1616
"description": "Angular data from accelerometer mounted on frame body in X direction.",
17-
"min": -4,
18-
"max": 4
17+
"min": 0,
18+
"max": 100
1919
},
2020
"3": {
21-
"title": "Left Suspension Angle4",
21+
"title": "Y Acceleration",
2222
"description": "Angular data from accelerometer mounted on frame body in X direction.",
23-
"min": -4,
24-
"max": 4
23+
"min": 0,
24+
"max": 100
2525
},
2626
"4": {
27-
"title": "Left Suspension Angle5",
27+
"title": "RPM",
2828
"description": "Angular data from accelerometer mounted on frame body in X direction.",
29-
"min": -4,
30-
"max": 4
29+
"min": 0,
30+
"max": 100
3131
},
3232
"5": {
33-
"title": "Left Suspension Angle6",
33+
"title": "Rear Right Shock Position",
3434
"description": "Angular data from accelerometer mounted on frame body in X direction.",
35-
"min": -4,
36-
"max": 4
35+
"min": 0,
36+
"max": 100
3737
},
3838
"6": {
39-
"title": "Left Suspension Angle7",
39+
"title": "Rear Left Shock Position",
4040
"description": "Angular data from accelerometer mounted on frame body in X direction.",
41-
"min": -4,
42-
"max": 4
41+
"min": 0,
42+
"max": 100
4343
},
4444
"7": {
45-
"title": "Left Suspension Angle8",
45+
"title": "Fuel Level",
4646
"description": "Angular data from accelerometer mounted on frame body in X direction.",
47-
"min": -4,
48-
"max": 4
47+
"min": 0,
48+
"max": 100
4949
}
5050
}
5151

server/wsServer.js

+6-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app.js

+16-13
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import startRealtimeGathering from './modules/Realtime';
88
import * as MapController from './modules/MapController';
99
import LogRocket from 'logrocket';
1010

11+
const mapData = [{ x: -122.2547275, y: 45.632601 }, { x: -122.2546309, y: 45.6326197 }, { x: -122.254529, y: 45.632631 }, { x: -122.2544324, y: 45.6326685 }, { x: -122.2543198, y: 45.632721 }, { x: -122.2542447, y: 45.632766 }, { x: -122.254132, y: 45.6328335 }, { x: -122.2540569, y: 45.6329085 }, { x: -122.2539604, y: 45.6329948 }, { x: -122.2538692, y: 45.6330773 }, { x: -122.2538263, y: 45.6331486 }, { x: -122.2537673, y: 45.6332499 }, { x: -122.2537136, y: 45.6333437 }, { x: -122.2536707, y: 45.6334449 }, { x: -122.2536707, y: 45.63349 }, { x: -122.2537297, y: 45.6335312 }, { x: -122.2538155, y: 45.6335462 }, { x: -122.2539228, y: 45.63352 }, { x: -122.2540194, y: 45.6334787 }, { x: -122.2541374, y: 45.6334262 }, { x: -122.2542554, y: 45.6333437 }, { x: -122.2543198, y: 45.6332837 }, { x: -122.2544003, y: 45.6332649 }, { x: -122.2544754, y: 45.6332536 }, { x: -122.2545397, y: 45.6332799 }, { x: -122.2545451, y: 45.6333324 }, { x: -122.2545451, y: 45.6334112 }, { x: -122.2545558, y: 45.6334712 }, { x: -122.2545773, y: 45.633535 }, { x: -122.2545612, y: 45.6335987 }, { x: -122.254411, y: 45.6338726 }, { x: -122.2543466, y: 45.6340376 }, { x: -122.2542554, y: 45.6341914 }, { x: -122.2542393, y: 45.6342439 }, { x: -122.2542071, y: 45.6343227 }, { x: -122.254191, y: 45.6343827 }, { x: -122.2541749, y: 45.634454 }, { x: -122.2540891, y: 45.6345965 }, { x: -122.2540194, y: 45.6347353 }, { x: -122.2539872, y: 45.6348216 }, { x: -122.2539765, y: 45.6348853 }, { x: -122.2539604, y: 45.6349566 }, { x: -122.2539443, y: 45.6350354 }, { x: -122.2539282, y: 45.6351441 }, { x: -122.2539282, y: 45.6352379 }, { x: -122.2539604, y: 45.6353767 }, { x: -122.2539818, y: 45.6354667 }, { x: -122.2539979, y: 45.6355718 }, { x: -122.2540247, y: 45.635688 }, { x: -122.2541159, y: 45.635733 }, { x: -122.2542232, y: 45.6357743 }, { x: -122.2543305, y: 45.6357743 }, { x: -122.2543895, y: 45.6357743 }, { x: -122.254529, y: 45.6357818 }, { x: -122.2546685, y: 45.6357893 }, { x: -122.2547758, y: 45.6357893 }, { x: -122.2549635, y: 45.6357968 }, { x: -122.2550333, y: 45.6357968 }, { x: -122.2551191, y: 45.635748 }, { x: -122.2551191, y: 45.6356618 }, { x: -122.2551137, y: 45.6356018 }, { x: -122.2551137, y: 45.635523 }, { x: -122.2551137, y: 45.6354742 }, { x: -122.2551244, y: 45.6354142 }, { x: -122.2551298, y: 45.6353429 }, { x: -122.2551298, y: 45.6352717 }, { x: -122.255103, y: 45.6352754 }, { x: -122.2550654, y: 45.6351967 }, { x: -122.2550923, y: 45.6350766 }, { x: -122.2550601, y: 45.6350204 }, { x: -122.2550493, y: 45.6349941 }, { x: -122.2550333, y: 45.6349453 }, { x: -122.2550118, y: 45.6348816 }, { x: -122.2550064, y: 45.6348178 }, { x: -122.2550011, y: 45.6346603 }, { x: -122.2549957, y: 45.634619 }, { x: -122.2549796, y: 45.6344952 }, { x: -122.2549742, y: 45.6344615 }, { x: -122.2549742, y: 45.6343865 }, { x: -122.2549742, y: 45.6343377 }, { x: -122.2549474, y: 45.6342477 }, { x: -122.2549367, y: 45.6341952 }, { x: -122.2549367, y: 45.6341351 }, { x: -122.2549367, y: 45.6341126 }, { x: -122.254926, y: 45.6340339 }, { x: -122.2549099, y: 45.6340038 }, { x: -122.2548509, y: 45.6339813 }, { x: -122.254824, y: 45.6339963 }, { x: -122.2548187, y: 45.6339888 }, { x: -122.2547597, y: 45.6340526 }, { x: -122.2547114, y: 45.6340789 }, { x: -122.2546685, y: 45.6340864 }, { x: -122.254647, y: 45.6341164 }, { x: -122.2545987, y: 45.6340489 }, { x: -122.2545826, y: 45.6339663 }, { x: -122.254647, y: 45.6338951 }, { x: -122.2546631, y: 45.6338388 }, { x: -122.2547436, y: 45.6337413 }, { x: -122.2547597, y: 45.6337 }, { x: -122.2547704, y: 45.6336438 }, { x: -122.2547919, y: 45.6335725 }, { x: -122.2548079, y: 45.633535 }, { x: -122.254824, y: 45.633505 }, { x: -122.2548616, y: 45.6333324 }, { x: -122.2548723, y: 45.6332574 }, { x: -122.2548831, y: 45.6331861 }, { x: -122.2549635, y: 45.6330923 }, { x: -122.2550011, y: 45.6330773 }, { x: -122.2551566, y: 45.6331561 }, { x: -122.2551996, y: 45.6331749 }, { x: -122.2551996, y: 45.6332799 }, { x: -122.2551888, y: 45.6333324 }, { x: -122.2551888, y: 45.6333999 }, { x: -122.2551781, y: 45.6334712 }, { x: -122.2551727, y: 45.63355 }, { x: -122.2551727, y: 45.6336137 }, { x: -122.2551835, y: 45.6336813 }, { x: -122.2552049, y: 45.633745 }, { x: -122.2552264, y: 45.6338013 }, { x: -122.2553015, y: 45.6338463 }, { x: -122.2552961, y: 45.6339438 }, { x: -122.2553337, y: 45.6340264 }, { x: -122.2553819, y: 45.6341164 }, { x: -122.2554249, y: 45.6342327 }, { x: -122.255457, y: 45.6342927 }, { x: -122.2555482, y: 45.6344052 }, { x: -122.2555643, y: 45.6344352 }, { x: -122.2556394, y: 45.6344915 }, { x: -122.2557145, y: 45.6345778 }, { x: -122.255913, y: 45.634694 }, { x: -122.2559559, y: 45.6348066 }, { x: -122.255972, y: 45.6348516 }, { x: -122.2560042, y: 45.6349979 }, { x: -122.2560042, y: 45.6350466 }, { x: -122.2559935, y: 45.6351179 }, { x: -122.2559774, y: 45.6352192 }, { x: -122.2559667, y: 45.6353467 }, { x: -122.2559613, y: 45.6353992 }, { x: -122.2559667, y: 45.6354555 }, { x: -122.2559667, y: 45.6355117 }, { x: -122.2559613, y: 45.6355868 }, { x: -122.2559667, y: 45.6356768 }, { x: -122.2559935, y: 45.6357068 }, { x: -122.2560686, y: 45.6357405 }, { x: -122.2562778, y: 45.6357443 }, { x: -122.2562885, y: 45.6357424 }, { x: -122.2562993, y: 45.6357405 }, { x: -122.25631, y: 45.6356805 }, { x: -122.2563207, y: 45.6355718 }, { x: -122.2563314, y: 45.6354555 }, { x: -122.2563261, y: 45.6353692 }, { x: -122.2563154, y: 45.6352904 }, { x: -122.2562939, y: 45.6351591 }, { x: -122.2562778, y: 45.6350654 }, { x: -122.2562724, y: 45.6350054 }, { x: -122.2562939, y: 45.6349829 }, { x: -122.2563314, y: 45.6348628 }, { x: -122.256369, y: 45.6347916 }, { x: -122.2563851, y: 45.6347575 }, { x: -122.256428, y: 45.6346978 }, { x: -122.2565407, y: 45.6345778 }, { x: -122.2565567, y: 45.634544 }, { x: -122.2565943, y: 45.6344802 }, { x: -122.2566587, y: 45.6344052 }, { x: -122.2566801, y: 45.6343639 }, { x: -122.2566855, y: 45.6343302 }, { x: -122.2566855, y: 45.6343002 }, { x: -122.2566748, y: 45.6342552 }, { x: -122.2566694, y: 45.6342139 }, { x: -122.2566479, y: 45.6341726 }, { x: -122.2565997, y: 45.6340939 }, { x: -122.256546, y: 45.6340376 }, { x: -122.2564173, y: 45.6339663 }, { x: -122.2562993, y: 45.6339176 }, { x: -122.2562402, y: 45.6339026 }, { x: -122.2560042, y: 45.6338538 }, { x: -122.2559023, y: 45.6338651 }, { x: -122.2558272, y: 45.6338726 }, { x: -122.255677, y: 45.6338801 }, { x: -122.2555804, y: 45.6338801 }, { x: -122.2555482, y: 45.6338538 }, { x: -122.2555321, y: 45.6337788 }, { x: -122.2555268, y: 45.6337263 }, { x: -122.2555643, y: 45.6336663 }, { x: -122.2558379, y: 45.6332686 }, { x: -122.2558755, y: 45.6332011 }, { x: -122.2559237, y: 45.6331449 }, { x: -122.2559613, y: 45.6330886 }, { x: -122.2559988, y: 45.6330061 }, { x: -122.256031, y: 45.632931 }, { x: -122.2560793, y: 45.6327773 }, { x: -122.2561008, y: 45.6326722 }, { x: -122.2559828, y: 45.6325597 }, { x: -122.2559345, y: 45.6325147 }, { x: -122.2558486, y: 45.6323834 }, { x: -122.2558433, y: 45.6322146 }, { x: -122.2558862, y: 45.6321921 }, { x: -122.2559935, y: 45.6321696 }, { x: -122.256133, y: 45.6321321 }, { x: -122.2562349, y: 45.6320946 }, { x: -122.2562885, y: 45.6320308 }, { x: -122.2563207, y: 45.6319895 }, { x: -122.2562832, y: 45.6319708 }, { x: -122.2560954, y: 45.6319858 }, { x: -122.25609, y: 45.6319933 }, { x: -122.2560525, y: 45.632012 }, { x: -122.2560149, y: 45.6320308 }, { x: -122.2559291, y: 45.632057 }, { x: -122.2558379, y: 45.6320758 }, { x: -122.2557896, y: 45.6320758 }, { x: -122.2557467, y: 45.632072 }, { x: -122.2556877, y: 45.6320495 }, { x: -122.2556502, y: 45.6319895 }, { x: -122.255736, y: 45.631832 }, { x: -122.2557843, y: 45.6317907 }, { x: -122.2558218, y: 45.6317307 }, { x: -122.2558326, y: 45.6316744 }, { x: -122.2557467, y: 45.6316294 }, { x: -122.2556823, y: 45.6316257 }, { x: -122.2555214, y: 45.6316782 }, { x: -122.2554463, y: 45.6317607 }, { x: -122.2553712, y: 45.6317982 }, { x: -122.2552532, y: 45.6318732 }, { x: -122.2552156, y: 45.6319182 }, { x: -122.2550762, y: 45.6320608 }, { x: -122.255044, y: 45.6321058 }, { x: -122.2550011, y: 45.6321658 }, { x: -122.2549635, y: 45.6322483 }, { x: -122.2549528, y: 45.6323159 }, { x: -122.2549528, y: 45.6324171 }, { x: -122.2549528, y: 45.6324884 }, { x: -122.2549528, y: 45.6325484 }, { x: -122.2548991, y: 45.6325822 }, { x: -122.254824, y: 45.6326085 }, { x: -122.2548187, y: 45.6326085 }, { x: -122.2547275, y: 45.632601 }];
12+
1113
LogRocket.init('p3pydi/xstream');
1214

1315
const sensorConfig = require('../config/sensorConfig.json');
@@ -156,6 +158,7 @@ const convertSecToTime = (secs) => {
156158
};
157159

158160
let i = 0;
161+
let mapCount = 0;
159162
const simulate = (timestamp) => {
160163
i += 1;
161164
timeDisplay.innerText = convertSecToTime(DataManager.getLiveTime());
@@ -167,16 +170,14 @@ const simulate = (timestamp) => {
167170
const timeArray = DataManager.getRealtimeData()['0'].x;
168171
timeIndex = Simulation.getClosestIndex((timePassedSincePlay / 1000), timeArray) + pausedIndex;
169172
seekerPositionRatio = Math.min(0.99, timeIndex / timeArray.length);
170-
const frontLeftSuspensionAngle = DataManager.getLatestYValue(1);
171-
const frontRightSuspensionAngle = DataManager.getLatestYValue('1');
173+
const frontLeftSuspensionAngle = DataManager.getLatestYValue(0);
174+
const frontRightSuspensionAngle = DataManager.getLatestYValue(1);
172175
seekerPosition = seekerPositionRatio * (overviewWidth - 1);
173176
seekerPosition = 0;
174177
overviewSeeker.style.left = seekerPosition;
175-
if (frontLeftSuspensionAngle === 0) {
176-
Model.animate(Math.sin(i / 5), Math.sin(i / 5));
177-
} else {
178-
Model.animate(frontLeftSuspensionAngle, frontRightSuspensionAngle);
179-
}
178+
179+
Model.animate(frontLeftSuspensionAngle, frontRightSuspensionAngle);
180+
180181
seekerPositionRatio = 0;
181182

182183
DataVisualizer.updatedataVisualizers(startRatio,
@@ -185,13 +186,15 @@ const simulate = (timestamp) => {
185186
DataManager.getRealtimeData(),
186187
DataManager.getDataLength());
187188

188-
drawOverviewCanvasRealtime(DataManager.getRealtimeData());
189+
//drawOverviewCanvasRealtime(DataManager.getRealtimeData());
189190
oldTimestamp = timestamp;
190-
const longitude = -122.255090 + i * 0.0001;
191-
const latitude = 45.632770 + frontRightSuspensionAngle * 0.001;
192191

193-
if (i % 20 === 0) {
194-
MapController.addLineCoordinates(longitude, latitude);
192+
if (i % 10 === 0) {
193+
mapCount += 1;
194+
if (mapCount === mapData.length - 1) {
195+
mapCount = 0;
196+
}
197+
MapController.addLineCoordinates(mapData[mapCount].x, mapData[mapCount].y);
195198
}
196199

197200
requestId = requestAnimationFrame(simulate);
@@ -274,7 +277,7 @@ window.addEventListener('resize', () => {
274277
Model.resizeCanvasToDisplaySize();
275278
setOverviewDimensions();
276279
overviewCanvas.width = overviewCanvas.parentNode.getBoundingClientRect().width * 4;
277-
drawOverviewCanvasRealtime(DataManager.getRealtimeData());
280+
//drawOverviewCanvasRealtime(DataManager.getRealtimeData());
278281
let dataLength;
279282

280283
if (pausedFlag === true) {

src/modules/DataManager.js

-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11

2-
const SAMPLE_PERIOD_SECONDS = 0.01;
32
let allPropertyPoints = {};
43
const sensorConfig = require('../../config/sensorConfig.json');
54

@@ -31,25 +30,6 @@ export const getRealtimeData = () => realtimeData;
3130
export const getLatestYValue = (key) => realtimeData[key].y[realtimeData[key].y.length - 1];
3231

3332

34-
const createFakeRawData = (nonTimeProperties, numDataPoints) => {
35-
const timeArray = [];
36-
const allRawData = {};
37-
const rawData = {};
38-
let k = 1;
39-
const createFakeData = nonTimeProperties.forEach((property) => {
40-
const yValues = [];
41-
for (let i = 0; i < numDataPoints; i += 1) {
42-
timeArray[i] = ((SAMPLE_PERIOD_SECONDS * i));
43-
k = timeArray[i];
44-
yValues[i] = (-0.5 * Math.sin(k * 20)) / Math.exp(k * 4) + 0.005 * Math.sin(i);
45-
}
46-
rawData[property] = yValues;
47-
});
48-
allRawData.yValues = rawData;
49-
allRawData.timeValues = timeArray;
50-
return allRawData;
51-
};
52-
5333
const convertDataToPointPairs = (allRawData) => {
5434
Object.keys(allRawData.yValues).forEach((key) => {
5535
allPropertyPoints[key] = [];

src/modules/DataVisualizer.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,15 @@ export const updatedataVisualizers = (arrayStartRatio, arrayEndRatio, seekerRati
100100

101101
let interval = 1;
102102
if ((end - start) > 8000) {
103-
interval = 20;
103+
interval = 30;
104104
} else if ((end - start) > 4000) {
105-
interval = 10;
105+
interval = 20;
106106
} else if ((end - start) > 2000) {
107-
interval = 4;
107+
interval = 8;
108108
}
109109

110+
// const interval = Math.max(1, Math.round(end - start / 1000));
111+
110112
for (let i = start; i < end; i += interval) {
111113
ctx.lineTo(scaleValues(data[key].x[i],
112114
data[key].x[start],

src/modules/MapController.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,19 @@ mapboxgl.accessToken = 'pk.eyJ1IjoicG9saXNoZHVkZTIwIiwiYSI6ImNrMnRodjhidTBsM2Qzb
66
const map = new mapboxgl.Map({
77
container: 'map', // container id
88
style: 'mapbox://styles/mapbox/streets-v11', // stylesheet location
9-
center: [-122.255090, 45.632770], // starting position [lng, lat]
9+
center: [-122.2547275, 45.632601], // starting position [lng, lat]
1010
pitch: 60, // pitch in degrees
1111
bearing: 0, // bearing in degrees
12-
zoom: 9, // starting zoom
12+
zoom: 16, // starting zoom
1313
});
1414

15-
1615
const geojson = {
1716
type: 'FeatureCollection',
1817
features: [{
1918
type: 'Feature',
2019
geometry: {
2120
type: 'Point',
22-
coordinates: [-122.255090, 45.632770],
21+
coordinates: [-122.2547275, 45.632601],
2322
},
2423
properties: {
2524
title: 'Mapbox',
@@ -30,7 +29,7 @@ const geojson = {
3029
type: 'Feature',
3130
geometry: {
3231
type: 'Point',
33-
coordinates: [-122.255090, 45.632500],
32+
coordinates: [-122.2547275, 45.632601],
3433
},
3534
properties: {
3635
title: 'Mapbox',
@@ -76,9 +75,9 @@ export const addLineCoordinates = ((longitude, latitude) => {
7675
});
7776

7877
map.getSource('line-animation').setData(geojson);
79-
map.flyTo({ center: [longitude, 45.632770] });
8078
});
8179

80+
8281
export const addMarkerToMap = ((longitude, latitude) => {
8382
geojson.features.push(getNewMarker(longitude, latitude));
8483
geojson.features.forEach((marker) => {
@@ -88,7 +87,6 @@ export const addMarkerToMap = ((longitude, latitude) => {
8887
new mapboxgl.Marker(el)
8988
.setLngLat(marker.geometry.coordinates)
9089
.addTo(map);
91-
map.center = [longitude, latitude];
9290
});
9391
});
9492

src/modules/Model.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import * as THREE from 'three';
22
import { OrbitControls } from './OrbitControls';
33
import { STLLoader } from './STLLoader';
44
import FourBar from './vectorFourBar';
5+
import { scaleValues } from './Utils';
6+
57

68
const scene = new THREE.Scene();
79
const camera = new THREE.PerspectiveCamera(75, window.innerWidth
@@ -187,8 +189,8 @@ export const loadAllGeometry = () => {
187189
};
188190

189191
export const animate = (left, right) => {
190-
armTopKnuckleGroupLeft.rotation.x = left * 0.1;
191-
armTopKnuckleGroupRight.rotation.x = right * 0.1;
192+
armTopKnuckleGroupLeft.rotation.x = scaleValues(left, 0, 100, Math.PI/4, -Math.PI/7);
193+
armTopKnuckleGroupRight.rotation.x = scaleValues(right, 0, 100, Math.PI/4, -Math.PI/7);
192194

193195
const angleLeft = ((armTopKnuckleGroupLeft.rotation.x + Math.PI / 2.0)
194196
+ 45.0 * (Math.PI / 180.0));

src/modules/Realtime.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ let realtimeFlag = 0;
88
export const getRealtimeFlag = () => realtimeFlag;
99

1010
const addChangedData = (sensorIndex, timeIndex, data) => {
11-
DataManager.addToRealtimeData(sensorIndex, timeIndex, 3.9 * Math.sin(data * 100));
11+
DataManager.addToRealtimeData(sensorIndex, timeIndex, data);
1212
};
1313

1414
let timeIndex = 0;
@@ -26,12 +26,10 @@ const establishWebsockets = () => {
2626
realtimeFlag = 1;
2727
const message = event.data;
2828
const dataValues = message.split(',');
29-
timeIndex += 0.064;
29+
timeIndex += 1;
3030
dataValues.forEach((value) => {
3131
const cleanValue = parseFloat(value.substring(1));
3232
addChangedData(value[0], timeIndex, cleanValue);
33-
// Work to do. Add fake coordinates data to be piped into datamanager . markers are ready to receive,.
34-
-122.255090, 45.632500
3533
});
3634
};
3735
};

0 commit comments

Comments
 (0)