/** * Create a clone of this ServiceRequest. */ @Override public ServiceRequest clone() { return new ServiceRequest(this.toJsonObject(), this.serviceRequestType); } }
ServiceRequest request = new ServiceRequest(args); request.setId(id); cb.handleServiceCall(request);
/** * Create a new Empty ServiceRequest based on the given JSON string. Any * missing values will be set to their defaults. * * @param jsonString * The JSON string to parse. * @return A Empty ServiceRequest based on the given JSON string. */ public static Request fromJsonString(String jsonString) { // convert to a ServiceRequest return Empty.Request.fromServiceRequest(new ServiceRequest( jsonString)); }
/** * 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()); }
ServiceRequest request = new ServiceRequest(args); request.setId(id); cb.handleServiceCall(request);
/** * Create a new Empty ServiceRequest based on the given JSON string. Any * missing values will be set to their defaults. * * @param jsonString * The JSON string to parse. * @return A Empty ServiceRequest based on the given JSON string. */ public static Request fromJsonString(String jsonString) { // convert to a ServiceRequest return Empty.Request.fromServiceRequest(new ServiceRequest( jsonString)); }
/** * 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()); }
/** * Create a clone of this ServiceRequest. */ @Override public ServiceRequest clone() { return new ServiceRequest(this.toJsonObject(), this.serviceRequestType); } }
private String getMethodType(Ros ros, String topic) { Service addTwoInts = new Service(ros, "/rosapi/topic_type", "rosapi/TopicType"); ServiceRequest request = new ServiceRequest("{\"topic\": \""+ topic +"\"}"); ServiceResponse response = addTwoInts.callServiceAndWait(request); JSONObject ob = new JSONObject(response.toString()); return ob.getString("type"); }
/** * 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); }