diff --git a/ActiveBOWeb/src/components/RewardPlot.vue b/ActiveBOWeb/src/components/RewardPlot.vue index a6fe669..40e93b8 100644 --- a/ActiveBOWeb/src/components/RewardPlot.vue +++ b/ActiveBOWeb/src/components/RewardPlot.vue @@ -100,15 +100,18 @@ onMounted(() => { buildChart(); }); -watch(() => store.getMean, () => { +watch(() => store.getTrigger, () => { 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]); - chartHandle.data.dataset[0].data = reward_mean; - chartHandle.data.dataset[1].data = upper_bound; - chartHandle.data.dataset[2].data = lower_bound; + const reward_labels = Array(reward_mean.length).fill(0).map((_, i) => i); + + chartHandle.options.scales.x.labels = reward_labels; + chartHandle.data.datasets[0].data = reward_mean; + chartHandle.data.datasets[1].data = upper_bound; + chartHandle.data.datasets[2].data = lower_bound; chartHandle.update(); }); diff --git a/ActiveBOWeb/src/components/RosBar.vue b/ActiveBOWeb/src/components/RosBar.vue index acea2b7..7c5cd9c 100644 --- a/ActiveBOWeb/src/components/RosBar.vue +++ b/ActiveBOWeb/src/components/RosBar.vue @@ -35,10 +35,14 @@ import { } from 'vue'; import * as ROSLIB from "roslib"; +import {useRStore} from "@/store/RewardStore"; +import {useMCStore} from "@/store/MountainCarStore"; const store = useBWStore(); const pstore = usePStore(); const cstore = useCStore(); +const rstore = useRStore(); +const mcstore = useMCStore(); const formState = reactive({ ipaddress: 'localhost', @@ -95,7 +99,7 @@ watch(stateCounter.value, (newValue) => { } }); -// Services +// Policy Service const policy_service = new ROSLIB.Service({ ros: ros, name: '/policy_srv', @@ -114,6 +118,35 @@ watch(() => cstore.getSendWeights, () =>{ }); }); +// RL Service + Feedback Suscriber +const rl_feedback_subscriber = new ROSLIB.Topic({ + ros: ros, + name: '/rl_feedback', + message: 'active_bo_msgs/msg/ImageFeedback', +}); + +rl_feedback_subscriber.subscribe( (msg) => { + mcstore.setDim(msg.height, msg.width); +}); + +const rl_service = new ROSLIB.Service({ + ros: ros, + name: '/rl_srv', + serviceType: 'active_bo_msgs/srv/RLRollOut', +}); + +watch(() => cstore.getRunner, () =>{ + + const rl_request = new ROSLIB.ServiceRequest({ + policy: pstore.policy, + }) + + rl_service.callService(rl_request, function (rl_result) { + rstore.addMeanManually(rl_result.reward) + }); +}); + +