/** * Create a clone of this ServiceRequest. */ @Override public ServiceRequest clone() { return new ServiceRequest(this.toJsonObject(), this.serviceRequestType); } }
/** * Create a new Empty ServiceRequest based on the given ServiceRequest. * Any missing values will be set to their defaults. * * @param req the req * @return A Empty ServiceRequest based on the given Message. */ public static Request fromServiceRequest(ServiceRequest req) { // get it from the JSON object return Empty.Request.fromJsonObject(req.toJsonObject()); }
/** * Create a clone of this ServiceRequest. */ @Override public ServiceRequest clone() { return new ServiceRequest(this.toJsonObject(), this.serviceRequestType); } }
/** * Create a new Empty ServiceRequest based on the given ServiceRequest. * Any missing values will be set to their defaults. * * @param m * The ServiceRequest to parse. * @return A Empty ServiceRequest based on the given Message. */ public static Request fromServiceRequest(ServiceRequest req) { // get it from the JSON object return Empty.Request.fromJsonObject(req.toJsonObject()); }
/** * 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); }