-
Notifications
You must be signed in to change notification settings - Fork 111
Accurately reflect PWM output configuration #3507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<template> | ||
<v-card class="ma-2 pa-2"> | ||
<v-card class="ma-2 pa-2" max-width="250px"> | ||
<v-card-title class="align-center"> | ||
Gripper | ||
</v-card-title> | ||
|
@@ -14,15 +14,19 @@ | |
<v-card-text v-else> | ||
{{ toBoardFriendlyChannel(`SERVO${gripper}_FUNCTION`) }} | ||
</v-card-text> | ||
<v-card-text v-if="misconfigured_gripper" class="red--text"> | ||
{{ misconfigured_gripper }} | ||
</v-card-text> | ||
</v-card> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from 'vue' | ||
|
||
import ardupilot_capabilities from '@/store/ardupilot_capabilities' | ||
import autopilot_data from '@/store/autopilot' | ||
import autopilot from '@/store/autopilot_manager' | ||
import { BTN_FUNCTION } from '@/types/autopilot/parameter-sub-enums' | ||
import { BTN_FUNCTION, SERVO_FUNCTION } from '@/types/autopilot/parameter-sub-enums' | ||
|
||
import toBoardFriendlyChannel from './common' | ||
|
||
|
@@ -39,25 +43,95 @@ export default Vue.extend({ | |
|
||
// we cannot directly detect a gripper, so we search for a channel with the min/max momentary actions | ||
// instead | ||
const channel1 = [BTN_FUNCTION.SERVO_1_MIN_MOMENTARY, BTN_FUNCTION.SERVO_1_MAX_MOMENTARY] | ||
const channel2 = [BTN_FUNCTION.SERVO_2_MIN_MOMENTARY, BTN_FUNCTION.SERVO_2_MAX_MOMENTARY] | ||
const channel3 = [BTN_FUNCTION.SERVO_3_MIN_MOMENTARY, BTN_FUNCTION.SERVO_3_MAX_MOMENTARY] | ||
const channel1 = [ | ||
BTN_FUNCTION.SERVO_1_MIN_MOMENTARY, | ||
BTN_FUNCTION.SERVO_1_MAX_MOMENTARY, | ||
BTN_FUNCTION.SERVO_1_MIN_TOGGLE, | ||
BTN_FUNCTION.SERVO_1_MAX_TOGGLE, | ||
BTN_FUNCTION.SERVO_1_MIN, | ||
BTN_FUNCTION.SERVO_1_MAX, | ||
Comment on lines
+47
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Haven't these been renamed now to |
||
] | ||
const channel2 = [ | ||
BTN_FUNCTION.SERVO_2_MIN_MOMENTARY, | ||
BTN_FUNCTION.SERVO_2_MAX_MOMENTARY, | ||
BTN_FUNCTION.SERVO_2_MIN_TOGGLE, | ||
BTN_FUNCTION.SERVO_2_MAX_TOGGLE, | ||
BTN_FUNCTION.SERVO_2_MIN, | ||
BTN_FUNCTION.SERVO_2_MAX, | ||
] | ||
const channel3 = [ | ||
BTN_FUNCTION.SERVO_3_MIN_MOMENTARY, | ||
BTN_FUNCTION.SERVO_3_MAX_MOMENTARY, | ||
BTN_FUNCTION.SERVO_3_MIN_TOGGLE, | ||
BTN_FUNCTION.SERVO_3_MAX_TOGGLE, | ||
BTN_FUNCTION.SERVO_3_MIN, | ||
BTN_FUNCTION.SERVO_3_MAX, | ||
] | ||
const channel4 = [ | ||
BTN_FUNCTION.SERVO_4_MIN_MOMENTARY, | ||
BTN_FUNCTION.SERVO_4_MAX_MOMENTARY, | ||
BTN_FUNCTION.SERVO_4_MIN_TOGGLE, | ||
BTN_FUNCTION.SERVO_4_MAX_TOGGLE, | ||
BTN_FUNCTION.SERVO_4_MIN, | ||
BTN_FUNCTION.SERVO_4_MAX, | ||
] | ||
const channel5 = [ | ||
BTN_FUNCTION.SERVO_5_MIN_MOMENTARY, | ||
BTN_FUNCTION.SERVO_5_MAX_MOMENTARY, | ||
BTN_FUNCTION.SERVO_5_MIN_TOGGLE, | ||
BTN_FUNCTION.SERVO_5_MAX_TOGGLE, | ||
BTN_FUNCTION.SERVO_5_MIN, | ||
BTN_FUNCTION.SERVO_5_MAX, | ||
] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about Actuator 6? |
||
const channels = [channel1, channel2, channel3, channel4, channel5] | ||
for (const param of btn_params) { | ||
if (channel1.includes(param.value)) { | ||
return 9 | ||
} | ||
if (channel2.includes(param.value)) { | ||
return 10 | ||
} | ||
if (channel3.includes(param.value)) { | ||
return 11 | ||
for (const [index, channel] of channels.entries()) { | ||
if (channel.includes(param.value)) { | ||
return index + 1 | ||
} | ||
} | ||
} | ||
return null | ||
}, | ||
boardType() { | ||
return autopilot.current_board?.name | ||
}, | ||
configured_actuators(): number[] { | ||
const actuator_functions = [ | ||
SERVO_FUNCTION.ACTUATOR1, | ||
SERVO_FUNCTION.ACTUATOR2, | ||
SERVO_FUNCTION.ACTUATOR3, | ||
SERVO_FUNCTION.ACTUATOR4, | ||
SERVO_FUNCTION.ACTUATOR5, | ||
SERVO_FUNCTION.ACTUATOR6, | ||
] | ||
return autopilot_data.parameterRegex('^SERVO(\\d+)_FUNCTION$') | ||
.filter((param) => actuator_functions.includes(param.value)) | ||
.map((param) => actuator_functions.indexOf(param.value) + 1) | ||
}, | ||
|
||
misconfigured_gripper(): string | null { | ||
if (this.gripper === 'MAVLink') { | ||
return null | ||
} | ||
if (!ardupilot_capabilities.firmware_supports_actuators) { | ||
if (this.gripper === null) { | ||
return 'No gripper configured.' | ||
} | ||
return null | ||
} | ||
if (this.gripper === null) { | ||
return 'No gripper configured.' | ||
} | ||
if (this.configured_actuators.includes(this.gripper)) { | ||
if (!this.configured_actuators.includes(this.gripper + 1)) { | ||
return `Gripper is configured on Actuator ${this.gripper},` | ||
+ ` but no Output PWM is configured for Actuator ${this.gripper + 1}.` | ||
} | ||
return null | ||
} | ||
return null | ||
}, | ||
}, | ||
methods: { | ||
toBoardFriendlyChannel(servo: string): string { | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,29 @@ | ||||||
import { | ||||||
getModule, | ||||||
Module, VuexModule, | ||||||
} from 'vuex-module-decorators' | ||||||
|
||||||
import store from '@/store' | ||||||
import autopilot_data from "./autopilot" | ||||||
|
||||||
@Module({ | ||||||
dynamic: true, | ||||||
store, | ||||||
name: 'ardupilot_capabilities', | ||||||
}) | ||||||
|
||||||
class ArdupilotCapabilitiesStore extends VuexModule { | ||||||
|
||||||
get firmware_supports_actuators(): boolean { | ||||||
return autopilot_data.parameter('ACTUATOR1_INC') !== undefined | ||||||
} | ||||||
|
||||||
get firmware_supports_light_functions(): boolean { | ||||||
// TODO: light functions were introduced at the same time as actuators | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
return autopilot_data.parameter('ACTUATOR1_INC') !== undefined | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there pre-filtering somewhere, that makes this apply only to ArduSub? |
||||||
} | ||||||
} | ||||||
export { ArdupilotCapabilitiesStore } | ||||||
|
||||||
const ardupilot_capabilities: ArdupilotCapabilitiesStore = getModule(ArdupilotCapabilitiesStore) | ||||||
export default ardupilot_capabilities |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems worth expanding to more general checks of missing outputs corresponding to assigned button functions:
but that's perhaps out of scope for this PR 🤷♂️