/** * Create a clone of this ServiceResponse. */ @Override public ServiceResponse clone() { return new ServiceResponse(this.toJsonObject(), this.serviceResponseType, this.result); } }
/** * Send a service response. * * @param response * The service response to send. * @param id * The ID of the response (matching that of the service call). */ public void sendResponse(ServiceResponse response, String id) { // build and send the rosbridge call JsonObject call = Json.createObjectBuilder() .add(JRosbridge.FIELD_OP, JRosbridge.OP_CODE_SERVICE_RESPONSE) .add(JRosbridge.FIELD_ID, id) .add(JRosbridge.FIELD_SERVICE, this.name) .add(JRosbridge.FIELD_VALUES, response.toJsonObject()) .add(JRosbridge.FIELD_RESULT, response.getResult()).build(); this.ros.send(call); }
/** * Create a new Empty ServiceResponse 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 ServiceResponse based on the given JSON string. */ public static Response fromJsonString(String jsonString) { // convert to a ServiceResponse return Empty.Response.fromServiceResponse(new ServiceResponse( jsonString, true)); }
/** * Create a new Empty ServiceResponse based on the given * ServiceResponse. Any missing values will be set to their defaults. * * @param m * The ServiceResponse to parse. * @return A Empty ServiceResponse based on the given Message. */ public static Response fromServiceResponse(ServiceResponse resp) { // get it from the JSON object return Empty.Response.fromJsonObject(resp.toJsonObject()); }
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"); }
/** * Send a service response. * * @param response * The service response to send. * @param id * The ID of the response (matching that of the service call). */ public void sendResponse(ServiceResponse response, String id) { // build and send the rosbridge call JsonObject call = Json.createObjectBuilder() .add(JRosbridge.FIELD_OP, JRosbridge.OP_CODE_SERVICE_RESPONSE) .add(JRosbridge.FIELD_ID, id) .add(JRosbridge.FIELD_SERVICE, this.name) .add(JRosbridge.FIELD_VALUES, response.toJsonObject()) .add(JRosbridge.FIELD_RESULT, response.getResult()).build(); this.ros.send(call); }
/** * Create a new Empty ServiceResponse 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 ServiceResponse based on the given JSON string. */ public static Response fromJsonString(String jsonString) { // convert to a ServiceResponse return Empty.Response.fromServiceResponse(new ServiceResponse( jsonString, true)); }
/** * Create a new Empty ServiceResponse based on the given * ServiceResponse. Any missing values will be set to their defaults. * * @param resp the resp * @return A Empty ServiceResponse based on the given Message. */ public static Response fromServiceResponse(ServiceResponse resp) { // get it from the JSON object return Empty.Response.fromJsonObject(resp.toJsonObject()); }
/** * Create a clone of this ServiceResponse. */ @Override public ServiceResponse clone() { return new ServiceResponse(this.toJsonObject(), this.serviceResponseType, this.result); } }
ServiceResponse response = new ServiceResponse(values, success); cb.handleServiceResponse(response);
ServiceResponse response = new ServiceResponse(values, success); cb.handleServiceResponse(response);