Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions core/frontend/src/components/vehiclesetup/configuration/lights.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@

<script lang="ts">
import mavlink2rest from '@/libs/MAVLink2Rest'
import ardupilot_capabilities from '@/store/ardupilot_capabilities'
import autopilot_data from '@/store/autopilot'
import Parameter, { printParam } from '@/types/autopilot/parameter'
import { SERVO_FUNCTION } from '@/types/autopilot/parameter-sub-enums'

enum Lights {
Lights1 = 59, // RCIN9
Expand All @@ -66,6 +68,9 @@ export default {
}
},
computed: {
supports_light_functions(): boolean {
return ardupilot_capabilities.firmware_supports_light_functions
},
light_steps(): Parameter | undefined {
return autopilot_data.parameter('JS_LIGHTS_STEPS')
},
Expand All @@ -78,6 +83,12 @@ export default {
lights2_param(): Parameter | undefined {
return this.servo_params.filter((param) => param.value === Lights.Lights2)[0]
},
new_lights1_value(): SERVO_FUNCTION {
return this.supports_light_functions ? SERVO_FUNCTION.LIGHTS1 : SERVO_FUNCTION.RCIN9
},
new_lights2_value(): SERVO_FUNCTION {
return this.supports_light_functions ? SERVO_FUNCTION.LIGHTS2 : SERVO_FUNCTION.RCIN10
},
},
watch: {
steps_param(new_value: Parameter | undefined) {
Expand All @@ -99,10 +110,10 @@ export default {
this.lights2_new_param = new_value?.name
},
lights1_new_param(new_param_name: string | undefined) {
this.setLights(new_param_name, Lights.Lights1)
this.setLights(new_param_name, this.new_lights1_value)
},
lights2_new_param(new_param_name: string | undefined) {
this.setLights(new_param_name, Lights.Lights2)
this.setLights(new_param_name, this.new_lights2_value)
},
},
mounted() {
Expand All @@ -111,7 +122,7 @@ export default {
this.steps_new_value = this.light_steps?.value ?? 0
},
methods: {
setLights(new_param_name: string | undefined, lights: Lights) {
setLights(new_param_name: string | undefined, lights: SERVO_FUNCTION) {
if (new_param_name) {
// reset any other parameter using lights1 to undefined
for (const old_param of this.servo_params) {
Expand Down
100 changes: 87 additions & 13 deletions core/frontend/src/components/vehiclesetup/overview/gripper.vue
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>
Expand All @@ -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 }}
Comment on lines +17 to +18
Copy link
Collaborator

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:

  • Lights N
  • Actuator N (with gripper mentioned as a potential intended output)
  • Relay N

but that's perhaps out of scope for this PR 🤷‍♂️

</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'

Expand All @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't these been renamed now to actuator_n_*? Not sure how that's best handled from a display perspective, given they were/are called servo_n_* for older firmware versions 🤷‍♂️

]
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,
]
Copy link
Collaborator

Choose a reason for hiding this comment

The 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 {
Expand Down
29 changes: 29 additions & 0 deletions core/frontend/src/store/ardupilot_capabilities.ts
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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// TODO: light functions were introduced at the same time as actuators
// light functions were introduced at the same time as actuators

return autopilot_data.parameter('ACTUATOR1_INC') !== undefined
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there pre-filtering somewhere, that makes this apply only to ArduSub?
IIRC Actuator outputs are more general ArduPilot, but Lights is a Sub thing - I could be wrong on both accounts though 🤷‍♂️

}
}
export { ArdupilotCapabilitiesStore }

const ardupilot_capabilities: ArdupilotCapabilitiesStore = getModule(ArdupilotCapabilitiesStore)
export default ardupilot_capabilities