-
Notifications
You must be signed in to change notification settings - Fork 3
Connecting the Drone to the Server
Connect to the server from the drone control app using websocket. See the example of a simple Python client script. The script reads a text file containing pre-recorded flight data (see the example file) and sends the data to the server. The procedure is to handshake with the server, where the server assigns a unique ID, which needs to be used in the following communication.
-
Send a JSON message with the following structure:
{ "type":"hello", "data":{ "ctype":0, "drone_name":"MavicPro", "serial":"12345" } }
where
ctype
is 0 for the drone, or 1 for the visualization client,drone_name
is the type of the drone (e.g. MavicPro, Phantom, Matrice, etc.), andserial
is the drone serial number (optional parameter). -
Receive a JSON message with the following structure:
{ "type":"hello_resp", "data":{ "client_id":"41f28cb6", "rtmp_port":1935 } }
where
client_id
is an auto-generated unique 8-digit hex string, which the drone needs to use as its unique ID in the following communication, andrtmp_port
is port to RTMP server. Drone should use RTMP URI address in following format for streaming media:rtmp://<host>[:<port>]/live/<client_id>
where
host
is hostname or address of server. RTMP serverport
andclient_id
are received from hello response message.
After the handshake, the drone can start broadcasting its flight data. The JSON message is expected to have the following structure:
{
"type":"data_broadcast",
"data":{
"client_id":"41f28cb6",
"altitude":234.6,
"gps":{
"latitude":49.24031521243185,
"longitude":16.613207555321484
},
"aircraft_orientation":{
"pitch":-4.0,
"roll":-1.2,
"yaw":81.2,
"compass":81.2
},
"aircraft_velocity":{
"velocity_x":0.1,
"velocity_y":1.0,
"velocity_z":0.1
},
"gimbal_orientation":{
"pitch":0.0,
"roll":0.0,
"yaw":81.1,
"yaw_relative":0.0
},
"timestamp":"2023-04-05 14:45:06.843",
"frame":"$jpeg_string_encoded_to_base64"
}
}
where the client_id
needs to be the same ID assigned in the handshake phase. To visualize the drone in the DroCo client, the mandatory data are altitude
, gps
, and aircraft_orientation
.