In preparation for the SpaceX Crew Dragon’s first crewed mission Demo-2 in late May, SpaceX released a pretty cool little WebGL docking simulator, featuring the Dragon spacecraft. After getting the docking done successfully a few times, I realised this is a perfect opportunity to write a docking autopilot! How does one even approach a problem like this?
In preparation for the SpaceX Crew Dragon’s first crewed mission Demo-2 in late May, SpaceX released a pretty cool little WebGL docking simulator, featuring the Dragon spacecraft. After getting the docking done successfully a few times, I realised this is a perfect opportunity to write a docking autopilot! How does one even approach a problem like this?
An orbital spacecraft is a bit different from what you would consider a normal vehicle, like a car or an airplane. In space, you have all 6 Degrees of Freedom (DoF), meaning you can go up-down, left-right, roll clockwise-anti-clockwise etc.
That is great, but how do we actually dock?
In the context of the simulator, a successful docking means that:
If you break it down, the problem simply consists of aligning the Dragon how it should be (aligned with the ISS docking port), and flying it to where it should be (at the docking port) slowly.
For the language, I am using Clojure, a Lisp-like *functional programming *language that runs on the JVM. It is highly extensible, simple, with lots of libraries and powerful concurrency abstractions, which we will absolutely need later.
The first step is to obviously figure out how to *control *the simulator. The best way to drive the browser these days is using WebDriver, and some API or client library to send commands to and from it. On our side, all we have to do is create a control interface in our code. In the entire project I am using Etaoin, which is a fantastic pure Clojure implementation of the WebDriver protocol.
Functional Programming: Functional Programming is a Declarative style of Programming Paradigm for writing computer programs.
Are functions from programming really functions? If you are reading this, then most probably you already know quite well what functions are in programming.
Part 1 — Functional Programming Journey.What does it mean to program in a functional way? Well, code written that way is based on, yes you guessed it, functions…these functions are tiny chunks of code that do something specific with the data that was passed to them. And in comparison with the object-oriented programming paradigm, these functions can be passed as arguments to other functions, which will receive them, execute them, perform some other computations and then either return some value or may this function is passed as an argument to another one.
Functional Programming: Higher Order Functions. A Better Take on JavaScript’s Higher Order Functions. Functional Programming is awesome! It makes programming fun.
A monoid is fundamental to the functional programming world. For those interested in functional programming, I’ll talk about monoids and why they’re very important to understand ahead of time.