publisher doesnt work

This commit is contained in:
Niko Feith 2023-03-21 16:55:11 +01:00
parent 12c5fd25be
commit 7ae87384b4
2 changed files with 11 additions and 42 deletions

View File

@ -4,7 +4,7 @@
<meta charset="UTF-8">
<link rel="icon" href="/CPS_White.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vite App</title>
<title>Active BO</title>
</head>
<body>
<div id="app"></div>

View File

@ -137,30 +137,14 @@ const active_rl_eval_pub = new ROSLIB.Topic({
name: "/active_rl_eval_response",
messageType: "active_bo_msgs/msg/ActiveRLEval",
});
// const active_rl_eval_service = 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);
//
// active_rl_eval_service.advertise(function (request, response) {
// currentResponse = response;
// currentServiceId = this.id;
// pendingRequest.value = true;
//
// pstore.setPolicy(request["old_policy"]);
// pstore.setWeights(request["old_weights"]);
//
// return false;
// });
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
watch(
() => cstore.getSendWeights,
() => {
async () => {
const usr_mode = cstore.getUserMode;
if (usr_mode === "manually") {
@ -172,25 +156,6 @@ watch(
policy_service.callService(policy_request, function (result) {
pstore.setPolicy(result.policy);
});
// } else if (usr_mode === "active BO") {
// if (!pendingRequest.value) {
// return;
// }
// console.log('after Button')
// currentResponse["new_policy"] = pstore.getPolicy;
// currentResponse["new_weights"] = pstore.getWeights;
//
// active_rl_eval_service.ros.callOnConnection({
// op: "service_response",
// service: active_rl_eval_service.name,
// values: currentResponse,
// result: true,
// id: currentServiceId,
// });
// console.log('call on connection')
// pendingRequest.value = false;
// currentResponse = null;
// currentServiceId = null;
} else if (usr_mode === "active BO") {
if (!pendingRequest.value) {
return;
@ -202,8 +167,12 @@ watch(
});
console.log(active_eval_response);
for (let i = 0; i < 10; i++) {
console.log(i);
active_rl_eval_pub.publish(active_eval_response);
await sleep(1000);
}
console.log("New Policy/ Weights published");
// pendingRequest.value = false;
}