1
1
<template lang="pug">
2
- q-page( padding ) .flex
3
- Joy
4
- q-btn-toggle (
5
- no-caps
6
- rounded
7
- unelevated
8
- toggle-color = "primary"
9
- text-color = "primary"
10
- v-model = "controlMode"
11
- :options = "[ \
12
- { label: 'One', value: 'one' }, \
13
- { label: 'Two', value: 'two' }, \
14
- { label: 'Three', value: 'three' } \
15
- ]" )
2
+ q-page( padding )
3
+ .q-pa-lg.row.q-gutter-md.flex-center
4
+ q-card ( style = 'max-width: 500px' ) .col
5
+ q-card-section ( :style = 'state.modeStyle' )
6
+ Joy ( @event = "handleJoystick" )
7
+ //- q-card-section
8
+ //- q-input(label="cmd_vel topic" v-model="state.cmdVelTopic")
9
+ q-tabs ( v-model = "state.controlMode" )
10
+ q-tab ( label = "Base" name = "base" ) .text-primary
11
+ q-tab ( label = "Arm" name = "arm" ) .text-secondary
12
+ q-separator ( inset )
13
+ q-card-actions ( align = "center" )
14
+ q-btn ( round icon = 'remove' )
15
+ q-btn ( round icon = 'add' )
16
16
</template >
17
17
18
18
<script setup>
19
- // import Joy from 'components/Joy.vue'
20
- import { rosInterface } from ' src/utils/RosUtils'
19
+ import _ from ' lodash' ;
21
20
import { toRefs , ref , reactive , watch , computed , onMounted } from ' vue'
22
- import DPad from ' src/components/DPad.vue' ;
21
+ import { getCssVar } from ' quasar'
22
+
23
+ import { rosInterface } from ' src/utils/RosUtils'
24
+ // import DPad from 'src/components/DPad.vue';
23
25
import Joy from ' src/components/Joy.vue' ;
24
26
25
- const controlMode = ref (" one" )
27
+ const controlStyles = {
28
+ base: getCssVar (' primary' ),
29
+ arm: getCssVar (' secondary' )
30
+ }
31
+
26
32
const state = reactive ({
27
- info: null ,
28
- panning: false ,
29
- direction: " stop" ,
33
+ controlMode: ' base' ,
34
+ modeStyle: computed (() => " backgroundColor: " + controlStyles[state .controlMode ]),
35
+ touching: false ,
36
+ direction: null ,
30
37
cmdVelTopic: rosInterface .cmdVelTopic .name ,
31
38
velocity: 0.5 ,
32
- cmdVelMsg: computed (() => {
33
- var msg = {
34
- up: { linear: { x: state .velocity } },
35
- down: { linear: { x: - state .velocity } },
36
- left: { angular: { x: state .velocity } },
37
- right: { angular: { x: - state .velocity } },
38
- stop: { linear: { x: 0.0 }, angular: { x: 0.0 } }
39
- };
40
- return msg[state .direction ];
41
- })
42
39
})
43
40
44
- function handlePan ({ evt, ... newInfo }) {
45
- state .info = newInfo
46
-
47
- // native Javascript event
48
- // console.log(evt)
49
-
50
- if (newInfo .isFirst ) {
51
- state .panning = true
41
+ function handleJoystick (event ) {
42
+ // console.log(event)
43
+ if (event === " start" ) {
44
+ state .touching = true ;
45
+ console .log (" Touch start." );
52
46
}
53
- else if (newInfo .isFinal ) {
54
- state .panning = false
55
- state .direction = " stop"
47
+ else if (event === " end" ) {
48
+ state .touching = false ;
49
+ console .log (" Touch end." );
50
+ }
51
+ else if (_ .startsWith (event , " dir:" )) {
52
+ state .direction = _ .split (event , " :" )[1 ];
56
53
}
57
-
58
- state .direction = newInfo .direction
59
54
}
60
55
61
- // watch topic and change publisher on change
62
- watch (() => state .cmdVelTopic , (topic ) => { rosInterface .cmdVelTopic .name = topic; })
63
56
// Publish 10Hz
64
57
onMounted (() => {
65
58
setInterval (() => {
66
- if (state .panning ) {
59
+ if (state .touching ) {
67
60
// console.log("pub message")
68
- rosInterface .cmdVelTopic .publish (state .cmdVelMsg )
61
+ // rosInterface.cmdVelTopic.publish(state.cmdVelMsg)
62
+ console .log (state .direction )
69
63
}
70
64
}, 100 )
71
65
})
66
+ // // watch topic and change publisher on change
67
+ // watch(() => state.cmdVelTopic, (topic) => { rosInterface.cmdVelTopic.name = topic; })
72
68
</script >
73
69
74
70
<style lang="sass" scoped>
75
- .custom-area
76
- width : 90%
77
- height : 550px
78
- border-radius : 3px
79
- padding : 0px
80
-
81
- .touch-area
82
- height : 85%
83
-
84
- .custom-info pre
85
- width : 180px
86
- font-size : 12px
87
-
88
- .touch-signal
89
- position : absolute
90
- top : 16px
91
- right : 16px
92
- width : 35px
93
- height : 35px
94
- font-size : 25px
95
- border-radius : 50% !important
96
- text-align : center
97
- background : rgba(255 , 255 , 255 , .2 )
98
71
</style >
0 commit comments