Factored out state machine from wizard. Added 'wizard.js' for wizard data structure

This commit is contained in:
PAJohnson
2020-09-10 16:28:20 -04:00
parent 11d770aa0c
commit 15b14dbe73
5 changed files with 337 additions and 495 deletions
+294
View File
@@ -0,0 +1,294 @@
import odriveEnums from "../odriveEnums.json";
// wizard is an object of pages.
// each page has a number, title, vue component name, next destination, back destination, and array of choices
export let pages = {
ODrive: {
number: 0,
title: "Which ODrive do you have?",
component: "wizardPage",
next: "Motor_0",
back: "ODrive",
requirements: [],
choices: [
{
imageURL: require("../images/24v_300x300.png"),
text: "ODrive v3.6 24V",
},
{
imageURL: require("../images/56v_300x300.png"),
text: "ODrive v3.6 56V",
},
],
customComponents: [],
},
Motor_0: {
number: 1,
title: "Which motor are you using on Axis 0?",
component: "wizardPage",
next: "Encoder_0",
back: "ODrive",
requirements: [],
choices: [
{
imageURL: require("../images/D5065_300x300.png"),
text: "ODrive D5065",
configStub: {
axis0: {
motor: {
config: {
pole_pairs: 7,
torque_constant: 8.27 / 270,
phase_resistance: 0.039, // from test rig
phase_inductance: 1.57e-5,
motor_type: odriveEnums.MOTOR_TYPE_HIGH_CURRENT, // MOTOR_TYPE_HIGH_CURRENT
},
},
},
},
},
{
imageURL: require("../images/D6374_300x300.png"),
text: "ODrive D6374",
configStub: {
axis0: {
motor: {
config: {
pole_pairs: 7,
torque_constant: 8.27 / 150,
phase_resistance: 0.041, // measurement from PJ
phase_inductance: 2.23e-5,
motor_type: odriveEnums.MOTOR_TYPE_HIGH_CURRENT, // MOTOR_TYPE_HIGH_CURRENT,
},
},
},
},
},
],
customComponents: [
{
component: "wizardMotor",
id: 0,
data: {
axis: "axis0",
}
},
],
},
Encoder_0: {
number: 2,
title: "Which encoder are you using for Axis 0?",
component: "wizardPage",
next: "Misc_0",
back: "Motor_0",
requirements: [],
choices: [
{
imageURL: require("../images/amt102-v_300x300.png"),
text: "CUI AMT102V",
configStub: {
axis0: {
encoder: {
config: {
cpr: 8192,
use_index: true,
mode: odriveEnums.ENCODER_MODE_INCREMENTAL, // ENCODER_MODE_INCREMENTAL
}
}
}
},
},
{
imageURL: require("../images/hall_effect_300x300.png"),
text: "Hall Effect",
configStub: {
axis0: {
encoder: {
config: {
cpr: 8192,
use_index: false,
mode: odriveEnums.ENCODER_MODE_INCREMENTAL, // ENCODER_MODE_INCREMENTAL
}
}
}
},
},
],
customComponents: [
{
component: "wizardEncoderIncremental",
id: 0,
data: {
axis: "axis0",
}
},
{
component: "wizardEncoderIncrementalIndex",
id: 1,
data: {
axis: "axis0",
}
},
],
},
Misc_0: {
number: 3,
title: "Finishing touches for Axis 0",
component: "wizardPage",
next: "Motor_1",
back: "Encoder_0",
requirements: [],
choices: [],
customComponents: [
{
component: "wizardMisc",
id: 0,
data: {
axis: "axis0",
}
},
],
},
Motor_1: {
number: 4,
title: "Which motor are you using for Axis 1?",
component: "wizardPage",
next: "Encoder_1",
back: "Misc_0",
requirements: [],
choices: [
{
imageURL: require("../images/D5065_300x300.png"),
text: "ODrive D5065",
configStub: {
axis1: {
motor: {
config: {
pole_pairs: 7,
torque_constant: 8.27 / 270,
phase_resistance: 0.039, // from test rig
phase_inductance: 1.57e-5,
motor_type: odriveEnums.MOTOR_TYPE_HIGH_CURRENT, // MOTOR_TYPE_HIGH_CURRENT
},
},
},
},
},
{
imageURL: require("../images/D6374_300x300.png"),
text: "ODrive D6374",
configStub: {
axis1: {
motor: {
config: {
pole_pairs: 7,
torque_constant: 8.27 / 150,
phase_resistance: 0.041, // measurement from PJ
phase_inductance: 2.23e-5,
motor_type: odriveEnums.MOTOR_TYPE_HIGH_CURRENT, // MOTOR_TYPE_HIGH_CURRENT,
},
},
},
},
},
],
customComponents: [
{
component: "wizardMotor",
id: 0,
data: {
axis: "axis1",
}
},
],
},
Encoder_1: {
number: 5,
title: "Which encoder are you using for Axis 1?",
component: "wizardPage",
next: "Misc_1",
back: "Motor_1",
requirements: [],
choices: [
{
imageURL: require("../images/amt102-v_300x300.png"),
text: "CUI AMT102V",
configStub: {
axis0: {
encoder: {
config: {
cpr: 8192,
use_index: true,
mode: odriveEnums.ENCODER_MODE_INCREMENTAL, // ENCODER_MODE_INCREMENTAL
}
}
}
},
},
{
imageURL: require("../images/hall_effect_300x300.png"),
text: "Hall Effect",
configStub: {
axis0: {
encoder: {
config: {
cpr: 8192,
use_index: false,
mode: odriveEnums.ENCODER_MODE_INCREMENTAL, // ENCODER_MODE_INCREMENTAL
}
}
}
},
},
],
customComponents: [
{
component: "wizardEncoderIncremental",
id: 0,
data: {
axis: "axis1",
}
},
{
component: "wizardEncoderIncrementalIndex",
id: 1,
data: {
axis: "axis1",
}
},
],
},
Misc_1: {
number: 6,
title: "Finishing touches for Axis 1",
component: "wizardPage",
next: "End",
back: "Encoder_1",
requirements: [],
choices: [],
customComponents: [
{
component: "wizardMisc",
id: 0,
data: {
axis: "axis1",
}
},
],
},
End: {
number: 7,
title: "Review choices",
component: "wizardPage",
next: "End",
back: "Misc_1",
requirements: [],
choices: [],
customComponents: [
{
component: "wizardEnd",
id: 0,
}
]
}
}
+4 -4
View File
@@ -15,7 +15,7 @@
export default {
name: "wizardMisc",
props: {
axis: String,
data: Object
},
data: function () {
return {
@@ -27,7 +27,7 @@ export default {
},
computed: {
velocityLimit: function () {
let keys = ["odrive0", this.axis, "controller", "config", "vel_limit"];
let keys = ["odrive0", this.data.axis, "controller", "config", "vel_limit"];
let odriveObj = this.$store.state.odrives;
for (const key of keys) {
odriveObj = odriveObj[key];
@@ -35,7 +35,7 @@ export default {
return parseFloat(odriveObj["val"]);
},
currentLimit: function () {
let keys = ["odrive0", this.axis, "motor", "config", "current_lim"];
let keys = ["odrive0", this.data.axis, "motor", "config", "current_lim"];
let odriveObj = this.$store.state.odrives;
for (const key of keys) {
odriveObj = odriveObj[key];
@@ -48,7 +48,7 @@ export default {
if ((this.vel_set == true && this.current_set == true)) {
console.log("emitting choice event from limits page");
this.$emit("choice", {
choice: "Limits " + this.axis,
choice: "Limits " + this.data.axis,
config: {
vel_limit: this.vel_limit,
current_lim: this.current_lim,
+6 -6
View File
@@ -28,7 +28,7 @@ import odriveEnums from "../../assets/odriveEnums.json";
export default {
name: "wizardMotor",
props: {
axis: String,
data: Object,
},
data: function () {
return {
@@ -44,7 +44,7 @@ export default {
},
computed: {
resistance: function () {
let keys = ["odrive0", this.axis, "motor", "config", "phase_resistance"];
let keys = ["odrive0", this.data.axis, "motor", "config", "phase_resistance"];
let odriveObj = this.$store.state.odrives;
for (const key of keys) {
odriveObj = odriveObj[key];
@@ -52,7 +52,7 @@ export default {
return parseFloat(odriveObj["val"]).toExponential(3);
},
inductance: function () {
let keys = ["odrive0", this.axis, "motor", "config", "phase_inductance"];
let keys = ["odrive0", this.data.axis, "motor", "config", "phase_inductance"];
let odriveObj = this.$store.state.odrives;
for (const key of keys) {
odriveObj = odriveObj[key];
@@ -63,7 +63,7 @@ export default {
watch: {
resistance: function (newVal) {
console.log("from resistance watcher: " + newVal);
let keys = ["odrive0", this.axis, "motor", "config", "phase_resistance"];
let keys = ["odrive0", this.data.axis, "motor", "config", "phase_resistance"];
let odriveObj = this.$store.state.odrives;
for (const key of keys) {
odriveObj = odriveObj[key];
@@ -72,7 +72,7 @@ export default {
},
inductance: function (newVal) {
console.log("from inductance watcher: " + newVal);
let keys = ["odrive0", this.axis, "motor", "config", "phase_inductance"];
let keys = ["odrive0", this.data.axis, "motor", "config", "phase_inductance"];
let odriveObj = this.$store.state.odrives;
for (const key of keys) {
odriveObj = odriveObj[key];
@@ -131,7 +131,7 @@ export default {
measure() {
// ask ODrive to measure resistance and inductance
var params = new URLSearchParams();
let keys = ["odrive0", this.axis, "requested_state"];
let keys = ["odrive0", this.data.axis, "requested_state"];
for (const key of keys) {
params.append("key", key);
}
+3 -3
View File
@@ -9,13 +9,13 @@
:key="choice.id"
:imageUrl="choice.imageURL"
:text="choice.text"
v-on:click.native="selectedChoice=choice.text;$emit('choice', {title: title, choice: choice.text, config: choice.config})"
v-on:click.native="selectedChoice=choice.text;$emit('choice', {title: title, choice: choice.text, configStub: choice.configStub})"
/>
<template v-for="customComponent in customComponents">
<component
v-bind:class="{chosen: selectedChoice == customComponent.compName, unchosen: selectedChoice != customComponent.compName}"
v-bind:is="customComponent.compName"
v-bind:axis="axis"
v-bind:is="customComponent.component"
v-bind:data="customComponent.data"
v-bind:config="config"
:key="customComponent.id"
v-on:click.native="selectedChoice=customComponent.compName"
+30 -482
View File
File diff suppressed because it is too large Load Diff