publisher doesnt work 2

This commit is contained in:
Niko Feith 2023-03-22 13:15:26 +01:00
parent 7ae87384b4
commit eb481e0799

View File

@ -138,19 +138,26 @@ const active_rl_eval_pub = new ROSLIB.Topic({
messageType: "active_bo_msgs/msg/ActiveRLEval",
});
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
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(
() => cstore.getSendWeights,
async () => {
() => {
const usr_mode = cstore.getUserMode;
if (usr_mode === "manually") {
const policy_request = new ROSLIB.ServiceRequest({
weights: pstore.weights,
nr_steps: pstore.max_steps,
weights: pstore.policy,
nr_steps: pstore.weights,
});
policy_service.callService(policy_request, function (result) {
@ -162,17 +169,14 @@ watch(
}
console.log("Button pressed!");
const active_eval_response = new ROSLIB.Message({
policy: pstore.getPolicy,
weights: pstore.getWeights,
policy: pstore.policy,
weights: pstore.weights,
});
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);
}
active_rl_eval_pub.publish(active_eval_response);
// await sleep(1000);
console.log("New Policy/ Weights published");
// pendingRequest.value = false;
}