start working on ControlPanel.vue
This commit is contained in:
parent
c7625c7f2b
commit
0cc4dc6a83
49
ActiveBOWeb/src/components/ControlPanel.vue
Normal file
49
ActiveBOWeb/src/components/ControlPanel.vue
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<template>
|
||||||
|
<v-container>
|
||||||
|
<v-row>
|
||||||
|
<v-col cols="12" sm="6">
|
||||||
|
<v-select
|
||||||
|
:items="options"
|
||||||
|
label="Select an option"
|
||||||
|
v-model="selectedOption"
|
||||||
|
></v-select>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
<v-row>
|
||||||
|
<v-col cols="12" sm="6" v-for="(slider, index) in sliders" :key="index">
|
||||||
|
<v-slider
|
||||||
|
:max="slider.max"
|
||||||
|
:min="slider.min"
|
||||||
|
v-model="slider.value"
|
||||||
|
label="Slider {{index+1}}"
|
||||||
|
></v-slider>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
<v-row>
|
||||||
|
<v-col cols="12" sm="6">
|
||||||
|
<v-btn color="primary" @click="cstore.setSendWeights()">Send Weights</v-btn>
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="12" sm="6">
|
||||||
|
<v-btn color="secondary" @click="cstore.setRunner()">Run</v-btn>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
</v-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {usePStore} from "@/store/PolicyStore";
|
||||||
|
import {useCStore} from "@/store/ControlStore";
|
||||||
|
|
||||||
|
const pstore = usePStore();
|
||||||
|
const cstore = useCStore();
|
||||||
|
|
||||||
|
const options = ['manually', 'BO', 'active BO'];
|
||||||
|
const selectedOption = cstore.user_mode;
|
||||||
|
// TODO: Copy code from gpt
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
@ -17,8 +17,8 @@ const store = useRStore();
|
|||||||
let chartHandle;
|
let chartHandle;
|
||||||
|
|
||||||
function buildChart() {
|
function buildChart() {
|
||||||
const reward_mean = store.getMean();
|
const reward_mean = store.getMean;
|
||||||
const reward_std = store.getStd();
|
const reward_std = store.getStd;
|
||||||
const upper_bound = Array(reward_mean.length).fill(0).map((_, i) => reward_mean[i] + 1.96 * reward_std[i]);
|
const upper_bound = Array(reward_mean.length).fill(0).map((_, i) => reward_mean[i] + 1.96 * reward_std[i]);
|
||||||
const lower_bound = Array(reward_mean.length).fill(0).map((_, i) => reward_mean[i] - 1.96 * reward_std[i]);
|
const lower_bound = Array(reward_mean.length).fill(0).map((_, i) => reward_mean[i] - 1.96 * reward_std[i]);
|
||||||
const reward_labels = Array(reward_mean.length).fill(0).map((_, i) => i);
|
const reward_labels = Array(reward_mean.length).fill(0).map((_, i) => i);
|
||||||
@ -97,9 +97,9 @@ onMounted(() => {
|
|||||||
buildChart();
|
buildChart();
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(() => store.getMean(), () => {
|
watch(() => store.getMean, () => {
|
||||||
const reward_mean = store.getMean();
|
const reward_mean = store.getMean;
|
||||||
const reward_std = store.getStd();
|
const reward_std = store.getStd;
|
||||||
const upper_bound = Array(reward_mean.length).fill(0).map((_, i) => reward_mean[i] + 1.96 * reward_std[i]);
|
const upper_bound = Array(reward_mean.length).fill(0).map((_, i) => reward_mean[i] + 1.96 * reward_std[i]);
|
||||||
const lower_bound = Array(reward_mean.length).fill(0).map((_, i) => reward_mean[i] - 1.96 * reward_std[i]);
|
const lower_bound = Array(reward_mean.length).fill(0).map((_, i) => reward_mean[i] - 1.96 * reward_std[i]);
|
||||||
|
|
||||||
|
@ -25,13 +25,16 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import * as ROS from 'roslib';
|
import * as ROS from 'roslib';
|
||||||
import { useBWStore } from '@/store/BaseWebsiteStore';
|
import { useBWStore } from '@/store/BaseWebsiteStore';
|
||||||
|
import { usePStore } from "@/store/PolicyStore";
|
||||||
import {
|
import {
|
||||||
reactive,
|
reactive,
|
||||||
ref,
|
ref,
|
||||||
watch,
|
watch,
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
|
import * as ROSLIB from "roslib";
|
||||||
|
|
||||||
const store = useBWStore();
|
const store = useBWStore();
|
||||||
|
const pstore = usePStore();
|
||||||
|
|
||||||
const formState = reactive({
|
const formState = reactive({
|
||||||
ipaddress: 'localhost',
|
ipaddress: 'localhost',
|
||||||
@ -88,9 +91,18 @@ watch(stateCounter.value, (newValue) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Subscribers
|
// Services
|
||||||
|
const policy_service = new ROSLIB.Service({
|
||||||
|
ros: ros,
|
||||||
|
name: '/policy_srv',
|
||||||
|
serviceType: 'active_bo_msgs/srv/WeightToPolicy',
|
||||||
|
});
|
||||||
|
|
||||||
|
const policy_request = new ROSLIB.ServiceRequest({
|
||||||
|
weights: pstore.weights,
|
||||||
|
nr_steps: pstore.nr_steps,
|
||||||
|
})
|
||||||
|
|
||||||
// Publisher
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<weight-tuner/>
|
<policy-plot/>
|
||||||
|
<weight-tuner/>
|
||||||
<reward-plot/>
|
<reward-plot/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import WeightTuner from "@/components/WeightTuner.vue";
|
import WeightTuner from "@/components/WeightTuner.vue";
|
||||||
import RewardPlot from "@/components/RewardPlot.vue";
|
import RewardPlot from "@/components/RewardPlot.vue";
|
||||||
|
import PolicyPlot from "@/components/PolicyPlot.vue";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
18
ActiveBOWeb/src/rosInterfaces/policy_srv.js
Normal file
18
ActiveBOWeb/src/rosInterfaces/policy_srv.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import * as ROSLIB from 'roslib';
|
||||||
|
import { usePStore } from "../store/PolicyStore";
|
||||||
|
|
||||||
|
const store = usePStore();
|
||||||
|
|
||||||
|
export function PolicyService(ros) {
|
||||||
|
const service = new ROSLIB.Service({
|
||||||
|
ros: ros,
|
||||||
|
name: '/policy_srv',
|
||||||
|
serviceType: 'active_bo_msgs/srv/WeightToPolicy',
|
||||||
|
});
|
||||||
|
|
||||||
|
const request = new ROSLIB.ServiceRequest({
|
||||||
|
weights: store.weights,
|
||||||
|
nr_steps: store.nr_steps,
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
42
ActiveBOWeb/src/store/ControlStore.js
Normal file
42
ActiveBOWeb/src/store/ControlStore.js
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import { defineStore } from "pinia";
|
||||||
|
|
||||||
|
export const useCStore = defineStore('Control Store', {
|
||||||
|
state: () => {
|
||||||
|
return {
|
||||||
|
user_mode: 'manually',
|
||||||
|
nr_episodes: 10,
|
||||||
|
nr_runs: 1,
|
||||||
|
greedy: 0,
|
||||||
|
sendWeights: false,
|
||||||
|
runner: false,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getters: {
|
||||||
|
getUserMode: (state) => state.user_mode,
|
||||||
|
getNrEpisodes: (state) => state.nr_episodes,
|
||||||
|
getNrRuns: (state) => state.nr_runs,
|
||||||
|
getGreedy: (state) => state.greedy,
|
||||||
|
getSendWeights: (state) => state.sendWeights,
|
||||||
|
getRunner: (state) => state.runner,
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
setUserMode(value) {
|
||||||
|
this.user_mode = value;
|
||||||
|
},
|
||||||
|
setNrEpisodes(value) {
|
||||||
|
this.nr_episodes = value;
|
||||||
|
},
|
||||||
|
setNrRuns(value) {
|
||||||
|
this.nr_runs = value;
|
||||||
|
},
|
||||||
|
setGreedy(value) {
|
||||||
|
this.greedy = value;
|
||||||
|
},
|
||||||
|
setSendWeights() {
|
||||||
|
this.sendWeights = !this.sendWeights;
|
||||||
|
},
|
||||||
|
setRunner() {
|
||||||
|
this.runner = !this.runner;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
})
|
@ -4,24 +4,30 @@ export const usePStore = defineStore('Policy Store', {
|
|||||||
state: () => {
|
state: () => {
|
||||||
return {
|
return {
|
||||||
policy: Array,
|
policy: Array,
|
||||||
weights: [-1, 1, 1],
|
nr_weights: 5,
|
||||||
nr_steps: 0,
|
weights: [0, 0, 0, 0, 0],
|
||||||
|
max_steps: 0,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
getPolicy: (state) => state.policy,
|
getPolicy: (state) => state.policy,
|
||||||
|
getNrWeights: (state) => state.nr_weights,
|
||||||
getWeights: (state) => state.weights,
|
getWeights: (state) => state.weights,
|
||||||
getNrSteps: (state) => state.nr_steps,
|
getMaxSteps: (state) => state.max_steps,
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
setPolicy(value) {
|
setPolicy(value) {
|
||||||
this.policy = value;
|
this.policy = value;
|
||||||
},
|
},
|
||||||
|
setNrWeights(value) {
|
||||||
|
this.nr_weights = value;
|
||||||
|
this.weights = Array(this.nr_weights).fill(0);
|
||||||
|
},
|
||||||
setWeights(value) {
|
setWeights(value) {
|
||||||
this.weights = value;
|
this.weights = value;
|
||||||
},
|
},
|
||||||
setNrSteps(value) {
|
setMaxSteps(value) {
|
||||||
this.nr_steps = value;
|
this.max_steps = value;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -3,15 +3,13 @@ import { defineStore } from "pinia";
|
|||||||
export const useRStore = defineStore('Reward Store', {
|
export const useRStore = defineStore('Reward Store', {
|
||||||
state: () => {
|
state: () => {
|
||||||
return {
|
return {
|
||||||
reward_mean: Array,
|
reward_mean: [0,],
|
||||||
reward_std: Array,
|
reward_std: [0,],
|
||||||
nr_episodes: 0,
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
getMean: (state) => state.reward_mean,
|
getMean: (state) => state.reward_mean,
|
||||||
getStd: (state) => state.reward_std,
|
getStd: (state) => state.reward_std,
|
||||||
getNrEpisodes: (state) => state.nr_episodes,
|
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
setMean(value) {
|
setMean(value) {
|
||||||
@ -20,8 +18,5 @@ export const useRStore = defineStore('Reward Store', {
|
|||||||
setStd(value) {
|
setStd(value) {
|
||||||
this.reward_std = value;
|
this.reward_std = value;
|
||||||
},
|
},
|
||||||
setNrEpisodes(value) {
|
|
||||||
this.nr_episodes = value;
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user