Compare commits
3 Commits
98a8748b15
...
7bbbf54044
Author | SHA1 | Date | |
---|---|---|---|
7bbbf54044 | |||
96a060f985 | |||
98226688c2 |
@ -108,11 +108,11 @@ watch(stateCounter.value, (newValue) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Policy Service
|
// Policy Service
|
||||||
// const policy_service = new ROSLIB.Service({
|
const policy_service = new ROSLIB.Service({
|
||||||
// ros: ros,
|
ros: ros,
|
||||||
// name: "/policy_srv",
|
name: "/policy_srv",
|
||||||
// serviceType: "active_bo_msgs/srv/WeightToPolicy",
|
serviceType: "active_bo_msgs/srv/WeightToPolicy",
|
||||||
// });
|
});
|
||||||
|
|
||||||
// RL Service + Feedback Suscriber
|
// RL Service + Feedback Suscriber
|
||||||
const rl_feedback_subscriber = new ROSLIB.Topic({
|
const rl_feedback_subscriber = new ROSLIB.Topic({
|
||||||
@ -126,99 +126,66 @@ rl_feedback_subscriber.subscribe((msg) => {
|
|||||||
mcstore.setRgbArrays(msg.red, msg.green, msg.blue);
|
mcstore.setRgbArrays(msg.red, msg.green, msg.blue);
|
||||||
});
|
});
|
||||||
|
|
||||||
// const active_rl_eval_sub = new ROSLIB.Topic({
|
const active_rl_eval_sub = new ROSLIB.Topic({
|
||||||
// ros: ros_eval,
|
ros: ros_eval,
|
||||||
// name: "/active_rl_eval_request",
|
name: "/active_rl_eval_request",
|
||||||
// messageType: "active_bo_msgs/msg/ActiveRLEval",
|
messageType: "active_bo_msgs/msg/ActiveRL",
|
||||||
// });
|
|
||||||
//
|
|
||||||
// const pendingRequest = ref(false);
|
|
||||||
// active_rl_eval_sub.subscribe((msg) => {
|
|
||||||
// pstore.setPolicy(msg.policy);
|
|
||||||
// pstore.setWeights(msg.weights);
|
|
||||||
// pendingRequest.value = true;
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// const active_rl_eval_pub = new ROSLIB.Topic({
|
|
||||||
// ros: ros_eval,
|
|
||||||
// name: "/active_rl_eval_response",
|
|
||||||
// messageType: "active_bo_msgs/msg/ActiveRLEval",
|
|
||||||
// });
|
|
||||||
|
|
||||||
// Active RL Eval Service
|
|
||||||
let active_rl_eval_srv = new ROSLIB.Service({
|
|
||||||
ros: ros,
|
|
||||||
name: "/active_rl_eval_srv",
|
|
||||||
serviceType: "active_bo_msgs/srv/ActiveRLEval",
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let currentResponse = null;
|
|
||||||
let currentServiceId = null;
|
|
||||||
const pendingRequest = ref(false);
|
const pendingRequest = ref(false);
|
||||||
|
active_rl_eval_sub.subscribe((msg) => {
|
||||||
active_rl_eval_srv.advertise(function (request, response) {
|
pstore.setPolicy(msg.policy);
|
||||||
currentResponse = response;
|
pstore.setWeights(msg.weights);
|
||||||
currentServiceId = this.id;
|
|
||||||
pendingRequest.value = true;
|
pendingRequest.value = true;
|
||||||
|
|
||||||
pstore.setPolicy(request["old_policy"]);
|
|
||||||
pstore.setWeights(request["old_weights"]);
|
|
||||||
|
|
||||||
console.log(request);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const active_rl_eval_pub = new ROSLIB.Topic({
|
||||||
|
ros: ros_eval,
|
||||||
|
name: "/active_rl_eval_response",
|
||||||
|
messageType: "active_bo_msgs/msg/ActiveRL",
|
||||||
|
});
|
||||||
|
|
||||||
|
// const active_eval_response_first = new ROSLIB.Message({
|
||||||
|
// policy: pstore.policy,
|
||||||
|
// weights: pstore.weights,
|
||||||
|
// });
|
||||||
|
// console.log(active_eval_response_first);
|
||||||
|
// active_rl_eval_pub.publish(active_eval_response_first);
|
||||||
|
|
||||||
|
// function sleep(ms) {
|
||||||
|
// return new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
|
// }
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => cstore.getSendWeights,
|
() => cstore.getSendWeights,
|
||||||
() => {
|
() => {
|
||||||
const usr_mode = cstore.getUserMode;
|
const usr_mode = cstore.getUserMode;
|
||||||
|
|
||||||
// if (usr_mode === "manually") {
|
if (usr_mode === "manually") {
|
||||||
// const policy_request = new ROSLIB.ServiceRequest({
|
const policy_request = new ROSLIB.ServiceRequest({
|
||||||
// weights: pstore.policy,
|
weights: pstore.policy,
|
||||||
// nr_steps: pstore.weights,
|
nr_steps: pstore.weights,
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// policy_service.callService(policy_request, function (result) {
|
policy_service.callService(policy_request, function (result) {
|
||||||
// pstore.setPolicy(result.policy);
|
pstore.setPolicy(result.policy);
|
||||||
// });
|
});
|
||||||
// } else
|
} else if (usr_mode === "active BO") {
|
||||||
if (usr_mode === "active BO") {
|
|
||||||
if (!pendingRequest.value) {
|
if (!pendingRequest.value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log("Button pressed!");
|
console.log("Button pressed!");
|
||||||
// const active_eval_response = new ROSLIB.Message({
|
const active_eval_response = new ROSLIB.Message({
|
||||||
// policy: pstore.policy,
|
policy: pstore.policy,
|
||||||
// weights: pstore.weights,
|
weights: pstore.weights,
|
||||||
// });
|
|
||||||
//
|
|
||||||
// console.log(active_eval_response);
|
|
||||||
//
|
|
||||||
// active_rl_eval_pub.publish(active_eval_response);
|
|
||||||
// // await sleep(1000);
|
|
||||||
// console.log("New Policy/ Weights published");
|
|
||||||
// pendingRequest.value = false;
|
|
||||||
|
|
||||||
currentResponse["new_policy"] = pstore.getPolicy;
|
|
||||||
currentResponse["new_weights"] = pstore.getWeights;
|
|
||||||
|
|
||||||
console.log(currentResponse);
|
|
||||||
|
|
||||||
active_rl_eval_srv.ros.callOnConnection({
|
|
||||||
op: "service_response",
|
|
||||||
service: active_rl_eval_srv.name,
|
|
||||||
values: currentResponse,
|
|
||||||
id: currentServiceId,
|
|
||||||
result: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("Service Responded!");
|
console.log(active_eval_response);
|
||||||
|
|
||||||
// pendingRequest.value = false;
|
active_rl_eval_pub.publish(active_eval_response);
|
||||||
// currentResponse = null;
|
// await sleep(1000);
|
||||||
// currentServiceId = null;
|
console.log("New Policy/ Weights published");
|
||||||
|
pendingRequest.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -235,10 +202,31 @@ const bo_service = new ROSLIB.Service({
|
|||||||
serviceType: "active_bo_msgs/srv/BO",
|
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,
|
ros: ros,
|
||||||
name: "/active_bo_srv",
|
name: "/active_bo_request",
|
||||||
serviceType: "active_bo_msgs/srv/ActiveBO",
|
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(
|
watch(
|
||||||
@ -274,8 +262,8 @@ watch(
|
|||||||
});
|
});
|
||||||
|
|
||||||
rl_service.callService(rl_request, () => {});
|
rl_service.callService(rl_request, () => {});
|
||||||
} else if (usr_mode === "active BO") {
|
} else if (usr_mode === "active BO" && !active_bo_pending.value) {
|
||||||
const active_bo_request = new ROSLIB.ServiceRequest({
|
const request_msg = new ROSLIB.Message({
|
||||||
nr_weights: pstore.nr_weights,
|
nr_weights: pstore.nr_weights,
|
||||||
max_steps: pstore.max_steps,
|
max_steps: pstore.max_steps,
|
||||||
nr_episodes: cstore.nr_episodes,
|
nr_episodes: cstore.nr_episodes,
|
||||||
@ -284,20 +272,37 @@ watch(
|
|||||||
epsilon: cstore.epsilon,
|
epsilon: cstore.epsilon,
|
||||||
});
|
});
|
||||||
|
|
||||||
active_bo_service.callService(
|
active_bo_request.publish(request_msg);
|
||||||
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({
|
const rl_request = new ROSLIB.ServiceRequest({
|
||||||
policy: pstore.policy,
|
policy: pstore.policy,
|
||||||
});
|
});
|
||||||
|
|
||||||
rl_service.callService(rl_request, () => {});
|
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, () => {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -4,22 +4,21 @@ import { createApp } from "vue";
|
|||||||
import { createPinia } from "pinia";
|
import { createPinia } from "pinia";
|
||||||
|
|
||||||
// Vuetify
|
// Vuetify
|
||||||
import 'vuetify/styles'
|
import "vuetify/styles";
|
||||||
import { createVuetify } from 'vuetify'
|
import { createVuetify } from "vuetify";
|
||||||
import * as components from 'vuetify/components'
|
import * as components from "vuetify/components";
|
||||||
import * as directives from 'vuetify/directives'
|
import * as directives from "vuetify/directives";
|
||||||
import '@mdi/font/css/materialdesignicons.css'
|
import "@mdi/font/css/materialdesignicons.css";
|
||||||
|
|
||||||
|
|
||||||
import App from "./App.vue";
|
import App from "./App.vue";
|
||||||
|
|
||||||
const pinia = createPinia();
|
const pinia = createPinia();
|
||||||
const vuetify = createVuetify({
|
const vuetify = createVuetify({
|
||||||
theme: {
|
theme: {
|
||||||
defaultTheme: 'dark',
|
defaultTheme: "dark",
|
||||||
},
|
},
|
||||||
components,
|
components,
|
||||||
directives,
|
directives,
|
||||||
});
|
});
|
||||||
|
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
|
Loading…
Reference in New Issue
Block a user