/** * Call this service. The callback function will be called with the * associated service response. * * @param request * The service request to send. * @param cb * The callback used when the associated response comes back. */ public void callService(ServiceRequest request, ServiceCallback cb) { // construct the unique ID String callServceId = "call_service:" + this.name + ":" + this.ros.nextId(); // register the callback function this.ros.registerServiceCallback(callServceId, cb); // build and send the rosbridge call JsonObject call = Json.createObjectBuilder() .add(JRosbridge.FIELD_OP, JRosbridge.OP_CODE_CALL_SERVICE) .add(JRosbridge.FIELD_ID, callServceId) .add(JRosbridge.FIELD_TYPE, this.type) .add(JRosbridge.FIELD_SERVICE, this.name) .add(JRosbridge.FIELD_ARGS, request.toJsonObject()).build(); this.ros.send(call); }
/** * Call this service. The callback function will be called with the * associated service response. * * @param request * The service request to send. * @param cb * The callback used when the associated response comes back. */ public void callService(ServiceRequest request, ServiceCallback cb) { // construct the unique ID String callServceId = "call_service:" + this.name + ":" + this.ros.nextId(); // register the callback function this.ros.registerServiceCallback(callServceId, cb); // build and send the rosbridge call JsonObject call = Json.createObjectBuilder() .add(JRosbridge.FIELD_OP, JRosbridge.OP_CODE_CALL_SERVICE) .add(JRosbridge.FIELD_ID, callServceId) .add(JRosbridge.FIELD_TYPE, this.type) .add(JRosbridge.FIELD_SERVICE, this.name) .add(JRosbridge.FIELD_ARGS, request.toJsonObject()).build(); this.ros.send(call); }