Config dash now changes variable names depending on what the firmware version of the connected ODrive is.

Wizard and Config dashes are now not displayed until an active connection has been established
This commit is contained in:
PAJohnson
2020-09-24 19:56:36 -04:00
parent 12a01a31e3
commit ca567c5d91
4 changed files with 144 additions and 16 deletions
-12
View File
@@ -59,7 +59,6 @@ import Axis from "./components/Axis.vue";
import Wizard from "./views/Wizard.vue"
import * as socketio from "./comms/socketio";
import { saveAs } from "file-saver";
import ConfigDash from "./assets/dashboards/Config.json";
import { v4 as uuidv4 } from "uuid";
//let propSamplePeriod = 100; //sampling period for properties in ms
@@ -135,7 +134,6 @@ export default {
setTimeout(() => {
this.updateOdrives();
}, 1000);
//console.log("updating data...");
},
addDash() {
@@ -231,16 +229,6 @@ export default {
this.$store.dispatch("setServerAddress", "http://127.0.0.1:5000");
// connect to socketio on server for sampled data
this.updateOdrives();
this.dashboards.push(ConfigDash);
// plots will have variables associated, add them to sampled variables list
for (const plot of ConfigDash.plots) {
console.log(plot);
for (const plotVar of plot.vars) {
console.log(plotVar);
//addsampledprop(path);
this.$store.commit("addSampledProperty", plotVar.path);
}
}
},
};
</script>
@@ -0,0 +1,97 @@
{
"name": "Config",
"component": "Dashboard",
"id": "deadb33f",
"controls": [
{
"controlType": "CtrlNumeric",
"path": "odrives.odrive0.axis0.motor.config.current_lim"
},
{
"controlType": "CtrlNumeric",
"path": "odrives.odrive0.axis0.controller.config.vel_limit"
},
{
"controlType": "CtrlNumeric",
"path": "odrives.odrive0.config.brake_resistance"
},
{
"controlType": "CtrlNumeric",
"path": "odrives.odrive0.axis0.motor.config.pole_pairs"
},
{
"controlType": "CtrlNumeric",
"path": "odrives.odrive0.axis0.encoder.config.cpr"
},
{
"controlType": "CtrlSlider",
"path": "odrives.odrive0.axis0.controller.config.pos_gain"
},
{
"controlType": "CtrlSlider",
"path": "odrives.odrive0.axis0.controller.config.vel_gain"
},
{
"controlType": "CtrlSlider",
"path": "odrives.odrive0.axis0.controller.config.vel_integrator_gain"
},
{
"controlType": "CtrlFunction",
"path": "odrives.odrive0.axis0.clear_errors"
},
{
"controlType": "CtrlFunction",
"path": "odrives.odrive0.save_configuration"
}
],
"actions": [
{
"id": "407aea0a-2b16-4d77-8043-2c43b27e4810",
"path": "odrives.odrive0.axis0.requested_state",
"val": 3
},
{
"id": "91b2c1b3-f1bb-4473-9e7a-dd89615cecc9",
"path": "odrives.odrive0.axis0.requested_state",
"val": 8
},
{
"id": "ad0ebe2a-a495-4e33-9cb8-b2ab17dc3a83",
"path": "odrives.odrive0.axis0.controller.input_pos",
"val": 0
},
{
"id": "d7abba09-b0aa-438a-8220-6126e467004e",
"path": "odrives.odrive0.axis0.controller.input_pos",
"val": 50000
}
],
"plots": [
{
"name": "65a2768d-e61e-4dd5-bf80-dba153838f74",
"vars": [
{
"path": "odrives.odrive0.axis0.controller.input_pos",
"color": "#195bd7"
},
{
"path": "odrives.odrive0.axis0.encoder.pos_estimate",
"color": "#d6941a"
}
]
},
{
"name": "d9ee2474-3e53-408f-9eab-1656342eb531",
"vars": [
{
"path": "odrives.odrive0.axis0.controller.vel_setpoint",
"color": "#195bd7"
},
{
"path": "odrives.odrive0.axis0.encoder.vel_estimate",
"color": "#d6941a"
}
]
}
]
}
+47 -4
View File
@@ -1,5 +1,7 @@
import Vue from 'vue';
import Vuex from 'vuex';
import ConfigDashOld from "./assets/dashboards/Config_0_4_12.json";
import ConfigDashNew from "./assets/dashboards/Config_0_5_1.json";
const axios = require('axios');
import * as socketio from "./comms/socketio";
//import { v4 as uuidv4 } from "uuid";
@@ -19,10 +21,6 @@ export default new Vuex.Store({
name: "Start",
component: "Start",
},
{
name: "Wizard",
component: "Wizard",
},
//{ name: "Config", id: uuidv4(), component: "Dashboard", controls: [], actions: [], plots: [] }
],
timeSampleStart: 0,
@@ -31,6 +29,7 @@ export default new Vuex.Store({
newData: false,
sampling: false,
currentDash: "Start",
firstConn: false,
},
// mutations are functions that change the data
mutations: {
@@ -39,6 +38,50 @@ export default new Vuex.Store({
},
setOdrives(state, odrives) {
state.odrives = odrives;
if (state.firstConn == false) {
// first time we're getting odrive data, add correct config page
let ConfigDash;
if (state.odrives.odrive0.fw_version_minor.val == "5") {
ConfigDash = ConfigDashNew;
}
else if (state.odrives.odrive0.fw_version_minor.val == "4") {
ConfigDash = ConfigDashOld;
}
else {
ConfigDash = ConfigDashNew;
}
state.dashboards.push({
name: "Wizard",
component: "Wizard",
});
state.dashboards.push(ConfigDash);
// plots will have variables associated, add them to sampled variables list
for (const plot of ConfigDash.plots) {
console.log(plot);
for (const plotVar of plot.vars) {
console.log(plotVar);
//addsampledprop(path);
let path = plotVar.path;
if (!(path in state.sampledProperties)) {
let newPath = path.split('.');
newPath.splice(0, 1);
state.sampledProperties.push(newPath.join('.'));
state.propSamples[newPath.join('.')] = [];
console.log(state.propSamples);
}
for (const path of state.sampledProperties) {
console.log(path);
}
socketio.sendEvent({
type: 'sampledVarNames',
data: {
paths: state.sampledProperties
}
});
}
}
}
state.firstConn = true;
},
setOdriveConfigs(state, odriveConfigs) {
state.odriveConfigs = odriveConfigs;