Websocket URL Question


#1

Hello,

Can you provide me with the proper Websocket URL for Flytsim cloud? Thank you!


#2

Hi Kyle,

http://docs.flytbase.com/docs/FlytAPI/REST_WebsocketAPIs.html#telemetry-apis

  • The link has the sample code for websocket code for flytsim and documentation of websocket APIs.
  • The url for websocket is wss://flytsim.flytbase.com/websocket .
  • A sample project for websocket is here. Login to flytsim.flytbase.com and make sure your drone is in air by clicking on take-off then login to the sample project and you will find the data being printed in the console.

#3

Great, thank you so much, that answered my question


#4

I’m running the example program you sent (unmodified) and in console it says that the login was successful, but the Websocket opens and then instantly closes. I tried logging out and then logging back in as well as respawning with no luck. Thanks!

EDIT: I’m using Chrome


#5

Hi Kyle,

It seems even I could replicate the same for me. @vallabh please take a look at this.


#6

Hi Kyle,
There was a bug that has been resolved now. So everything should be working as expected.


#7

Hi all!
First time for me in this forum, we started up with flytbase last week my company.
I have started to use the cloud simulator, and can send rest calls that is fine. But for websocket i have problems.

Is the answers in this thread still valid for virtual drone connection in cloud?
I must use: wss://dev.flytbase.com/websocket to be able to open the socket, the one suggested?
(in the setup documentation for cloud this url is suggested : https://dev.flytbase.com/websocket)
However it is closed immediately afterwards, seems like same problem srv and kylefoley experienced also.

Hope anyone can help me forward with my issue, thanks!

best regards
Sebastian


#8

@SebastianW Above discussion is regarding websocket on local network. For cloud access you need to send your authentication details (API key and vehicle ID) as described in documentation.

If you are using Javascript and roslibjs then following code snippet will work.

// Establishing websocket connection 
ros = new ROSLIB.Ros({
      url : 'https://dev.flytbase.com/websocket'
    });

ros.on('connection', function() {
      console.log('Connected to websocket server.');
      setTimeout(function(){socketCallback();},2000);
    });

var rauth = new ROSLIB.Message({
         "Authorization": "Token 894553f4851dc1171srt7y75fe9916c56yh87yui",
         "VehicleID" : "fRweRTFA"
     });

ros.authenticate(rauth);

#9

We will get the documentation for websocket out soon.

An example call to subscribe to local position is given below to get started with.

// Subscribing to Local Position data
function socketCallback(){
  var lpos = new ROSLIB.Service({
    ros : ros,
    name : '/<namespace>/mavros/local_position/local',
    messageType : 'geometry_msgs/TwistStamped',
    throttle_rate: 200
  });

  var request = new ROSLIB.ServiceRequest({});

  lpos.subscribe(request, function(result) {
      console.log(result.twist);
  });
}

#10

Thank you @Dhirajd so much for your help! Than I understand, i misunderstood what was meant with flytsim (cloud).
I got it to work with you answer, perfect!

/Sebastian


#11