Active BO works

This commit is contained in:
Niko Feith 2023-04-04 17:03:31 +02:00
parent 96a060f985
commit 7bbbf54044
2 changed files with 64 additions and 27 deletions

View File

@ -129,7 +129,7 @@ rl_feedback_subscriber.subscribe((msg) => {
const active_rl_eval_sub = new ROSLIB.Topic({
ros: ros_eval,
name: "/active_rl_eval_request",
messageType: "active_bo_msgs/msg/ActiveRLEval",
messageType: "active_bo_msgs/msg/ActiveRL",
});
const pendingRequest = ref(false);
@ -142,7 +142,7 @@ active_rl_eval_sub.subscribe((msg) => {
const active_rl_eval_pub = new ROSLIB.Topic({
ros: ros_eval,
name: "/active_rl_eval_response",
messageType: "active_bo_msgs/msg/ActiveRLEval",
messageType: "active_bo_msgs/msg/ActiveRL",
});
// const active_eval_response_first = new ROSLIB.Message({
@ -202,10 +202,31 @@ const bo_service = new ROSLIB.Service({
serviceType: "active_bo_msgs/srv/BO",
});
const active_bo_service = new ROSLIB.Service({
// const active_bo_service = new ROSLIB.Service({
// ros: ros,
// name: "/active_bo_srv",
// serviceType: "active_bo_msgs/srv/ActiveBO",
// });
const active_bo_pending = ref(false);
const active_bo_request = new ROSLIB.Topic({
ros: ros,
name: "/active_bo_srv",
serviceType: "active_bo_msgs/srv/ActiveBO",
name: "/active_bo_request",
messageType: "active_bo_msgs/msg/ActiveBORequest",
});
const active_bo_response = new ROSLIB.Topic({
ros: ros,
name: "/active_bo_response",
messageType: "active_bo_msgs/msg/ActiveBOResponse",
});
active_bo_response.subscribe((msg) => {
pstore.setPolicy(msg.best_policy);
pstore.setWeights(msg.best_weights);
rstore.setMean(msg.reward_mean);
rstore.setStd(msg.reward_std);
active_bo_pending.value = false;
});
watch(
@ -241,8 +262,8 @@ watch(
});
rl_service.callService(rl_request, () => {});
} else if (usr_mode === "active BO") {
const active_bo_request = new ROSLIB.ServiceRequest({
} else if (usr_mode === "active BO" && !active_bo_pending.value) {
const request_msg = new ROSLIB.Message({
nr_weights: pstore.nr_weights,
max_steps: pstore.max_steps,
nr_episodes: cstore.nr_episodes,
@ -251,20 +272,37 @@ watch(
epsilon: cstore.epsilon,
});
active_bo_service.callService(
active_bo_request,
function (active_bo_response) {
pstore.setPolicy(active_bo_response.best_policy);
pstore.setWeights(active_bo_response.best_weights);
rstore.setMean(active_bo_response.reward_mean);
rstore.setStd(active_bo_response.reward_std);
}
);
active_bo_request.publish(request_msg);
const rl_request = new ROSLIB.ServiceRequest({
policy: pstore.policy,
});
rl_service.callService(rl_request, () => {});
active_bo_pending.value = true;
// const active_bo_request = new ROSLIB.ServiceRequest({
// nr_weights: pstore.nr_weights,
// max_steps: pstore.max_steps,
// nr_episodes: cstore.nr_episodes,
// nr_runs: cstore.nr_runs,
// acquisition_function: cstore.acq_fun,
// epsilon: cstore.epsilon,
// });
//
// active_bo_service.callService(
// active_bo_request,
// function (active_bo_response) {
// pstore.setPolicy(active_bo_response.best_policy);
// pstore.setWeights(active_bo_response.best_weights);
// rstore.setMean(active_bo_response.reward_mean);
// rstore.setStd(active_bo_response.reward_std);
// }
// );
// const rl_request = new ROSLIB.ServiceRequest({
// policy: pstore.policy,
// });
//
// rl_service.callService(rl_request, () => {});
}
}
);

View File

@ -4,19 +4,18 @@ import { createApp } from "vue";
import { createPinia } from "pinia";
// Vuetify
import 'vuetify/styles'
import { createVuetify } from 'vuetify'
import * as components from 'vuetify/components'
import * as directives from 'vuetify/directives'
import '@mdi/font/css/materialdesignicons.css'
import "vuetify/styles";
import { createVuetify } from "vuetify";
import * as components from "vuetify/components";
import * as directives from "vuetify/directives";
import "@mdi/font/css/materialdesignicons.css";
import App from "./App.vue";
const pinia = createPinia();
const vuetify = createVuetify({
theme: {
defaultTheme: 'dark',
defaultTheme: "dark",
},
components,
directives,