SDK Tutorial
A quick start guide for the Flyby SDK.
Download & Setup
The latest SDK release can be found here, and an example project can be found here.
The simplest way to get starting is by copying the example project structure and CMake file.
For this example, we will assume we have a payload that is composed of a single camera on a gimbal, and the camera produces one video stream.
Getting Started
The main entry point into the drone ecosystem is through the Drone
object. This object is how our new payload register itself with the drone and make itself available to the controller.
To create a new Drone
object, we use the DroneFactory::create_drone()
method. This returns a new shared_ptr
to the Drone
object.
Now that we have access to the drone, the next step is creating the Payload
object.
Payload
Every payload has to inherit from the flyby::Payload
object. Our new payload class should call the following base constructor:
The Payload
object will contain all of our payload components, is solely responsible for creating these components. Payloads are composed of streams and components such as gimbals.
We can now register our payload object with the drone.
Since our payload does not contain any components, we have no way of interacting with it through the controller. Let's fix that.
Components
Every payload component should inherit from its corresponding class. For example, cameras should inherit from Camera
, and gimbals should inherit from Gimbal
. The main responsibility of these objects is to connect the controller to the hardware, and we do so by overriding functionality that the hardware can provide. For example, a camera that can take pictures should override the take_picture
function, and that function should take a picture on the corresponding camera.
Gimbal
All gimbals should inherit from the Gimbal
object. Gimbals are controlled through the controller, which sends roll, pitch, and yaw values for the gimbal. The controller displays the current gimbal pitch, and so the gimbal class should override the get_pitch
function. In order for the controller to control the gimbal's movements, it should also override the set_roll_pitch_yaw_speed
function.
We can now revisit the SimplePayload
constructor to include our new gimbal.
Camera & Stream
Streams are composed of cameras, so let us focus on the camera object first. Similar to gimbals, cameras should inherit from the Camera
object and implement the functionality that they provide.
Suppose our camera can take videos, but does not have any picture functionality or zoom functionality. For video controls, we will set m_video = true
, and set the other two to false. Since our camera is mounted on our gimbal, we will set m_gimbal = true
so that, while viewing this camera's stream, we will be able to control the gimbal through the controller. These settings correspond to the UI visibility on the controller.
This camera object tells the controller that this camera is mounted on a gimbal and can take videos, and when the user presses the video buttons the controller they trigger the overriden functions that are present above.
With our camera object implemented, we can now focus on the stream. Streams are responsible for creating and owning their own camera objects, and starting some streaming method. For the former, we create our camera object in the constructor and register it with the stream.
With our stream object configured and our cameras set up, all that is left is to start an actual stream. The stream object will get a new endpoint to publish a stream to, and is responsible to specify when the stream is alive. We do this by overriding the start_stream
function.
Lastly, we update the payload constructor to register this stream as follows:
Finally, we have created and registered all of the relevant payload components. All that is left to do is to start the payload server.
Last updated