How to create a custom API?


#1

Hi,
I would like create my own custom APIs and integrate it with the FlytOS. For example, I’m planning on using a charging station for my drone for which I want to create service packages integrated with FlytOS.
So I would like to know if there are any tutorials/how-to’s available for this.
Thanks in advance. :slight_smile:


#2

Hi @pranavn248,

Unfortunately, such a tutorial does not exist.
You can create your own ros packages and source it in bashrc.
Once done, if you would like to expose REST APIs over LAN, then add your service name to this file: “/flyt/flytos/flytcore/share/core_api/launch/core_api_rostful.launch”.

If you are running the latest FlytOS(v1.5-6), you can also create a file named ‘user.launch’ beside the above launch file and add your node into it. This would enable autolaunch of your node, when FlytOS boots up.

If you would like to expose these APIs over FlytCloud, please send us the API reference and we would check if we could add it to our cloud server.


#3

Hi,

Thanks for the reply.
I think I’m going to create rospy APIs, not REST. So, does it work the same way for this as well? Also, I’m not sure if I understood correctly, but is it possible for me to access the “code” for the APIs in your cloud? I mean, I wanna “edit” or atleast “read” the already existing APIs in FlytOS.
Thanks in advance.


#4

Please checkout api.flytbase.com for all of our API definition.

How are you planning to execute/call these APIs? via ros-service calls? If yes, then you can skip this step: Once done, if you would like to expose REST APIs over LAN, then add your service name to this file: “/flyt/flytos/flytcore/share/core_api/launch/core_api_rostful.launch”.

Also checkout this doc for Python Code developers


#5

Hi,

Blockquote Yes, I’m planning to use ros-service calls.
I checked out the API definition and I just have a small, silly question to ask.
I’m not sure how you’ve defined the “name” of the API, for example, in the API documentation, under Navigation, the Land API has a Name like “Name: //navigation/land” and Service Type like “core_api/Land”. Similarly, let’s say, if I want to create my own API for my charging station, for example, an API called DroneCharge, and I define the services that it performs, how do I create a Name and Service Type? Should I just call it under core_api? Where do I exactly save this ros service?
Sorry, I’m still a newbie trying to understand how APIs and ros works.
Thanks in advance.


#6

I would suggest you to go through ROS Tutorials and ROS Service Tutorial.

The second tutorial should help you in creating a ros-service. Service Name and Service type is also mentioned/explained over there.


#7

Thank you, I think I’ve understood quite a bit more now. This seems a bit helpful. However, would you be willing to review my sample code of creating a service API once I’m done. Just to make sure my overall structure looks correct?
Thanks in advance. :slight_smile:


#8

Sure no problem.
Just send me your code in this thread.