I have a project where I have go-karts and I have users. Each user will get a go-kart, but for that I have to put both data sets in a database. The user is already in it, but I can't put the go-karts in because it's a separate file in the public folder.
My folder structure looks like this:
-contollers
-auth.js (Here is the database code for the users)
-node_modules
-public
-img
-style
-js
-gokart.js (I would like to send one or two pieces of this data to the database)
-routes
-auth.js
-pages.js
-views
-gokart.hbs
-register.hbs
-index.hbs
-login.hbs
app.js
The go-kart file looks like this:
var ros = new ROSLIB.Ros({
url:'ws://10.0.2.15:9090'
});
ros.on('connection',function(){
console.log("Connected to websocket server")
});
ros.on('error',function(){
console.log("Error connecting to websocket server: ",error)
});
ros.on('close',function(){
console.log("Connection to websocket server closed.")
});
var gokarts = new ROSLIB.Topic({
ros:ros,
name:"/dwm1001/tag5617",
messageType:"dwm1001/anchor"
});
var myChart;
let canvas = document.getElementById('myChart');
let ctx = canvas.getContext('2d');
function init(){
myChart = new Chart(ctx, {
type: 'scatter',
data: {
datasets: [{
label: 'GOKART moving',
backgroundColor: "blue",
data: [],
}]
},
options: {
responsive: false,
aspectRatio: 1,
maintainAspestRatio: true,
scales: {
xAxes: [{
ticks:{
stepSize:2,
suggestedMax:18,
}
}]
, yAxes: [{
ticks:{
stepSize:2,
suggestedMax:18,
}
}]
}
}
});
}
init();
gokarts.subscribe(function(message) {
myChart.data.datasets[0].data.push({x:message.x.toFixed(2), y:message.y.toFixed(2);
myChart.update();
});
I want to put the gokarts.name and gokart.messageType of the go-kart in a database.(I used mysql)
Thanks for the ideas!