mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-08-19 02:43:27 +08:00
Server has better exception handling, axis objects actually fetch updated error values instead of cached ones, numeric controls and actions now accept valid math as inputs like '12e-2+4/(2**2)'
This commit is contained in:
+24
-20
@@ -140,22 +140,25 @@ def postVal(odrives, keyList, value, argType):
|
||||
# expect a list of keys in the form of ["key1", "key2", "keyN"]
|
||||
# "key1" will be "odriveN"
|
||||
# like this: postVal(odrives, ["odrive0","axis0","config","calibration_lockin","accel"], 17.0)
|
||||
index = int(''.join([char for char in keyList.pop(0) if char.isnumeric()]))
|
||||
try:
|
||||
index = int(''.join([char for char in keyList.pop(0) if char.isnumeric()]))
|
||||
|
||||
RO = odrives[index]
|
||||
for key in keyList:
|
||||
RO = RO._remote_attributes[key]
|
||||
if argType == "number":
|
||||
RO.set_value(float(value))
|
||||
elif argType == "boolean":
|
||||
RO.set_value(value == "true")
|
||||
else:
|
||||
pass # dont support that type yet
|
||||
RO = odrives[index]
|
||||
for key in keyList:
|
||||
RO = RO._remote_attributes[key]
|
||||
if argType == "number":
|
||||
RO.set_value(float(value))
|
||||
elif argType == "boolean":
|
||||
RO.set_value(value == "true")
|
||||
else:
|
||||
pass # dont support that type yet
|
||||
except:
|
||||
print("exception in postVal")
|
||||
|
||||
def getVal(odrives, keyList):
|
||||
index = int(''.join([char for char in keyList.pop(0) if char.isnumeric()]))
|
||||
RO = odrives[index]
|
||||
try:
|
||||
index = int(''.join([char for char in keyList.pop(0) if char.isnumeric()]))
|
||||
RO = odrives[index]
|
||||
for key in keyList:
|
||||
RO = RO._remote_attributes[key]
|
||||
if isinstance(RO, fibre.remote_object.RemoteObject):
|
||||
@@ -163,6 +166,7 @@ def getVal(odrives, keyList):
|
||||
else:
|
||||
return RO.get_value()
|
||||
except:
|
||||
print("exception in getVal")
|
||||
return 0
|
||||
|
||||
def getSampledData(vars):
|
||||
@@ -176,15 +180,15 @@ def getSampledData(vars):
|
||||
return samples
|
||||
|
||||
def callFunc(odrives, keyList):
|
||||
index = int(''.join([char for char in keyList.pop(0) if char.isnumeric()]))
|
||||
RO = odrives[index]
|
||||
for key in keyList:
|
||||
RO = RO._remote_attributes[key]
|
||||
if isinstance(RO, fibre.remote_object.RemoteFunction):
|
||||
try:
|
||||
try:
|
||||
index = int(''.join([char for char in keyList.pop(0) if char.isnumeric()]))
|
||||
RO = odrives[index]
|
||||
for key in keyList:
|
||||
RO = RO._remote_attributes[key]
|
||||
if isinstance(RO, fibre.remote_object.RemoteFunction):
|
||||
RO.__call__()
|
||||
except:
|
||||
print("fcn call failed")
|
||||
except:
|
||||
print("fcn call failed")
|
||||
|
||||
if __name__ == "__main__":
|
||||
# sleep to allow time for background.js to register event callbacks for stdout,stderr
|
||||
|
||||
+12
-11
@@ -26,7 +26,7 @@
|
||||
<script>
|
||||
import odriveEnums from "../assets/odriveEnums.json";
|
||||
import clearErrors from "./clearErrors.vue";
|
||||
import { getVal } from "../lib/odrive_utils";
|
||||
import { getVal, fetchParam } from "../lib/odrive_utils";
|
||||
|
||||
const axisErrors = {
|
||||
0x00000000: "AXIS_ERROR_NONE",
|
||||
@@ -82,16 +82,13 @@ let encoderErrors = {
|
||||
};
|
||||
|
||||
let controllerErrors = {
|
||||
0x00000000: "ENCODER_ERROR_NONE",
|
||||
0x00000001: "ENCODER_ERROR_UNSTABLE_GAIN",
|
||||
0x00000002: "ENCODER_ERROR_CPR_POLEPAIRS_MISMATCH",
|
||||
0x00000004: "ENCODER_ERROR_NO_RESPONSE",
|
||||
0x00000008: "ENCODER_ERROR_UNSUPPORTED_ENCODER_MODE",
|
||||
0x00000010: "ENCODER_ERROR_ILLEGAL_HALL_STATE",
|
||||
0x00000020: "ENCODER_ERROR_INDEX_NOT_FOUND_YET",
|
||||
0x00000040: "ENCODER_ERROR_ABS_SPI_TIMEOUT",
|
||||
0x00000080: "ENCODER_ERROR_ABS_SPI_COM_FAIL",
|
||||
0x00000100: "ENCODER_ERROR_ABS_SPI_NOT_READY",
|
||||
0x00000000: "CONTROLLER_ERROR_NONE",
|
||||
0x00000001: "CONTROLLER_ERROR_OVERSPEED",
|
||||
0x00000002: "CONTROLLER_ERROR_INVALID_INPUT_MODE",
|
||||
0x00000004: "CONTROLLER_ERROR_UNSTABLE_GAIN",
|
||||
0x00000008: "CONTROLLER_ERROR_INVALID_MIRROR_AXIS",
|
||||
0x00000010: "CONTROLLER_ERROR_INVALID_LOAD_ENCODER",
|
||||
0x00000020: "CONTROLLER_ERROR_INVALID_ESTIMATE",
|
||||
};
|
||||
|
||||
export default {
|
||||
@@ -241,6 +238,10 @@ export default {
|
||||
created() {
|
||||
// set up timeout loop for grabbing axis error values
|
||||
let update = () => {
|
||||
fetchParam(this.axis + ".error");
|
||||
fetchParam(this.axis + '.motor.error');
|
||||
fetchParam(this.axis + '.controller.error');
|
||||
fetchParam(this.axis + '.encoder.error');
|
||||
this.axisErr = getVal(this.axis + '.error');
|
||||
this.motorErr = getVal(this.axis + '.motor.error');
|
||||
this.controllerErr = getVal(this.axis + '.controller.error');
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<button class="close-button" @click=deleteAction>X</button>
|
||||
<span class="ctrlName">{{path}}:</span>
|
||||
<div class="right">
|
||||
<input type="number" v-on:change="newVal" :placeholder="initVal"/>
|
||||
<input v-on:change="newVal" :placeholder="initVal"/>
|
||||
<button class="action-button close-button" @click="putVal">Go</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -32,16 +32,24 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
newVal: function (e) {
|
||||
this.value = parseFloat(e.target.value);
|
||||
// emit a signal - signal needs to float all the way up to Dash
|
||||
// set value of dash.actions.id.val to this.value
|
||||
// this way, action values will be kept when dashes are imported or exported
|
||||
//this.$emit('set-action-val', {id: this.id, val: this.value});
|
||||
let input = e.target.value;
|
||||
let allowedChars = "0123456789eE/*-+.()";
|
||||
let send = true;
|
||||
for (const c of input) {
|
||||
if (!allowedChars.includes(c)) {
|
||||
send = false;
|
||||
}
|
||||
}
|
||||
if (send) {
|
||||
this.value = eval(input);
|
||||
console.log("input = " + input + ", val = " + this.value);
|
||||
}
|
||||
this.$store.commit("setActionVal", {dashID: this.dashID, actionID: this.id, val: this.value});
|
||||
},
|
||||
putVal: function () {
|
||||
let keys = this.path.split(".");
|
||||
keys.shift();
|
||||
console.log('path = ' + keys.join('.') + ", val = " + this.value);
|
||||
putVal(keys.join('.'), this.value);
|
||||
},
|
||||
deleteAction: function() {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<span class="ctrlName">{{name}}:</span>
|
||||
<div class="right">
|
||||
<span class="ctrlVal">{{value}}</span>
|
||||
<input v-if="writeAccess" type="number" v-on:change="putVal" />
|
||||
<input v-if="writeAccess" v-on:change="putVal" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -41,7 +41,17 @@ export default {
|
||||
putVal: function (e) {
|
||||
let keys = this.path.split('.');
|
||||
keys.shift();
|
||||
putVal(keys.join('.'), parseFloat(e.target.value));
|
||||
let input = e.target.value;
|
||||
let allowedChars = "0123456789eE/*-+.()";
|
||||
let send = true;
|
||||
for (const c of input) {
|
||||
if (!allowedChars.includes(c)) {
|
||||
send = false;
|
||||
}
|
||||
}
|
||||
if (send) {
|
||||
putVal(keys.join('.'), eval(input));
|
||||
}
|
||||
},
|
||||
deleteCtrl: function() {
|
||||
// commit a mutation in the store with the relevant information
|
||||
|
||||
@@ -23,6 +23,13 @@ export function getReadonly(path) {
|
||||
return getParam(path + '.readonly');
|
||||
}
|
||||
|
||||
export function fetchParam(path) {
|
||||
socketio.sendEvent({
|
||||
type: "getProperty",
|
||||
data: {path: path},
|
||||
});
|
||||
}
|
||||
|
||||
export function putVal(path, value) {
|
||||
socketio.sendEvent({
|
||||
type: "setProperty",
|
||||
|
||||
Reference in New Issue
Block a user