2023-08-21 01:51:35 -04:00
< script setup lang = "ts" >
2023-10-17 16:32:59 -04:00
import PvSelect from "@/components/common/pv-select.vue" ;
2023-08-21 01:51:35 -04:00
import { useCameraSettingsStore } from "@/stores/settings/CameraSettingsStore" ;
2024-01-02 11:03:16 -05:00
import { type ActivePipelineSettings , PipelineType , RobotOffsetPointMode } from "@/types/PipelineTypes" ;
2023-10-17 16:32:59 -04:00
import PvSwitch from "@/components/common/pv-switch.vue" ;
2023-08-21 01:51:35 -04:00
import { computed , getCurrentInstance } from "vue" ;
import { RobotOffsetType } from "@/types/SettingTypes" ;
import { useStateStore } from "@/stores/StateStore" ;
2023-08-31 16:56:58 -04:00
const isTagPipeline = computed (
( ) =>
useCameraSettingsStore ( ) . currentPipelineType === PipelineType . AprilTag ||
useCameraSettingsStore ( ) . currentPipelineType === PipelineType . Aruco
) ;
2023-08-21 01:51:35 -04:00
interface MetricItem {
2023-08-31 16:56:58 -04:00
header : string ;
value ? : string ;
2023-08-21 01:51:35 -04:00
}
const offsetPoints = computed < MetricItem [ ] > ( ( ) => {
switch ( useCameraSettingsStore ( ) . currentPipelineSettings . offsetRobotOffsetMode ) {
case RobotOffsetPointMode . Single :
const value = Object . values ( useCameraSettingsStore ( ) . currentPipelineSettings . offsetSinglePoint ) ;
return [ { header : "Offset Point" , value : ` ( ${ value [ 0 ] . toFixed ( 2 ) } °, ${ value [ 1 ] . toFixed ( 2 ) } °) ` } ] ;
case RobotOffsetPointMode . Dual :
const firstPoint = Object . values ( useCameraSettingsStore ( ) . currentPipelineSettings . offsetDualPointA ) ;
const firstPointArea = useCameraSettingsStore ( ) . currentPipelineSettings . offsetDualPointAArea ;
const secondPoint = Object . values ( useCameraSettingsStore ( ) . currentPipelineSettings . offsetDualPointB ) ;
const secondPointArea = useCameraSettingsStore ( ) . currentPipelineSettings . offsetDualPointBArea ;
2023-08-31 16:56:58 -04:00
return [
{ header : "First Offset Point" , value : ` ( ${ firstPoint [ 0 ] . toFixed ( 2 ) } °, ${ firstPoint [ 1 ] . toFixed ( 2 ) } °) ` } ,
{ header : "First Offset Point Area" , value : ` ${ firstPointArea . toFixed ( 2 ) } % ` } ,
{ header : "Second Offset Point" , value : ` ( ${ secondPoint [ 0 ] . toFixed ( 2 ) } °, ${ secondPoint [ 1 ] . toFixed ( 2 ) } °) ` } ,
{ header : "Second Offset Point Area" , value : ` ${ secondPointArea . toFixed ( 2 ) } % ` }
2023-08-21 01:51:35 -04:00
] ;
default :
case RobotOffsetPointMode . None :
return [ ] ;
}
} ) ;
2024-01-02 11:03:16 -05:00
// TODO fix pipeline typing in order to fix this, the store settings call should be able to infer that only valid pipeline type settings are exposed based on pre-checks for the entire config section
// Defer reference to store access method
const currentPipelineSettings = computed < ActivePipelineSettings > (
( ) => useCameraSettingsStore ( ) . currentPipelineSettings
) ;
2023-10-17 10:20:00 -04:00
2024-01-16 22:23:05 -05:00
const interactiveCols = computed ( ( ) =>
( getCurrentInstance ( ) ? . proxy . $vuetify . breakpoint . mdAndDown || false ) &&
( ! useStateStore ( ) . sidebarFolded || useCameraSettingsStore ( ) . isDriverMode )
? 9
: 8
) ;
2023-08-21 01:51:35 -04:00
< / script >
< template >
< div >
2023-10-17 16:32:59 -04:00
< pv-select
2023-08-21 01:51:35 -04:00
v - model = "useCameraSettingsStore().currentPipelineSettings.contourTargetOffsetPointEdge"
label = "Target Offset Point"
tooltip = "Changes where the 'center' of the target is (used for calculating e.g. pitch and yaw)"
2023-08-31 16:56:58 -04:00
: items = "['Center', 'Top', 'Bottom', 'Left', 'Right']"
2023-08-21 01:51:35 -04:00
: select - cols = "interactiveCols"
2023-08-31 16:56:58 -04:00
@ input = "
( value ) => useCameraSettingsStore ( ) . changeCurrentPipelineSetting ( { contourTargetOffsetPointEdge : value } , false )
"
2023-08-21 01:51:35 -04:00
/ >
2023-10-17 16:32:59 -04:00
< pv-select
2023-08-21 01:51:35 -04:00
v - if = "!isTagPipeline"
v - model = "useCameraSettingsStore().currentPipelineSettings.contourTargetOrientation"
label = "Target Orientation"
tooltip = "Used to determine how to calculate target landmarks (e.g. the top, left, or bottom of the target)"
: items = "['Portrait', 'Landscape']"
: select - cols = "interactiveCols"
2023-08-31 16:56:58 -04:00
@ input = "
( value ) => useCameraSettingsStore ( ) . changeCurrentPipelineSetting ( { contourTargetOrientation : value } , false )
"
2023-08-21 01:51:35 -04:00
/ >
2023-10-17 16:32:59 -04:00
< pv-switch
2023-08-21 01:51:35 -04:00
v - model = "useCameraSettingsStore().currentPipelineSettings.outputShowMultipleTargets"
label = "Show Multiple Targets"
2023-10-17 10:20:00 -04:00
tooltip = "If enabled, up to five targets will be displayed and sent via PhotonLib, instead of just one"
2023-08-21 01:51:35 -04:00
: disabled = "isTagPipeline"
: switch - cols = "interactiveCols"
2023-08-31 16:56:58 -04:00
@ input = "
( value ) => useCameraSettingsStore ( ) . changeCurrentPipelineSetting ( { outputShowMultipleTargets : value } , false )
"
2023-08-21 01:51:35 -04:00
/ >
2023-10-21 11:09:55 -04:00
< pv-switch
2023-10-17 10:20:00 -04:00
v - if = "
2023-10-24 19:39:38 -07:00
( currentPipelineSettings . pipelineType === PipelineType . AprilTag ||
currentPipelineSettings . pipelineType === PipelineType . Aruco ) &&
2023-10-21 11:09:55 -04:00
useCameraSettingsStore ( ) . isCurrentVideoFormatCalibrated &&
useCameraSettingsStore ( ) . currentPipelineSettings . solvePNPEnabled
2023-10-17 10:20:00 -04:00
"
v - model = "currentPipelineSettings.doMultiTarget"
label = "Do Multi-Target Estimation"
tooltip = "If enabled, all visible fiducial targets will be used to provide a single pose estimate from their combined model."
: switch - cols = "interactiveCols"
: disabled = "!isTagPipeline"
@ input = "(value) => useCameraSettingsStore().changeCurrentPipelineSetting({ doMultiTarget: value }, false)"
/ >
2023-10-21 11:09:55 -04:00
< pv-switch
2023-10-17 10:20:00 -04:00
v - if = "
2023-10-24 19:39:38 -07:00
( currentPipelineSettings . pipelineType === PipelineType . AprilTag ||
currentPipelineSettings . pipelineType === PipelineType . Aruco ) &&
2023-10-21 11:09:55 -04:00
useCameraSettingsStore ( ) . isCurrentVideoFormatCalibrated &&
useCameraSettingsStore ( ) . currentPipelineSettings . solvePNPEnabled
2023-10-17 10:20:00 -04:00
"
v - model = "currentPipelineSettings.doSingleTargetAlways"
label = "Always Do Single-Target Estimation"
tooltip = "If disabled, visible fiducial targets used for multi-target estimation will not also be used for single-target estimation."
: switch - cols = "interactiveCols"
: disabled = "!isTagPipeline || !currentPipelineSettings.doMultiTarget"
@ input = "(value) => useCameraSettingsStore().changeCurrentPipelineSetting({ doSingleTargetAlways: value }, false)"
/ >
2023-08-21 01:51:35 -04:00
< v-divider / >
< table
v - if = "useCameraSettingsStore().currentPipelineSettings.offsetRobotOffsetMode !== RobotOffsetPointMode.None"
class = "metrics-table mt-3 mb-3"
>
< tr >
2023-08-31 16:56:58 -04:00
< th v-for = "(item, itemIndex) in offsetPoints" :key="itemIndex" class="metric-item metric-item-title" >
2023-08-21 01:51:35 -04:00
{ { item . header } }
< / th >
< / tr >
< tr >
2023-08-31 16:56:58 -04:00
< td v-for = "(item, itemIndex) in offsetPoints" :key="itemIndex" class="metric-item" >
2023-08-21 01:51:35 -04:00
{ { item . value } }
< / td >
< / tr >
< / table >
2023-10-17 16:32:59 -04:00
< pv-select
2023-08-21 01:51:35 -04:00
v - model = "useCameraSettingsStore().currentPipelineSettings.offsetRobotOffsetMode"
label = "Robot Offset Mode"
tooltip = "Used to add an arbitrary offset to the location of the targeting crosshair"
2023-08-31 16:56:58 -04:00
: items = "['None', 'Single Point', 'Dual Point']"
2023-08-21 01:51:35 -04:00
: select - cols = "interactiveCols"
2023-08-31 16:56:58 -04:00
@ input = "(value) => useCameraSettingsStore().changeCurrentPipelineSetting({ offsetRobotOffsetMode: value }, false)"
2023-08-21 01:51:35 -04:00
/ >
< v-row
v - if = "useCameraSettingsStore().currentPipelineSettings.offsetRobotOffsetMode !== RobotOffsetPointMode.None"
align = "center"
justify = "start"
>
2023-08-31 16:56:58 -04:00
< v-row
v - if = "useCameraSettingsStore().currentPipelineSettings.offsetRobotOffsetMode === RobotOffsetPointMode.Single"
>
2023-08-21 01:51:35 -04:00
< v-col >
< v-btn
small
color = "accent"
2023-08-31 16:56:58 -04:00
style = "width: 100%"
2023-08-21 01:51:35 -04:00
class = "black--text"
@ click = "useCameraSettingsStore().takeRobotOffsetPoint(RobotOffsetType.Single)"
>
Take Point
< / v-btn >
< / v-col >
< / v-row >
2023-08-31 16:56:58 -04:00
< v-row
v - else - if = "useCameraSettingsStore().currentPipelineSettings.offsetRobotOffsetMode === RobotOffsetPointMode.Dual"
>
2023-08-21 01:51:35 -04:00
< v-col >
< v-btn
small
color = "accent"
2023-08-31 16:56:58 -04:00
style = "width: 100%"
2023-08-21 01:51:35 -04:00
class = "black--text"
@ click = "useCameraSettingsStore().takeRobotOffsetPoint(RobotOffsetType.DualFirst)"
>
Take First Point
< / v-btn >
< / v-col >
< v-col >
< v-btn
small
color = "accent"
2023-08-31 16:56:58 -04:00
style = "width: 100%"
2023-08-21 01:51:35 -04:00
class = "black--text"
@ click = "useCameraSettingsStore().takeRobotOffsetPoint(RobotOffsetType.DualSecond)"
>
Take Second Point
< / v-btn >
< / v-col >
< / v-row >
< v-col >
< v-btn
small
color = "yellow darken-3"
2023-08-31 16:56:58 -04:00
style = "width: 100%"
2023-08-21 01:51:35 -04:00
@ click = "useCameraSettingsStore().takeRobotOffsetPoint(RobotOffsetType.Clear)"
>
Clear All Points
< / v-btn >
< / v-col >
< / v-row >
< / div >
< / template >
< style scoped >
2023-08-31 16:56:58 -04:00
. metrics - table {
2023-08-21 01:51:35 -04:00
border - collapse : separate ;
border - spacing : 0 ;
border - radius : 5 px ;
border : 1 px solid white ;
width : 100 % ;
text - align : center ;
}
. metric - item {
padding : 1 px 15 px 1 px 10 px ;
border - right : 1 px solid ;
font - weight : normal ;
color : white ;
}
. metric - item - title {
font - size : 18 px ;
text - decoration : underline ;
text - decoration - color : # ffd843 ;
}
< / style >