Merge branch 'frank-dev2' into develop

This commit is contained in:
Timo Volkmann 2020-12-09 12:32:54 +01:00
commit afa5141af6
10 changed files with 1224 additions and 146 deletions

4
.idea/misc.xml generated
View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectPlainTextFileTypeManager">
<file url="file://$PROJECT_DIR$/gnet/net.go" />
<component name="ProjectRootManager">
<output url="file://$PROJECT_DIR$/out"/>
</component>
</project>

234
.idea/workspace.xml generated Normal file
View File

@ -0,0 +1,234 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="BranchesTreeState">
<expand>
<path>
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="LOCAL_ROOT" type="e8cecc67:BranchNodeDescriptor" />
</path>
<path>
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="LOCAL_ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="GROUP_NODE:sensor" type="e8cecc67:BranchNodeDescriptor" />
</path>
</expand>
<select>
<path>
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="LOCAL_ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="GROUP_NODE:sensor" type="e8cecc67:BranchNodeDescriptor" />
<item name="BRANCH:sensor/relative" type="e8cecc67:BranchNodeDescriptor" />
</path>
</select>
</component>
<component name="ChangeListManager">
<list default="true" id="99c957e4-aa42-481d-843d-3fbc901e0f79" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/static/scripts/map.js" beforeDir="false" afterPath="$PROJECT_DIR$/static/scripts/map.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/static/scripts/websocket.js" beforeDir="false" afterPath="$PROJECT_DIR$/static/scripts/websocket.js" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Go Application" />
<option value="Go File" />
<option value="JavaScript File" />
</list>
</option>
</component>
<component name="GOROOT" url="file://$PROJECT_DIR$/../../../../Go" />
<component name="Git.Settings">
<option name="RECENT_BRANCH_BY_REPOSITORY">
<map>
<entry key="$PROJECT_DIR$" value="master" />
</map>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectId" id="1jq0r5aMzeueG8kqyThltUQyqCa" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="DefaultGoTemplateProperty" value="Go File" />
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" />
<property name="configurable.Global.GOPATH.is.expanded" value="true" />
<property name="configurable.Module.GOPATH.is.expanded" value="true" />
<property name="configurable.Project.GOPATH.is.expanded" value="true" />
<property name="go.import.settings.migrated" value="true" />
<property name="go.sdk.automatically.set" value="true" />
<property name="go.tried.to.enable.integration.vgo.integrator" value="true" />
<property name="last_opened_file_path" value="$USER_HOME$" />
<property name="project.structure.last.edited" value="Project" />
<property name="project.structure.proportion" value="0.0" />
<property name="project.structure.side.proportion" value="0.0" />
<property name="settings.editor.selected.configurable" value="preferences.pluginManager" />
</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/cmd/server" />
<recent name="$PROJECT_DIR$/serial_ubx" />
<recent name="$PROJECT_DIR$" />
<recent name="$PROJECT_DIR$/ublox" />
<recent name="$PROJECT_DIR$/serial" />
</key>
</component>
<component name="RunManager" selected="Go Build.go build git.timovolkmann.de/gyrogpsc/cmd/server">
<configuration default="true" type="ArquillianJUnit" factoryName="" nameIsGenerated="true">
<option name="arquillianRunConfiguration">
<value>
<option name="containerStateName" value="" />
</value>
</option>
<option name="TEST_OBJECT" value="class" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="go build git.timovolkmann.de/gyrogpsc/cmd/serial_only" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
<module name="gyrogpsc" />
<working_directory value="$PROJECT_DIR$" />
<kind value="PACKAGE" />
<filePath value="$PROJECT_DIR$/cmd/serial_only/serial_only.go" />
<package value="git.timovolkmann.de/gyrogpsc/cmd/serial_only" />
<directory value="$PROJECT_DIR$" />
<method v="2" />
</configuration>
<configuration name="go build git.timovolkmann.de/gyrogpsc/cmd/server" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
<module name="gyrogpsc" />
<working_directory value="$PROJECT_DIR$" />
<kind value="PACKAGE" />
<filePath value="$PROJECT_DIR$/cmd/server/server.go" />
<package value="git.timovolkmann.de/gyrogpsc/cmd/server" />
<directory value="$PROJECT_DIR$" />
<method v="2" />
</configuration>
<configuration name="go build git.timovolkmann.de/gyrogpsc/cmd/tcp_only" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
<module name="gyrogpsc" />
<working_directory value="$PROJECT_DIR$" />
<kind value="PACKAGE" />
<filePath value="$PROJECT_DIR$/cmd/tcp_only/tcp_only.go" />
<package value="git.timovolkmann.de/gyrogpsc/cmd/tcp_only" />
<directory value="$PROJECT_DIR$" />
<method v="2" />
</configuration>
<configuration name="go build git.timovolkmann.de/gyrogpsc/serial" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
<module name="gyrogpsc" />
<working_directory value="$PROJECT_DIR$" />
<kind value="PACKAGE" />
<filePath value="$PROJECT_DIR$/serial/serial.go" />
<package value="git.timovolkmann.de/gyrogpsc/serial" />
<directory value="$PROJECT_DIR$" />
<method v="2" />
</configuration>
<configuration name="index.html" type="JavascriptDebugType" temporary="true" nameIsGenerated="true" uri="http://localhost:63342/gyrogpsc/static/index.html" useBuiltInWebServerPort="true">
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Go Build.go build git.timovolkmann.de/gyrogpsc/cmd/server" />
<item itemvalue="Go Build.go build git.timovolkmann.de/gyrogpsc/cmd/tcp_only" />
<item itemvalue="JavaScript Debug.index.html" />
<item itemvalue="Go Build.go build git.timovolkmann.de/gyrogpsc/cmd/serial_only" />
<item itemvalue="Go Build.go build git.timovolkmann.de/gyrogpsc/serial" />
</list>
</recent_temporary>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="99c957e4-aa42-481d-843d-3fbc901e0f79" name="Default Changelist" comment="" />
<created>1604516509922</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1604516509922</updated>
<workItem from="1607463793011" duration="356000" />
<workItem from="1607504119613" duration="3584000" />
</task>
<task id="LOCAL-00001" summary="initial working version">
<created>1604747925521</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1604747925521</updated>
</task>
<task id="LOCAL-00002" summary="added dispatcher.go">
<created>1604747940729</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1604747940729</updated>
</task>
<task id="LOCAL-00003" summary="3d orientation visualization html/css">
<created>1604768327573</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1604768327573</updated>
</task>
<task id="LOCAL-00004" summary="switched to relative sensor data (gyroscope)">
<created>1604777752387</created>
<option name="number" value="00004" />
<option name="presentableId" value="LOCAL-00004" />
<option name="project" value="LOCAL" />
<updated>1604777752387</updated>
</task>
<task id="LOCAL-00005" summary="changed orientation">
<created>1605444355479</created>
<option name="number" value="00005" />
<option name="presentableId" value="LOCAL-00005" />
<option name="project" value="LOCAL" />
<updated>1605444355479</updated>
</task>
<option name="localTasksCounter" value="6" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State>
<option name="FILTERS">
<map>
<entry key="branch">
<value>
<list>
<option value="sensor/relative" />
</list>
</value>
</entry>
</map>
</option>
</State>
</value>
</entry>
</map>
</option>
<option name="oldMeFiltersMigrated" value="true" />
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="initial working version" />
<MESSAGE value="added dispatcher.go" />
<MESSAGE value="3d orientation visualization html/css" />
<MESSAGE value="switched to relative sensor data (gyroscope)" />
<MESSAGE value="changed orientation" />
<option name="LAST_COMMIT_MESSAGE" value="changed orientation" />
</component>
<component name="VgoProject">
<integration-enabled>true</integration-enabled>
</component>
</project>

View File

@ -8,7 +8,7 @@ import (
const (
TCP_PORT = ":3010"
HTTP_PORT = ":3011"
SERIAL_PORT = "/dev/tty.usbmodem14201"
SERIAL_PORT = "COM4"
)
func main() {

View File

@ -2,6 +2,7 @@ package main
import (
"git.timovolkmann.de/gyrogpsc/core"
"log"
)
const (
@ -10,9 +11,13 @@ const (
)
func main() {
log.Println("setup dispatcher")
dispatcher := core.NewDispatcher()
processor := core.NewPipeline(dispatcher, 20, 10000)
log.Println("initialize processing pipeline")
processor := core.NewPipeline(dispatcher, 50, 494)
processor.Run()
collectRoutines(processor)
log.Println("start http server")
core.HttpListenAndServe(dispatcher, HTTP_PORT)
}

View File

@ -7,8 +7,6 @@ import (
"log"
"math"
"time"
"github.com/m7shapan/njson"
)
/*{
@ -159,20 +157,20 @@ func convertIPhoneSensorLog(jsonData []byte) (*Sensordata, error) {
func convertAndroidHyperImu(jsonData []byte) (*Sensordata, error) {
prep := struct {
Timestamp int64 `njson:"Timestamp"`
Position [3]float64 `njson:"GPS"`
Orientation [3]float64 `njson:"orientation"`
}{}
err := njson.Unmarshal(jsonData, &prep)
if err != nil {
return nil, err
}
timestamp := gjson.Get(string(jsonData), "Timestamp").Int()
lat := gjson.Get(string(jsonData), "GPS.0").Float()
lon := gjson.Get(string(jsonData), "GPS.1").Float()
alt := gjson.Get(string(jsonData), "GPS.2").Float()
pitch := gjson.Get(string(jsonData), "orientation.0").Float()
roll := gjson.Get(string(jsonData), "orientation.1").Float()
yaw := gjson.Get(string(jsonData), "orientation.2").Float()
sd := &Sensordata{
Timestamp: prep.Timestamp * int64(time.Millisecond),
SourceId: SOURCE_TCP,
Timestamp: timestamp * int64(time.Millisecond),
//Timestamp: time.Unix(0, prep.Timestamp * int64(time.Millisecond)),
Position: prep.Position,
Orientation: prep.Orientation,
Position: [3]float64{lat, lon, alt},
Orientation: [3]float64{pitch, roll, yaw},
}
return sd, nil
}

View File

@ -3,89 +3,14 @@
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.bundle.js"></script>
<script>
const GRAPH_RES = 100;
var dataSmartphone = [];
window.addEventListener("load", function(evt) {
var orientation = [0,0,0];
var multiplier = 180/Math.PI/15
var output = document.getElementById("output");
var input = document.getElementById("input");
var ws;
var print = function(message) {
var d = document.createElement("div");
d.textContent = message;
output.appendChild(d);
};
var print2 = function(message) {
var d = document.createElement("p");
d.innerText = message;
oldNode = output.firstChild
output.replaceChild(d, oldNode)
};
document.getElementById("open").onclick = function(evt) {
if (ws && ws.OPEN) {
print("Websocket already open")
return false;
}
ws = new WebSocket("{{.}}");
ws.onopen = function(evt) {
print("OPEN");
}
ws.onclose = function(evt) {
ws = null;
print2("CLOSE");
}
ws.onmessage = function(evt) {
//print2("RESPONSE: " + evt.data);
dataSmartphone.push(evt.data)
// let dat = JSON.parse(evt.data)["bmi26x gyroscope"]
// let dat = JSON.parse(evt.data)["lsm6dsm gyroscope"]
//let dat = JSON.parse(evt.data)["lsm6ds3c gyroscope"]
let dat = JSON.parse(evt.data)
//console.log(dat)
//console.log(dat.orientation)
document.getElementById("gyroscope").style.transform = `rotateX(${-((dat.orientation[1]+90)%360)}deg) rotateY(${dat.orientation[0]}deg) rotateZ(${-dat.orientation[2]}deg)`
/*
console.log(dat)
orientation[0] += dat[0] * multiplier
orientation[1] += dat[1] * multiplier
orientation[2] += dat[2] * multiplier
// dataset.push(orientation[0])
// while (dataset.length >= 50) {
// dataset.shift();
// }
// addData(orientation[0] / multiplier)
*/
addData(dat.orientation[0])
// addData(dat[0])
//document.getElementById("gyroscope").style.transform = `rotateX(${-orientation[0]}deg) rotateY(${orientation[1]}deg) rotateZ(${-orientation[2]}deg) translateZ(50px)`
}
ws.onerror = function(evt) {
print("ERROR: " + evt.data);
}
return false;
};
document.getElementById("send").onclick = function(evt) {
if (!ws) {
return false;
}
print("SEND: " + input.value);
ws.send(input.value);
return false;
};
document.getElementById("close").onclick = function(evt) {
if (!ws) {
return false;
}
ws.close();
return false;
};
});
</script>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
<script src="https://api.mapbox.com/mapbox-gl-js/v1.12.0/mapbox-gl.js"></script>
<link href="https://api.mapbox.com/mapbox-gl-js/v1.12.0/mapbox-gl.css" rel="stylesheet" />
<style>
body { margin: 0; padding: 0; }
#map { position: absolute; top: 0; bottom: 0; width: 100%; }
</style>
<script src="static/scripts/websocket.js"></script>
<style>
* { box-sizing: border-box; }
@ -162,6 +87,12 @@
<button id="send">Send</button>
</p>
</form>
<div class="scene" style='width: 600px; height: 400px;'>
<div id="map" style='width: 600px; height: 400px;'></div>
</div>
<script src="https://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="static/scripts/map.js"></script>
<div class="scene">
<div id="gyroscope" class="cube">
<div class="cube__face cube__face--front">front</div>
@ -175,51 +106,8 @@
<div style="width: 600px; height: 400px;">
<canvas id="myChart" width="400" height="200"></canvas>
</div>
<script>
var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: new Array(GRAPH_RES),
datasets: [{
label: 'Z',
backgroundColor: 'rgba(255, 99, 132, 0.2)',
borderColor: 'rgba(255, 99, 132, 1)',
borderWidth: 1,
pointRadius: 0,
lineTension: 0.5,
data: new Array(GRAPH_RES)
}]
},
options: {
scales: {
yAxes: [{
ticks: {
// beginAtZero: true
min: -100,
max: 100
}
}]
},
animation: {
duration: 0
}
}
});
myChart.data.labels.fill("", 0, GRAPH_RES);
myChart.data.datasets.forEach((dataset) => dataset.data.fill(0, 0, GRAPH_RES))
function addData(data) {
myChart.data.labels.push("");
myChart.data.datasets.forEach((dataset) => {
dataset.data.push(data);
});
while (myChart.data.labels.length >= GRAPH_RES) {
myChart.data.labels.shift();
myChart.data.datasets.forEach((dataset) => dataset.data.shift())
}
myChart.update();
};
</script>
<script src="static/scripts/chart.js"></script>
</td>
<td valign="top" width="50%">
<div id="output"></div>

43
static/scripts/chart.js Normal file
View File

@ -0,0 +1,43 @@
var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: new Array(GRAPH_RES),
datasets: [{
label: 'Z',
backgroundColor: 'rgba(255, 99, 132, 0.2)',
borderColor: 'rgba(255, 99, 132, 1)',
borderWidth: 1,
pointRadius: 0,
lineTension: 0.5,
data: new Array(GRAPH_RES)
}]
},
options: {
scales: {
yAxes: [{
ticks: {
// beginAtZero: true
min: -100,
max: 100
}
}]
},
animation: {
duration: 0
}
}
});
myChart.data.labels.fill("", 0, GRAPH_RES);
myChart.data.datasets.forEach((dataset) => dataset.data.fill(0, 0, GRAPH_RES))
function addData(data) {
myChart.data.labels.push("");
myChart.data.datasets.forEach((dataset) => {
dataset.data.push(data);
});
while (myChart.data.labels.length >= GRAPH_RES) {
myChart.data.labels.shift();
myChart.data.datasets.forEach((dataset) => dataset.data.shift())
}
myChart.update();
};

View File

@ -0,0 +1,737 @@
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[
9.196275472640991,
49.12280972701122
],
[
9.19629693031311,
49.122757066649065
],
[
9.196267426013947,
49.1227219597099
],
[
9.196237921714783,
49.12268685274588
],
[
9.196205735206604,
49.122642969005895
],
[
9.196168184280396,
49.12259908522708
],
[
9.196090400218964,
49.122556956762885
],
[
9.196015298366547,
49.12252536039125
],
[
9.195816814899445,
49.122421794365344
],
[
9.19578731060028,
49.12246041223081
],
[
9.195752441883085,
49.122495519355134
],
[
9.195720255374908,
49.1225306264546
],
[
9.195685386657715,
49.12257099958827
],
[
9.195658564567566,
49.122602595930815
],
[
9.195634424686432,
49.12263419225324
],
[
9.195604920387268,
49.12266052250654
],
[
9.19557273387909,
49.12268334204809
],
[
9.195548593997955,
49.12271318297122
],
[
9.195532500743866,
49.12273951318259
],
[
9.195497632026672,
49.12276057734161
],
[
9.19557273387909,
49.12281850373281
],
[
9.195524454116821,
49.12285712128936
],
[
9.195497632026672,
49.12287818539843
],
[
9.195476174354553,
49.122904515522194
],
[
9.195586144924162,
49.12300983587742
],
[
9.195840954780579,
49.1232152099268
],
[
9.19605016708374,
49.1233942532759
],
[
9.196152091026306,
49.1235346789797
],
[
9.196280837059021,
49.12368212554077
],
[
9.196393489837646,
49.12382606104651
],
[
9.196511507034302,
49.123924358225025
],
[
9.196581244468689,
49.12404371882266
],
[
9.196720719337463,
49.124173610911306
],
[
9.196838736534119,
49.12435967195905
],
[
9.196951389312744,
49.124501850213676
],
[
9.197013080120087,
49.1245896143649
],
[
9.19705867767334,
49.12465280445759
],
[
9.19714719057083,
49.12476865275172
],
[
9.197292029857635,
49.12495120102961
],
[
9.197361767292023,
49.12506529336202
],
[
9.197455644607544,
49.125175874910624
],
[
9.197522699832916,
49.12529347723932
],
[
9.197605848312378,
49.12543565281655
],
[
9.197745323181152,
49.125690163634275
],
[
9.197841882705688,
49.12584989044582
],
[
9.19790893793106,
49.12598328826778
],
[
9.197978675365448,
49.12612195141281
],
[
9.198064506053925,
49.12627290072483
],
[
9.19819325208664,
49.126525652032335
],
[
9.198254942893982,
49.12668011053043
],
[
9.198305904865265,
49.12679770929164
],
[
9.198405146598816,
49.12695743253551
],
[
9.198488295078278,
49.12716981099699
],
[
9.198619723320007,
49.12720315959838
],
[
9.198799431324005,
49.127229487425765
],
[
9.199027419090271,
49.12716630061657
],
[
9.19931173324585,
49.127129441607394
],
[
9.199504852294922,
49.12708556179883
],
[
9.19965773820877,
49.12704870272959
],
[
9.199883043766022,
49.12700482284956
],
[
9.200116395950317,
49.1269732293119
],
[
9.200357794761658,
49.12690653177737
],
[
9.200548231601715,
49.12688546937944
],
[
9.20065551996231,
49.126911797375485
],
[
9.200770854949951,
49.12695743253551
],
[
9.200899600982666,
49.12702061961085
],
[
9.20103371143341,
49.12706800986451
],
[
9.201240241527557,
49.12711891045688
],
[
9.20141190290451,
49.12714874871086
],
[
9.2015540599823,
49.127191750868846
],
[
9.201587587594986,
49.127187362895256
],
[
9.201736450195312,
49.1271601574503
],
[
9.201810210943222,
49.127157524664504
],
[
9.201871901750565,
49.12715313668789
],
[
9.201933592557907,
49.12710925690026
],
[
9.202055633068085,
49.12697498450896
],
[
9.20224204659462,
49.12691530777389
],
[
9.20237347483635,
49.126887224579605
],
[
9.202480763196945,
49.126842466955814
],
[
9.20254647731781,
49.12681613892294
],
[
9.202671200037003,
49.126769626030736
],
[
9.202869683504105,
49.126692396981234
],
[
9.202970266342163,
49.12665729282806
],
[
9.203054755926132,
49.12662218865002
],
[
9.203156679868698,
49.12659147247387
],
[
9.203227758407593,
49.126569532336404
],
[
9.203289449214935,
49.126551980219446
],
[
9.203341752290726,
49.12653179527724
],
[
9.203158020973206,
49.126483526903876
],
[
9.203088283538818,
49.12646334193381
],
[
9.203002452850342,
49.12644140173965
],
[
9.202857613563538,
49.12640278697433
],
[
9.202712774276733,
49.126357151303814
],
[
9.202632308006287,
49.126325557353475
],
[
9.202412366867065,
49.12626236939239
],
[
9.202256798744202,
49.126213223144774
],
[
9.202122688293455,
49.12616758729978
],
[
9.201961755752563,
49.12612546186714
],
[
9.2018061876297,
49.12607982594142
],
[
9.201698899269104,
49.126037700434225
],
[
9.201596975326538,
49.125999085354515
],
[
9.20129120349884,
49.125883239934964
],
[
9.201119542121887,
49.125827072361396
],
[
9.200921058654785,
49.12578143616102
],
[
9.200685024261473,
49.125676121692166
],
[
9.200513362884521,
49.12560591192202
],
[
9.200336337089539,
49.12554623353922
],
[
9.199842810630798,
49.125360176943595
],
[
9.199681878089905,
49.12527592467067
],
[
9.1995370388031,
49.12522677744532
],
[
9.199456572532654,
49.12518816173411
],
[
9.19932246208191,
49.12513199337321
],
[
9.199220538139343,
49.12508635653314
],
[
9.199113249778748,
49.125023166992925
],
[
9.199016690254211,
49.12496699844514
],
[
9.198925495147705,
49.1248932771296
],
[
9.198732376098633,
49.12480551351584
],
[
9.198582172393799,
49.124721260300475
],
[
9.198474884033203,
49.124647538619605
],
[
9.198367595672607,
49.12459839077146
],
[
9.198265671730042,
49.12455626400573
],
[
9.198126196861267,
49.124542221742516
],
[
9.198099374771118,
49.12450360549822
],
[
9.198126196861267,
49.12441584119478
],
[
9.198174476623533,
49.12433509789843
],
[
9.19828176498413,
49.12430701324279
],
[
9.19831931591034,
49.12427190740087
],
[
9.198254942893982,
49.12420871682283
],
[
9.198115468025208,
49.124149036758475
],
[
9.197981357574463,
49.124085846023824
],
[
9.197836518287659,
49.124026165811614
],
[
9.197707772254944,
49.12395595370529
],
[
9.197557568550108,
49.12386467781845
],
[
9.197487831115723,
49.12381201857656
],
[
9.197385907173157,
49.123717231800214
],
[
9.197214245796204,
49.12367510428589
],
[
9.197010397911072,
49.123566274708274
],
[
9.196908473968506,
49.123474998104186
],
[
9.196704626083374,
49.123401274570526
],
[
9.196602702140808,
49.123348614836544
],
[
9.196484684944153,
49.123260848488954
],
[
9.196339845657349,
49.12319414596088
],
[
9.196216464042664,
49.12313095400942
],
[
9.196135997772217,
49.12306776197748
],
[
9.19607162475586,
49.12299754851418
],
[
9.195937514305115,
49.12295893106699
],
[
9.195835590362549,
49.12289222813283
],
[
9.195733666419983,
49.12282903579667
],
[
9.195638447999954,
49.122754433629495
],
[
9.195600226521492,
49.12273293063105
],
[
9.195574074983597,
49.122708355764296
],
[
9.195574074983597,
49.12269431297779
],
[
9.195623695850372,
49.1226412136555
],
[
9.195666611194609,
49.12260961733753
],
[
9.195688739418983,
49.12258021519025
],
[
9.195733666419983,
49.12253106529318
],
[
9.19575646519661,
49.12250034658276
],
[
9.195783287286758,
49.12247269972715
],
[
9.195801392197609,
49.12244988008865
],
[
9.195815473794937,
49.122438470265486
],
[
9.195830225944519,
49.12242047784666
],
[
9.195859730243683,
49.122431887674
],
[
9.195901304483414,
49.122448563570735
],
[
9.195931479334831,
49.12246787249679
],
[
9.195965006947517,
49.12248367070343
],
[
9.195998534560204,
49.122498152388445
],
[
9.19603407382965,
49.12251307290797
],
[
9.196063578128815,
49.12253501484029
],
[
9.196093752980232,
49.122546424641236
],
[
9.196127280592918,
49.1225600286313
],
[
9.19615812599659,
49.12258109286655
],
[
9.196201711893082,
49.12261927177015
],
[
9.196238592267036,
49.12267237111598
],
[
9.196262061595917,
49.12270045669739
],
[
9.196281507611275,
49.122722837383684
],
[
9.196305647492409,
49.122746534569934
],
[
9.196302965283394,
49.1227693540719
],
[
9.196292236447334,
49.12279392890845
],
[
9.196286201477049,
49.122811482355665
],
[
9.19628955423832,
49.12282815812477
],
[
9.196309000253677,
49.1228479057388
]
]
}
}
]
}

88
static/scripts/map.js Normal file
View File

@ -0,0 +1,88 @@
mapboxgl.accessToken = 'pk.eyJ1IjoiZmhlcmtvbW0iLCJhIjoiY2tobm81bXppMGVuNzMyazY3eDU0M2dyaSJ9.qWJrwtv7KitW60pzs6h3Gg';
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v11',
zoom: 0
});
var emptyTCP = {
type: "FeatureCollection",
features: [
{
type: "Feature",
geometry: {
type: "LineString",
coordinates: []
}
}]
}
var emptySERIAL = {
type: "FeatureCollection",
features: [
{
type: "Feature",
geometry: {
type: "LineString",
coordinates: []
}
}]
}
map.on('load', function () {
// save full coordinate list for later
//var coordinates = data.features[0].geometry.coordinates;
// start by showing just the first coordinate
//data.features[0].geometry.coordinates = [coordinates[0]];
// add it to the map
//map.addSource('trace', { type: 'geojson', data: data });
map.addSource('routeTCP', { 'type': 'geojson', 'data': emptyTCP })
map.addSource('routeSERIAL', { 'type': 'geojson', 'data': emptySERIAL })
map.addLayer({
'id': 'routeTCP',
'type': 'line',
'source': 'routeTCP',
'paint': {
'line-color': 'yellow',
'line-opacity': 0.75,
'line-width': 5
}
});
map.addLayer({
'id': 'routeSERIAL',
'type': 'line',
'source': 'routeSERIAL',
'paint': {
'line-color': 'blue',
'line-opacity': 0.75,
'line-width': 5
}
});
// setup the viewport
map.jumpTo({ 'center': [9.19640999, 49.12283027], 'zoom': 17 });
map.setPitch(30);
// on a regular basis, add more coordinates from the saved list and update the map
//var i = 0;
//var timer = window.setInterval(, 10);
})
function updateMapTCP (long, lat) {
//let coordinates = [long, lat]
emptyTCP.features[0].geometry.coordinates.push([long, lat]);
map.getSource('routeTCP').setData(emptyTCP);
map.panTo([long, lat]);
}
function updateMapSERIAL (long, lat) {
emptySERIAL.features[0].geometry.coordinates.push([long, lat]);
map.getSource('routeSERIAL').setData(emptySERIAL);
//map.panTo([long, lat]);
}

View File

@ -0,0 +1,85 @@
const GRAPH_RES = 100;
var dataSmartphone = [];
window.addEventListener("load", function(evt) {
var orientation = [0,0,0];
var multiplier = 180/Math.PI/15
var output = document.getElementById("output");
var input = document.getElementById("input");
var ws;
var print = function(message) {
var d = document.createElement("div");
d.textContent = message;
output.appendChild(d);
};
var print2 = function(message) {
var d = document.createElement("p");
d.innerText = message;
oldNode = output.firstChild
output.replaceChild(d, oldNode)
};
document.getElementById("open").onclick = function(evt) {
if (ws && ws.OPEN) {
print("Websocket already open")
return false;
}
ws = new WebSocket("ws://localhost:3011/echo");
ws.onopen = function(evt) {
print("OPEN");
}
ws.onclose = function(evt) {
ws = null;
print2("CLOSE");
}
ws.onmessage = function(evt) {
//print2("RESPONSE: " + evt.data);
dataSmartphone.push(evt.data)
// let dat = JSON.parse(evt.data)["bmi26x gyroscope"]
// let dat = JSON.parse(evt.data)["lsm6dsm gyroscope"]
//let dat = JSON.parse(evt.data)["lsm6ds3c gyroscope"]
let dat = JSON.parse(evt.data)
//console.log(evt.data)
console.log("JSON geparsed onmessage", dat)
//console.log(dat.SOURCE_TCP.Orientation)
document.getElementById("gyroscope").style.transform = `rotateX(${-((dat.SOURCE_TCP.Orientation[1]+90)%360)}deg) rotateY(${dat.SOURCE_TCP.Orientation[0]}deg) rotateZ(${-dat.SOURCE_TCP.Orientation[2]}deg)`
/*
console.log(dat)
orientation[0] += dat[0] * multiplier
orientation[1] += dat[1] * multiplier
orientation[2] += dat[2] * multiplier
// dataset.push(orientation[0])
// while (dataset.length >= 50) {
// dataset.shift();
// }
// addData(orientation[0] / multiplier)
*/
addData(dat.SOURCE_TCP.Orientation[0])
updateMapTCP(dat.SOURCE_TCP.Position[1], dat.SOURCE_TCP.Position[0])
updateMapSERIAL(dat.SOURCE_SERIAL.Position[1], dat.SOURCE_SERIAL.Position[0])
//updateMap(dat.SOURCE_SERIAL.Position[1], dat.SOURCE_SERIAL.Position[0])
// addData(dat[0])
//document.getElementById("gyroscope").style.transform = `rotateX(${-orientation[0]}deg) rotateY(${orientation[1]}deg) rotateZ(${-orientation[2]}deg) translateZ(50px)`
}
ws.onerror = function(evt) {
print("ERROR: " + evt.data);
}
return false;
};
document.getElementById("send").onclick = function(evt) {
if (!ws) {
return false;
}
print("SEND: " + input.value);
ws.send(input.value);
return false;
};
document.getElementById("close").onclick = function(evt) {
if (!ws) {
return false;
}
ws.close();
return false;
};
});