Flight Computer with c++

The Rocketry Forum

Help Support The Rocketry Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

William Carter

Active Member
Joined
Oct 12, 2020
Messages
34
Reaction score
6
Hello. I want to build my own flight computer with some simple sensors on board to start out. I have read a lot about Arduino, which at first for me sounded good. However, I read its not c++, more of a mutant version of it. If I want to code a flight computer with c++ (and not the 'mutant' version arduino), how would I go about this. I can't find anything online about controlling hardware or flight computers with anything other than Raspberry Pi (Python) or Arduino.
 
It's going to depend a lot on how much work you want to do and how many skills you want to learn.

Arduino is quite underpowered for it's weight and size (in terms of how much memory and CPU power you get), and it's kind of idiosyncratic, as you have noted. But there's a lot of software and user support out there for it.

Raspberry Pi are very capable, you can do almost anything with one of them you could do with a small PC. If you want the experience of programming applications like you would for a "normal" computer they might be a good choice. For example, you can run GCC on one, with full C++ support. But they're kind of large and power hungry for some applications. It might depend on how big your rockets are going to be.

There are gazillions of other embedded computing platforms which have varying degrees of C and C++ support, which have their own quirks and rough edges. Researching which is best can be a long and glorious journey.

Some questions to narrow down your path:
  • how physically big can your computer be?
  • how do you plan to attach sensors? Are you comfortable with selecting components and soldering? Fabricating your own circuit board? Or do you need something with easy to plug connectors?
  • are you comfortable implementing your own architecture and algorithms for the flight computer if literally all you have is a computer with a C++ compiler, or do you need some existing libraries or sample code for that stuff?
  • are you comfortable working in a memory-constrained environment where you have to be very conscious of every byte you allocate with new, or do you want an environment where you can write as if you're on a big PC-like platform and mostly worry just about code that's easy to maintain and correct but not necessarily highly tuned?
 
The arduino system is just a wrapper around the compiler. I use the ARM version of the gcc compiler with the Teensy 3.6 without the arduino stuff. I could of course go full C++ but I wouldn't. C++ drags a lot of stuff along and the code can get bloated. Not the code you write but the assembly code (and libraries) generated.

I can't think of anything that C++ does that you really need.
 
Have you considered using ArduPilot as a starting point? It used to be arduino-based but nowadays it is coded natively in C and a few other languages. They already have guidance solutions for vehicles using DCM or Kalman filtering. You might be able to learn something from the code anyway :). It is fully open-source.
www.ardupilot.org
 
Last edited:
The original arduino boards were very limiting, but they have advanced a lot in the past few years. The teensy 4.0 (or 4.1 with SD card) feels like a super computer, compared to the early days. On the teensy 4.0 I can get 284 million instructions a second (e.g. incrementing an integer) in my benchmarks. In addition, I can have eight different loops multi-tasking and it has all the I/O you would ever need in a flight computer (I2C, SPI, Serial, etc). As David says, you can use the arduino IDE or your IDE of choice, but I've found there is a lot of support for the Arduino IDE and it is easy to run or adapt just about any C library. Every IDE will have its own idiosyncrasies.
 
Thank you everyone!
To be clear the reason I want to learn c++ because in every aerospace engineer job description you need to know C++,C, and Matlab (which is requires advanced math and is more for analysis.)

These are the answers to these questions:
  • how physically big can your computer be?
  • It can be about 4 inches wide and the height can be as tall as long as the rocket keeps stable and it doesn't interfere with anything.
  • how do you plan to attach sensors? Are you comfortable with selecting components and soldering? Fabricating your own circuit board? Or do you need something with easy to plug connectors?
  • I have been learning soldering. I plan to select components then solder them onto a custom designed pcb.
  • are you comfortable implementing your own architecture and algorithms for the flight computer if literally all you have is a computer with a C++ compiler, or do you need some existing libraries or sample code for that stuff?
  • I would do both. The thing is I would rather not use libraries because I want to stay as close to I guess you could say vanilla c++ as possible. The only reason I say this is because I see people advertise their coding languages with libraries as c++ and it looks nothings like c++.
  • are you comfortable working in a memory-constrained environment where you have to be very conscious of every byte you allocate with new, or do you want an environment where you can write as if you're on a big PC-like platform and mostly worry just about code that's easy to maintain and correct but not necessarily highly tuned?
  • I would want an enviroment where I dont have to think and worry about conserving memory
 
Last edited:
So what I'm seeing is I should use either a Raspberry Pi or Teensy.

Which one is better?

Also is there any way to learn how to do this? I see some videos on YouTube about c++ in raspberry pi, but barley any for teensy 4.1.

The problem for me is there are no tutorials. There are hundreds of tutorials for Arduinos Unos or Nanos, but there are very little for using c++ on a raspberry pi or a teensy. I'm fully committed to making a flight computer and coding it with c++, and everyone here has helped me, but I don't know how and where to learn how to code c++ for the board/microcontroller I pick.
 
With pi you are installing an OS and are further abstracted from hardware. Using any of the micros you install an integrated development environment on your computer and use the computer to compile and download code to your micro. The micro doesn't do anything except run your code, while the pi is doing many other things.

We teach our into to c++ course for engineers using a variety of different micros (Atmel, arm, microchip, esperiff) and IDEs from the different companies AND the arduino IDE. gcc is the same throughout. We use a web based compiler for class projects but use the arduino compiler for labs. I'm partial to whatever board I can buy 30 of cheaply with usb and easy breadboard integration.

We use intro to engineering problem solving with c++ by etter as the text. A popular final class project is to fabricate and program a flight computer with telemetry that provides realtime data when it flies on one of the rocket team L1 cert flights.
 
Hello. I want to build my own flight computer with some simple sensors on board to start out. I have read a lot about Arduino, which at first for me sounded good. However, I read its not c++, more of a mutant version of it. If I want to code a flight computer with c++ (and not the 'mutant' version arduino), how would I go about this. I can't find anything online about controlling hardware or flight computers with anything other than Raspberry Pi (Python) or Arduino.
I’m using the STM32F “Blue Pill” for my flight computer with the Arduino IDE.

Its amazingly powerful, smaller, costs under $20, and fully works with all of the GPS, altimeter, SD card, inertial guidance 9dof accelerometers, and 915Mhz transmitter modules and their Arduino C++ libraries. As a former professional firmware developer, that’s all I could ask for for a hobby project.

Unless you have years with C/C++, the Arduino IDE greatly simplifies things for you and the added *.h and *.cpp code files to a project are true C++. Under the hood, all of the libraries you use for every added module are C++, with full classes and inheritance.

The Arduino IDE hides the C++ details from most users who would be lost with it, and its the pain to access with Notepad++, but its fully supported.

I’d also be interested in an Eclipse firmware development platform that could be used to “#include” the “Arduino pde” and all of the C++ libraries into a full buildable project with the same firmware footprint that the Arduino IDE generates. That would permit the full code navigation, compiling and debugging with breakpoints, single-stepping that I was familiar with as a professional firmware engineer. I’d bet dollar to doughnuts that people who professionally develop the complex code libraries for Arduino modules don’t shackle themselves with the limitations of the Arduino IDE, except for the final release test phase.
 
Thank you everyone!
To be clear the reason I want to learn c++ because in every aerospace engineer job description you need to know C++,C, and Matlab (which is requires advanced math and is more for analysis.)

These are the answers to these questions:
  • how physically big can your computer be?
  • It can be about 4 inches wide and the height can be as tall as long as the rocket keeps stable and it doesn't interfere with anything.
  • how do you plan to attach sensors? Are you comfortable with selecting components and soldering? Fabricating your own circuit board? Or do you need something with easy to plug connectors?
  • I have been learning soldering. I plan to select components then solder them onto a custom designed pcb.
  • are you comfortable implementing your own architecture and algorithms for the flight computer if literally all you have is a computer with a C++ compiler, or do you need some existing libraries or sample code for that stuff?
  • I would do both. The thing is I would rather not use libraries because I want to stay as close to I guess you could say vanilla c++ as possible. The only reason I say this is because I see people advertise their coding languages with libraries as c++ and it looks nothings like c++.
  • are you comfortable working in a memory-constrained environment where you have to be very conscious of every byte you allocate with new, or do you want an environment where you can write as if you're on a big PC-like platform and mostly worry just about code that's easy to maintain and correct but not necessarily highly tuned?
  • I would want an enviroment where I dont have to think and worry about conserving memory
I’m a retired engineer who spent at least half of my 40 year career writing C/C++ professionally.

It took several years in the 80s to break into the field of C/C++ programming, even though I had spent years studying C/C++ as a hobbyist with my own computer, and with a bookshelf of the best books on the subject. It finally happened when I was working for a small company as a process control engineer and had the opportunity to take over the C development part of the project that was being done by another programmer who quit.

But I need to warn you. The managers of most jobs that require C/C++ know the language and practice well, and test all applicants to see if they really know how to code at a professional level. Working as part of a team with other programmers or adding new features or debugging large C/C++ projects with hundreds of linked source files is much different than working on a simple rocket flight computer project.
 
Ok thanks for the advice Mr. Griffing. For an aspiring Aerospace Engineer who will need to know c++ to control hardware and software, what's the best way to learn how to do that.
 
Ok thanks for the advice Mr. Griffing. For an aspiring Aerospace Engineer who will need to know c++ to control hardware and software, what's the best way to learn how to do that.
My further advice would be to do C/C++ course work, and/or attend C/C++ conferences and training seminars. My favorites were the yearly Software Development Conferences in the SF Masconi Center where Bjarne Stroustrup, James Coplien, or Alexander Stepanov would typically spreak, along with other famous programmer/authors in the field. Such conferences are great places to get to know people and make professional C/C++ programming contacts. You’re in a rarified atmosphere in a small seminar hearing people like these speak and being able to understand them.

Its also important to realize that the normal, journeyman-level of a C/C++ programming job on a big project is a lot different than just knowing the language. In such a job the main architecture and class definitions have already been defined, and most of the work is understanding and working on a team within that context. Its also important to have internalized the understanding and use of C/C++ so that you can focus on the problem-space rather than the programming techniques.

If you are already an aerospace engineer who qualifies for a job on an engineering project team where there are C/C++ programming engineers, there might be an option where you can demonstrate your C/C++ programming skills and can gradually gain those as your a part of your job. Another option might be as an engineer whose job is to do software testing the C/C++ applications where detailed aerospace functionality knowledge is needed. In that role you get to know the software development team and can transition into a software job that way.

But you may discover that you have more to offer as an aerospace engineer than as a C/C++ programmer.
 
Back
Top