Publish command via Websocket in Java


Was able to setup topic’s and subscribe to Telemtry endpoints using FlytSDK via websocket without any issues.
Things are harder now that I want to switch from Rest driven request do websocket.
I want to trigger the ‘takeoff’ command via websocket in order to wait for the finished result.

The topic instantiation looks like:
val t = Topic(ros,"/flytsim/navigation/take_off",“core_api/TakeOff”,2000)
later on int the code I try to publish my request via:

Flytsim Docker prompts:
flytsim ==> “publish: Cannot infer topic type for topic /flytsim/navigation/take_off as it is not yet advertised”

Everything compiles and as mentioned before, I can subscribe to topics and process feedback via callbacks. What I am not getting clearly is how to send commands over and wait for a proper result.

Thanks for your help


Hi @tmaus,

instead of calling publish() function, there should be a service().
I will update this thread once I go through the SDK again.



TakeOff is a ROS Service call and cannot be called via ‘publish’ function as it is only for ROS Topics.

The SDK does not have the above call definition.
Handling Service response has still not been coded yet.

But one can define the following function:

public void callService(String service_name, JSONObject req, CallbackRos cb) {
this.ros.registerTopicCallback(service_name, cb);
this.callbacks.add(cb); = new JSONObject();
try {“op”, “call_service”);“service”, service_name);“args”, req);
} catch (JSONException error) {

This would call the service but not fetch the response.
Please refer this guide for more details.


I will try to update SDK and add this feature, but I cannot mention a timeline for this.