Skip to content

Commit a3763c1

Browse files
committed
Add experiment panel
1 parent 2459ef7 commit a3763c1

File tree

6 files changed

+99
-8
lines changed

6 files changed

+99
-8
lines changed

.vscode/settings.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"vetur.validation.template": false,
33
"vetur.format.enable": false,
44
"eslint.validate": ["javascript", "javascriptreact", "typescript", "vue"],
5-
6-
"vetur.experimental.templateInterpolationService": true
5+
6+
"vetur.experimental.templateInterpolationService": true,
7+
"vue3snippets.enable-compile-vue-file-on-did-save-code": true
78
}

src/layouts/MainLayout.vue

+6
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,11 @@ const menuContent = [
6868
pathName: 'home.controller',
6969
separator: false
7070
},
71+
{
72+
icon: 'science',
73+
label: 'Experiment',
74+
pathName: 'home.experiment',
75+
separator: false
76+
},
7177
]
7278
</script>

src/pages/ExperimentPanel.vue

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<template>
2+
<q-page padding>
3+
<!-- content -->
4+
<div class="q-pa-md">
5+
<div class="q-gutter-sm">
6+
<div>Task: <strong>current</strong></div>
7+
<q-btn-group rounded>
8+
<q-btn rounded color="primary" label="Start Task" />
9+
<q-btn rounded color="red" label="Stop Task" />
10+
</q-btn-group>
11+
<div>
12+
Facial expression: <strong>{{ lastExpression }}</strong>
13+
</div>
14+
<q-btn-group outline rounded>
15+
<template v-for="(expressionName, index) in expressionList" :key="index">
16+
<q-btn
17+
outline
18+
color="primary"
19+
@click="
20+
() => {
21+
express(expressionName);
22+
}
23+
"
24+
:label="expressionName"
25+
/>
26+
</template>
27+
</q-btn-group>
28+
29+
<div>Voice Command</div>
30+
<q-list bordered separator style="max-width: 350px">
31+
<q-item clickable v-ripple>
32+
<q-item-section>
33+
<q-item-label overline>Voice</q-item-label>
34+
<q-item-label>Hello</q-item-label>
35+
</q-item-section>
36+
</q-item>
37+
</q-list>
38+
39+
<div>
40+
<iframe
41+
width="400"
42+
height="250"
43+
src="https://vclock.com/embed/timer/#countdown=00:00:10&enabled=0&seconds=10&onzero=1&theme=1&ampm=1&sound=xylophone"
44+
frameborder="0"
45+
allowfullscreen
46+
></iframe>
47+
</div>
48+
</div>
49+
</div>
50+
</q-page>
51+
</template>
52+
53+
<script setup>
54+
import { toRefs, ref, reactive, watch, watchEffect, computed, onMounted } from "vue";
55+
import { rosConnection } from "src/utils/RosUtils";
56+
57+
const expressionList = ["happy", "sad", "mad", "focused", "confused"];
58+
const lastExpression = ref("None");
59+
var expressionTopic = new ROSLIB.Topic({
60+
ros: rosConnection.ros,
61+
name: "/face",
62+
messageType: "std_msgs/String",
63+
});
64+
65+
function express(expressionType) {
66+
var expressionMsg = new ROSLIB.Message({ data: expressionType });
67+
expressionTopic.publish(expressionMsg);
68+
lastExpression.value = expressionType;
69+
}
70+
</script>

src/pages/Index.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<script setup>
2727
2828
import { ref, toRefs, reactive, onMounted, watch } from "vue"
29-
import { rosInterface } from "src/utils/RosUtils"
29+
import { rosInterface,triggerServiceByName } from "src/utils/RosUtils"
3030
import NumericInput from "src/components/NumericInput.vue"
3131
import { useQuasar } from 'quasar'
3232
const $q = useQuasar()
@@ -89,6 +89,7 @@ function checkoutOrders () {
8989
})
9090
// console.log('Orders submitted.')
9191
//TODO publish order
92+
triggerServiceByName("/sp_sm/start")
9293
notif({
9394
type: 'positive',
9495
message: 'Orders submitted.'

src/router/routes.js

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ const routes = [
1919
name: "home.controller",
2020
component: () => import("pages/Controller.vue"),
2121
},
22+
{
23+
path: "experiment",
24+
name: "home.experiment",
25+
component: () => import("pages/ExperimentPanel.vue"),
26+
},
2227
],
2328
},
2429
// Always leave this as last one,

src/utils/RosUtils.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,23 @@ export const rosDisconnect = () => {
2424
rosConnection.connected = false;
2525
};
2626

27+
export function makeTopic(topicName, topicType) {
28+
return new ROSLIB.Topic({
29+
ros: rosConnection.ros,
30+
name: topicName,
31+
messageType: topicType,
32+
});
33+
}
34+
2735
export const rosInterface = reactive({
2836
// JointState
2937
jointState: null,
3038
// Subscriber
31-
orderTopic: new ROSLIB.Topic({
32-
ros: rosConnection.ros,
33-
name: "/sp_sm/current_orders",
34-
messageType: "std_msgs/Int16MultiArray",
35-
}),
39+
// orderTopic: new ROSLIB.Topic({
40+
// ros: rosConnection.ros,
41+
// name: "/sp_sm/current_orders",
42+
// messageType: "std_msgs/Int16MultiArray",
43+
// }),
3644
stateTopic: new ROSLIB.Topic({
3745
ros: rosConnection.ros,
3846
name: "/state_machine/smach/container_status",

0 commit comments

Comments
 (0)