Designing a flight control system using a genetic algorithm instead of a predetermined mathematical model.

Two of the three robots used for testing of the Evolving Altitude Robot. Image by Author


The purpose of the study was to design a flight control system with no pre-determined mathematical model, but instead using a genetic algorithm to maintain the optimal altitude. The study is done through a quantitative empirical research method. In the process of conducting the research, we found that programming a genetic algorithm was cumbersome for novice users to implement. Due to this, we created and released an open-source Python package called EasyGA.

An initial population of 15 chromosomes, 10 genes per chromosome with 100 generations, were used during one trial. The throttle value of the device had an associated gene…

To keep my promise, here is all the code you will need to get your first genetic algorithm working with the EasyGA package.

pip3 install EasyGA

Run the code below in a python file anywhere on your computer.

import EasyGA

# Create the Genetic algorithm
ga = EasyGA.GA()

# Evolve the genetic algorithm until termination has been reached

# Print out the current generation and the population


Current Generation      : 15
Current population:
Chromosome - 0 [7][4][4][5][3][5][5][8][3][7] / Fitness = 3
Chromosome - 1 [7][4][4][5][3][5][5][8][3][7] / Fitness = 3
Chromosome - 2 [7][4][4][5][3][5][5][8][3][7] / Fitness…

A quick and easy way to setup your first python package. All code needed is included in the tutorial.

Illustration comes from

File structure needed:

For our example we will be making the EasyNumberMNIST package. Below is the file and folder structure:

├── EasyNumberMNIST
│ ├──
│ └──

To make the tree output clear, you will need a folder with 2 files and 1 folder in the main directory of your overall folder. The following files need to be created inside the main folder:,, and a folder with the name of your package. Inside the package folder you will need the name of your main python file and an file.

There is a lot of…

As of right now there is not that many good tutorials teaching those new to python / raspberry pi how to control a stepper motor. In this tutorial your going to learn how to control a stepper motor using a Raspberry PI, TB6600 stepper motor controller and Python.

I love to show examples first for people like me who don't want to read too much. Here is the wiring diagram and code used in this tutorial.

Wiring Diagram:

Wiring diagram to control a Nema 23 stepper motor using python,TB6600 and Raspberry PI.


All the code can be found here or at the bottom of the article.

Breakdown: Hardware Setup and Code:

This tutorial can be broken down into two sections. First…

A fun and easy way to learn about genetic algorithms by cracking a password.

EasyGA Python Package

So lets get straight to it.

pip3 install EasyGA

Now you have access to the EasyGA package. If you’ve never used it before I would check out the wiki or the getting started with EasyGA article that was created. They use the popular game among us to explain some of the novice features. Now were going to try and crack the password: EasyGA. Yup the worst password ever but it proves the point here.

Here is all the code we will need.

import EasyGA
import random
#Create the Genetic Algorithm
ga = EasyGA.GA()

Daniel Wilczak

Dedicated college student who loves to write simple code for everyone. Passion to make machine learning for everyone.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store