now trying to use topics for abo
This commit is contained in:
parent
1db897b9d5
commit
12c5fd25be
@ -107,6 +107,57 @@ const policy_service = new ROSLIB.Service({
|
||||
serviceType: "active_bo_msgs/srv/WeightToPolicy",
|
||||
});
|
||||
|
||||
// RL Service + Feedback Suscriber
|
||||
const rl_feedback_subscriber = new ROSLIB.Topic({
|
||||
ros: ros,
|
||||
name: "/rl_feedback",
|
||||
messageType: "active_bo_msgs/msg/ImageFeedback",
|
||||
});
|
||||
|
||||
rl_feedback_subscriber.subscribe((msg) => {
|
||||
mcstore.setDim(msg.height, msg.width);
|
||||
mcstore.setRgbArrays(msg.red, msg.green, msg.blue);
|
||||
});
|
||||
|
||||
const active_rl_eval_sub = new ROSLIB.Topic({
|
||||
ros: ros,
|
||||
name: "/active_rl_eval_request",
|
||||
messageType: "active_bo_msgs/msg/ActiveRLEval",
|
||||
});
|
||||
|
||||
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,
|
||||
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;
|
||||
// });
|
||||
|
||||
watch(
|
||||
() => cstore.getSendWeights,
|
||||
() => {
|
||||
@ -121,43 +172,44 @@ 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;
|
||||
}
|
||||
console.log("Button pressed!");
|
||||
const active_eval_response = new ROSLIB.Message({
|
||||
policy: pstore.getPolicy,
|
||||
weights: pstore.getWeights,
|
||||
});
|
||||
|
||||
console.log(active_eval_response);
|
||||
|
||||
active_rl_eval_pub.publish(active_eval_response);
|
||||
console.log("New Policy/ Weights published");
|
||||
// pendingRequest.value = false;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// RL Service + Feedback Suscriber
|
||||
const rl_feedback_subscriber = new ROSLIB.Topic({
|
||||
ros: ros,
|
||||
name: "/rl_feedback",
|
||||
message: "active_bo_msgs/msg/ImageFeedback",
|
||||
});
|
||||
|
||||
rl_feedback_subscriber.subscribe((msg) => {
|
||||
mcstore.setDim(msg.height, msg.width);
|
||||
mcstore.setRgbArrays(msg.red, msg.green, msg.blue);
|
||||
});
|
||||
|
||||
const active_rl_eval_service = new ROSLIB.Service({
|
||||
ros: ros,
|
||||
name: "/active_rl_eval_srv",
|
||||
serviceType: "active_bo_msgs/srv/ActiveRLEval",
|
||||
});
|
||||
|
||||
active_rl_eval_service.advertise(function (request, response) {
|
||||
pstore.setPolicy(request["old_policy"]);
|
||||
pstore.setWeights(request["old_weights"]);
|
||||
|
||||
watch(
|
||||
() => cstore.getSendWeights,
|
||||
() => {
|
||||
response["new_policy"] = pstore.getPolicy;
|
||||
response["new_weights"] = pstore.getWeights;
|
||||
|
||||
return true;
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
const rl_service = new ROSLIB.Service({
|
||||
ros: ros,
|
||||
name: "/rl_srv",
|
||||
|
Loading…
Reference in New Issue
Block a user