From 7ae87384b4cf1df3658cdd27092cda0d8f07d983 Mon Sep 17 00:00:00 2001 From: Niko Date: Tue, 21 Mar 2023 16:55:11 +0100 Subject: [PATCH] publisher doesnt work --- ActiveBOWeb/index.html | 2 +- ActiveBOWeb/src/components/RosBar.vue | 51 ++++++--------------------- 2 files changed, 11 insertions(+), 42 deletions(-) diff --git a/ActiveBOWeb/index.html b/ActiveBOWeb/index.html index 3336a32..2ad8df9 100644 --- a/ActiveBOWeb/index.html +++ b/ActiveBOWeb/index.html @@ -4,7 +4,7 @@ - Vite App + Active BO
diff --git a/ActiveBOWeb/src/components/RosBar.vue b/ActiveBOWeb/src/components/RosBar.vue index 866fdfa..fc8ad83 100644 --- a/ActiveBOWeb/src/components/RosBar.vue +++ b/ActiveBOWeb/src/components/RosBar.vue @@ -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); + active_rl_eval_pub.publish(active_eval_response); + await sleep(1000); + } console.log("New Policy/ Weights published"); // pendingRequest.value = false; }