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;
|
||||
|
||||
function buildChart() {
|
||||
const reward_mean = store.getMean();
|
||||
const reward_std = store.getStd();
|
||||
const reward_mean = store.getMean;
|
||||
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 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);
|
||||
@ -97,9 +97,9 @@ onMounted(() => {
|
||||
buildChart();
|
||||
});
|
||||
|
||||
watch(() => store.getMean(), () => {
|
||||
const reward_mean = store.getMean();
|
||||
const reward_std = store.getStd();
|
||||
watch(() => store.getMean, () => {
|
||||
const reward_mean = store.getMean;
|
||||
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 lower_bound = Array(reward_mean.length).fill(0).map((_, i) => reward_mean[i] - 1.96 * reward_std[i]);
|
||||
|
||||
|
@ -25,13 +25,16 @@
|
||||
<script setup>
|
||||
import * as ROS from 'roslib';
|
||||
import { useBWStore } from '@/store/BaseWebsiteStore';
|
||||
import { usePStore } from "@/store/PolicyStore";
|
||||
import {
|
||||
reactive,
|
||||
ref,
|
||||
watch,
|
||||
} from 'vue';
|
||||
import * as ROSLIB from "roslib";
|
||||
|
||||
const store = useBWStore();
|
||||
const pstore = usePStore();
|
||||
|
||||
const formState = reactive({
|
||||
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>
|
||||
|
@ -1,4 +1,5 @@
|
||||
<template>
|
||||
<policy-plot/>
|
||||
<weight-tuner/>
|
||||
<reward-plot/>
|
||||
</template>
|
||||
@ -6,6 +7,7 @@
|
||||
<script setup>
|
||||
import WeightTuner from "@/components/WeightTuner.vue";
|
||||
import RewardPlot from "@/components/RewardPlot.vue";
|
||||
import PolicyPlot from "@/components/PolicyPlot.vue";
|
||||
</script>
|
||||
|
||||
<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: () => {
|
||||
return {
|
||||
policy: Array,
|
||||
weights: [-1, 1, 1],
|
||||
nr_steps: 0,
|
||||
nr_weights: 5,
|
||||
weights: [0, 0, 0, 0, 0],
|
||||
max_steps: 0,
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
getPolicy: (state) => state.policy,
|
||||
getNrWeights: (state) => state.nr_weights,
|
||||
getWeights: (state) => state.weights,
|
||||
getNrSteps: (state) => state.nr_steps,
|
||||
getMaxSteps: (state) => state.max_steps,
|
||||
},
|
||||
actions: {
|
||||
setPolicy(value) {
|
||||
this.policy = value;
|
||||
},
|
||||
setNrWeights(value) {
|
||||
this.nr_weights = value;
|
||||
this.weights = Array(this.nr_weights).fill(0);
|
||||
},
|
||||
setWeights(value) {
|
||||
this.weights = value;
|
||||
},
|
||||
setNrSteps(value) {
|
||||
this.nr_steps = value;
|
||||
setMaxSteps(value) {
|
||||
this.max_steps = value;
|
||||
},
|
||||
}
|
||||
})
|
||||
|
@ -3,15 +3,13 @@ import { defineStore } from "pinia";
|
||||
export const useRStore = defineStore('Reward Store', {
|
||||
state: () => {
|
||||
return {
|
||||
reward_mean: Array,
|
||||
reward_std: Array,
|
||||
nr_episodes: 0,
|
||||
reward_mean: [0,],
|
||||
reward_std: [0,],
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
getMean: (state) => state.reward_mean,
|
||||
getStd: (state) => state.reward_std,
|
||||
getNrEpisodes: (state) => state.nr_episodes,
|
||||
},
|
||||
actions: {
|
||||
setMean(value) {
|
||||
@ -20,8 +18,5 @@ export const useRStore = defineStore('Reward Store', {
|
||||
setStd(value) {
|
||||
this.reward_std = value;
|
||||
},
|
||||
setNrEpisodes(value) {
|
||||
this.nr_episodes = value;
|
||||
},
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user