/** * Unregisters as service advertiser. */ public void unadvertiseService() { this.ros.deregisterCallServiceCallback(this.name); // build and send the rosbridge call JsonObject call = Json.createObjectBuilder() .add(JRosbridge.FIELD_OP, JRosbridge.OP_CODE_UNADVERTISE_SERVICE) .add(JRosbridge.FIELD_SERVICE, this.name).build(); this.ros.send(call); // set the flag indicating we are registered this.isAdvertised = false; }
/** * Unregister as a publisher for the topic. */ public void unadvertise() { // build and send the rosbridge call String unadvertiseId = "unadvertise:" + this.name + ":" + this.ros.nextId(); JsonObject call = Json.createObjectBuilder() .add(JRosbridge.FIELD_OP, JRosbridge.OP_CODE_UNADVERTISE) .add(JRosbridge.FIELD_ID, unadvertiseId) .add(JRosbridge.FIELD_TOPIC, this.name).build(); this.ros.send(call); // set the flag indicating we are no longer registered this.isAdvertised = false; }
/** * Unregister as a publisher for the topic. */ public void unadvertise() { // build and send the rosbridge call String unadvertiseId = "unadvertise:" + this.name + ":" + this.ros.nextId(); JsonObject call = Json.createObjectBuilder() .add(JRosbridge.FIELD_OP, JRosbridge.OP_CODE_UNADVERTISE) .add(JRosbridge.FIELD_ID, unadvertiseId) .add(JRosbridge.FIELD_TOPIC, this.name).build(); this.ros.send(call); // set the flag indicating we are no longer registered this.isAdvertised = false; }
/** * Unregisters as service advertiser. */ public void unadvertiseService() { this.ros.deregisterCallServiceCallback(this.name); // build and send the rosbridge call JsonObject call = Json.createObjectBuilder() .add(JRosbridge.FIELD_OP, JRosbridge.OP_CODE_UNADVERTISE_SERVICE) .add(JRosbridge.FIELD_SERVICE, this.name).build(); this.ros.send(call); // set the flag indicating we are registered this.isAdvertised = false; }
/** * Registers as service advertiser. * * @param cb the cb */ public void advertiseService(CallServiceCallback cb) { // register the callback this.ros.registerCallServiceCallback(this.name, cb); // build and send the rosbridge call JsonObject call = Json.createObjectBuilder() .add(JRosbridge.FIELD_OP, JRosbridge.OP_CODE_ADVERTISE_SERVICE) .add(JRosbridge.FIELD_TYPE, this.type) .add(JRosbridge.FIELD_SERVICE, this.name).build(); this.ros.send(call); // set the flag indicating we are registered this.isAdvertised = true; }
/** * Registers as service advertiser. */ public void advertiseService(CallServiceCallback cb) { // register the callback this.ros.registerCallServiceCallback(this.name, cb); // build and send the rosbridge call JsonObject call = Json.createObjectBuilder() .add(JRosbridge.FIELD_OP, JRosbridge.OP_CODE_ADVERTISE_SERVICE) .add(JRosbridge.FIELD_TYPE, this.type) .add(JRosbridge.FIELD_SERVICE, this.name).build(); this.ros.send(call); // set the flag indicating we are registered this.isAdvertised = true; }
/** * Registers as a publisher for the topic. This call will be automatically * called by publish if you do not explicitly call it. */ public void advertise() { // build and send the rosbridge call String advertiseId = "advertise:" + this.name + ":" + this.ros.nextId(); JsonObject call = Json.createObjectBuilder() .add(JRosbridge.FIELD_OP, JRosbridge.OP_CODE_ADVERTISE) .add(JRosbridge.FIELD_ID, advertiseId) .add(JRosbridge.FIELD_TYPE, this.type) .add(JRosbridge.FIELD_TOPIC, this.name).build(); this.ros.send(call); // set the flag indicating we are registered this.isAdvertised = true; }
/** * Registers as a publisher for the topic. This call will be automatically * called by publish if you do not explicitly call it. */ public void advertise() { // build and send the rosbridge call String advertiseId = "advertise:" + this.name + ":" + this.ros.nextId(); JsonObject call = Json.createObjectBuilder() .add(JRosbridge.FIELD_OP, JRosbridge.OP_CODE_ADVERTISE) .add(JRosbridge.FIELD_ID, advertiseId) .add(JRosbridge.FIELD_TYPE, this.type) .add(JRosbridge.FIELD_TOPIC, this.name).build(); this.ros.send(call); // set the flag indicating we are registered this.isAdvertised = true; }
.add(JRosbridge.FIELD_LEVEL, level) .add(JRosbridge.FIELD_END_TIME, end).build(); this.send(call);
/** * Unregisters as a subscriber for the topic. Unsubscribing will remove all * the associated subscribe callbacks. */ public void unsubscribe() { // remove this object's associated callbacks. for (TopicCallback cb : this.callbacks) { this.ros.deregisterTopicCallback(this.name, cb); } this.callbacks.clear(); // build and send the rosbridge calls for (String id : this.ids) { JsonObject call = Json.createObjectBuilder() .add(JRosbridge.FIELD_OP, JRosbridge.OP_CODE_UNSUBSCRIBE) .add(JRosbridge.FIELD_ID, id) .add(JRosbridge.FIELD_TOPIC, this.name).build(); this.ros.send(call); } // set the flag indicating we are not longer subscribed this.isSubscribed = false; }
.add(JRosbridge.FIELD_LEVEL, level) .add(JRosbridge.FIELD_END_TIME, end).build(); this.send(call);
/** * Unregisters as a subscriber for the topic. Unsubscribing will remove all * the associated subscribe callbacks. */ public void unsubscribe() { // remove this object's associated callbacks. for (TopicCallback cb : this.callbacks) { this.ros.deregisterTopicCallback(this.name, cb); } this.callbacks.clear(); // build and send the rosbridge calls for (String id : this.ids) { JsonObject call = Json.createObjectBuilder() .add(JRosbridge.FIELD_OP, JRosbridge.OP_CODE_UNSUBSCRIBE) .add(JRosbridge.FIELD_ID, id) .add(JRosbridge.FIELD_TOPIC, this.name).build(); this.ros.send(call); } // set the flag indicating we are not longer subscribed this.isSubscribed = false; }
/** * 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); }
/** * 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); }
/** * Subscribe to this topic. A callback function is required and will be * called with any incoming message for this topic. * * @param cb * The callback that will be called when incoming messages are * received. */ public void subscribe(TopicCallback cb) { // register the callback function this.ros.registerTopicCallback(this.name, cb); // internal reference used during unsubscribe this.callbacks.add(cb); String subscribeId = "subscribe:" + this.name + ":" + this.ros.nextId(); this.ids.add(subscribeId); // build and send the rosbridge call JsonObject call = Json.createObjectBuilder() .add(JRosbridge.FIELD_OP, JRosbridge.OP_CODE_SUBSCRIBE) .add(JRosbridge.FIELD_ID, subscribeId) .add(JRosbridge.FIELD_TYPE, this.type) .add(JRosbridge.FIELD_TOPIC, this.name) .add(JRosbridge.FIELD_COMPRESSION, this.compression.toString()) .add(JRosbridge.FIELD_THROTTLE_RATE, this.throttleRate).build(); this.ros.send(call); // set the flag indicating we have subscribed this.isSubscribed = true; }
/** * 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); }
/** * Subscribe to this topic. A callback function is required and will be * called with any incoming message for this topic. * * @param cb * The callback that will be called when incoming messages are * received. */ public void subscribe(TopicCallback cb) { // register the callback function this.ros.registerTopicCallback(this.name, cb); // internal reference used during unsubscribe this.callbacks.add(cb); String subscribeId = "subscribe:" + this.name + ":" + this.ros.nextId(); this.ids.add(subscribeId); // build and send the rosbridge call JsonObject call = Json.createObjectBuilder() .add(JRosbridge.FIELD_OP, JRosbridge.OP_CODE_SUBSCRIBE) .add(JRosbridge.FIELD_ID, subscribeId) .add(JRosbridge.FIELD_TYPE, this.type) .add(JRosbridge.FIELD_TOPIC, this.name) .add(JRosbridge.FIELD_COMPRESSION, this.compression.toString()) .add(JRosbridge.FIELD_THROTTLE_RATE, this.throttleRate).build(); this.ros.send(call); // set the flag indicating we have subscribed this.isSubscribed = true; }
/** * 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); }
/** * Publish the given message to ROS on this topic. If the topic is not * advertised, it will be advertised first. * * @param message * The message to publish. */ public void publish(Message message) { // check if we have advertised yet. if (!this.isAdvertised()) { this.advertise(); } // build and send the rosbridge call String publishId = "publish:" + this.name + ":" + this.ros.nextId(); JsonObject call = Json.createObjectBuilder() .add(JRosbridge.FIELD_OP, JRosbridge.OP_CODE_PUBLISH) .add(JRosbridge.FIELD_ID, publishId) .add(JRosbridge.FIELD_TOPIC, this.name) .add(JRosbridge.FIELD_MESSAGE, message.toJsonObject()).build(); this.ros.send(call); } }
/** * Publish the given message to ROS on this topic. If the topic is not * advertised, it will be advertised first. * * @param message * The message to publish. */ public void publish(Message message) { // check if we have advertised yet. if (!this.isAdvertised()) { this.advertise(); } // build and send the rosbridge call String publishId = "publish:" + this.name + ":" + this.ros.nextId(); JsonObject call = Json.createObjectBuilder() .add(JRosbridge.FIELD_OP, JRosbridge.OP_CODE_PUBLISH) .add(JRosbridge.FIELD_ID, publishId) .add(JRosbridge.FIELD_TOPIC, this.name) .add(JRosbridge.FIELD_MESSAGE, message.toJsonObject()).build(); this.ros.send(call); } }