https://github.com/mbertschler/dragon-iss-docking-autopilot
Autopilot in Go for docking the SpaceX Dragon capsule in the simulator
https://github.com/mbertschler/dragon-iss-docking-autopilot
autopilot controller controller-algorithm go spacex webassembly
Last synced: 6 months ago
JSON representation
Autopilot in Go for docking the SpaceX Dragon capsule in the simulator
- Host: GitHub
- URL: https://github.com/mbertschler/dragon-iss-docking-autopilot
- Owner: mbertschler
- License: mit
- Created: 2020-05-23T22:42:27.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-05-29T07:56:09.000Z (about 6 years ago)
- Last Synced: 2025-04-11T01:39:34.634Z (about 1 year ago)
- Topics: autopilot, controller, controller-algorithm, go, spacex, webassembly
- Language: Go
- Homepage: https://youtu.be/jLTr6UwuSd4
- Size: 31.3 KB
- Stars: 293
- Watchers: 5
- Forks: 22
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dragon ISS Docking Autopilot in Go
Autopilot written in Go and executed as WebAssembly for docking the SpaceX
Dragon capsule in the [official simulator](https://iss-sim.spacex.com).
### [Screencast of the autopilot in action](https://youtu.be/jLTr6UwuSd4)

## Why
I never used Go and WebAssembly together before. This seemed like a nice and
small excercise and I also got to refresh controller algorithms.
## Using this autopilot
- Compile the autopilot and serve the files.
```bash
go run ./cmd/autopilot-server
```
- Open the SpaceX ISS docking simulator: https://iss-sim.spacex.com
- Open the developer console of your browser (eg. right click > Inspect in Chrome)
- Paste the following code into the console to load the autopilot:
```js
const s = document.createElement("script");
s.setAttribute("src", "http://localhost:8000/loader.js?t="+ new Date().getTime());
document.body.appendChild(s);
```
If you want to make modifications to `autopilot.go`, restart the
`autopilot-server`, refresh the simulator page and paste the above
JavaScript code into the console again.
## Controller algorithm
The main controller algorithm is the `correct()` method in `autopilot.go`.
At first the current rate is calculated using the previous time and offset
and dampened over some cycles `DampingCycles`.
Then a correction factor `Correction` is used to calculate the target rate.
This target rate is limited based on the offset and `RateFactor` but kept
between `RateMin` and `RateMax`.
The difference between target and current rate is then added to a clicks
accumulator. Full clicks are then subtracted from the accumulator and
returned from the function.
Play around with the `ios` configuration to get different controller behavior.
## Contributing
If you improved this autopilot or added a new feature, don't hesitate to open a PR.
I'm looking forward to see what you will do with it.
---
Built by [@mbertschler](https://twitter.com/mbertschler)