theFramework | The Tangram Flex Blog

Under the Hood: Building a MAV/PX4 Ground Control Station with Tangram Maker

Written by Grayson Rodriguez | Jun 02, 2022

In this edition of our Behind the Scenes blog series, Grayson Rodriguez, Product Support Specialist and steward of tutorials and DIY Tangram Maker™ projects, shares his most recent experiment, setting out to control a drone programmatically with MAVLink commands. Grayson combines his background in high-level applied math (he’s a published expert in eastern cicada killer wasps — no joke) with his talent for learning and applying new technology through self-taught coding and some good old-fashioned elbow grease to our team here at Tangram Flex. The best part? He brings everyone along for the ride. If you’re interested in trying out Grayson’s project on your own check it out on Github.

A few weeks ago I set out to control a drone programmatically with MAVLink commands. With the help of Tangram Maker™, I was able to connect to a simulated drone on my computer and send it a flight plan. It was a breeze. You know that feeling you get when you jump into new technology and it just works? That’s how I felt when the drone took flight.

I had created my own PX4-compatible ground control station in less than two hours. And really, most of that time was spent setting up a Linux virtual machine and installing PX4. Tangram Maker is accessible online so I didn’t have to install anything for that. Before I started on this project, one of our software engineers shared a simple, single-file C++ application with me. This helped me get started, but I had a lot of knowledge gaps.

Tangram Maker eliminated some technical hurdles for me. Admittedly, I know next to nothing about writing communications code, and I’m a beginner with C++ (learning more every day). It did a lot of development work for me, like I had another software engineer working with me who is an expert in MAVLink, data types and transferring messages between software components. Tangram Maker™ generated an interface and I focused on programming the logic for my ground control station. It also handled package dependencies.

It was easy to visualize my system in Tangram Maker™ before getting into code. To start, I created a component to represent my ground control station (GCS) and a component to represent a drone, and connected MAVLink messages between them.

Next, I generated C++ code from my GCS component and compiled it on the web.

This process transpiled all the MAVLink messages I used in my design into C++ objects (as well as all of their child objects/classes). It also generated an API layer that includes a MAVLink serializer. The message definitions and API together make up the generated interface. The interface is shown in the diagram below as two blue boxes.

The generated interface includes get and set methods, as well as functions I can call to serialize or deserialize MAVLink command messages and send the data to a PX4 socket. This process converts the messages into packets of bytes formatted according to MAVLink’s over-the-wire specifications.

To test out my code, all I had to do was start the PX4 SITL (“software in the loop simulation”) in my Linux virtual machine and run my mission C++ app. And voila!

Now that my test environment is set up, I can make changes in Tangram Maker™ and/or my C++ app, and fly new code in a matter of minutes. It’s made the learning process easier and quicker. Experimenting and testing new code in increments helps me learn, and I was able to do just that . Additionally, it was convenient not to have to pay for anything or enter a credit card for a trial; all the tools I’m using are free.

Try It Yourself

I’ve put together all the steps so that you can follow along and create your own ground control station. Check it out here on GitHub.

If you want to try out Tangram Maker on your own first, sign up for a free account at https://tangramflex.com/tangram-maker and check out the tutorials on Tangram’s docs site to get started. I’m the moderator on our forum, https://discuss.tangramflex.io/ and am always happy to hear what you’re working on and help through problems.

Tangram Flex is a product-driven software company that provides custom service and expertise in system modernization, integration, assurance, and autonomy. We believe every mission deserves access to innovation, and so we deliver software research, prototypes, services, and products that enable rapid integration with confidence.

Tangram Flex has experience from DoD, Fortune 50 companies, and innovative software startups. We are dedicated to walking alongside our customers to keep pace with changes in technology. To get in touch, drop a note at https://tangramflex.com/contact