-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
core.clj
58 lines (52 loc) · 1.61 KB
/
core.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
(ns iss-sim-auto-docking.core
(:require
[etaoin.api :refer :all]
[iss-sim-auto-docking.dragon :as dragon]
[iss-sim-auto-docking.telemetry :as tel])
(:gen-class))
(def sim-website-url "https://iss-sim.spacex.com")
;; Button selectors
(def begin-button {:id :begin-button})
(def success {:css "#success > h2"})
(defn setup-sim
"Setup the simulator."
[driv]
(println "Setting up the simulator...")
(doto driv
(set-window-size 1200 800)
(go sim-website-url)
(wait-visible begin-button {:timeout 30})
(click begin-button)
(wait 12))
(println "Simulator started."))
(defn -main
"I don't do a whole lot ... yet."
[& args]
(println "Starting up webdriver...")
(with-chrome {} chr
;; Setup the simulator
(setup-sim chr)
(println "Started telemetry poller")
(future (tel/poll chr))
(wait chr 2)
;; concurrent futures for each control axis
(println "Rotation alignment enabled")
;; TODO: Replace with core.async channels
(future (dragon/align-roll-rot chr))
(future (dragon/align-pitch-rot chr))
(future (dragon/align-yaw-rot chr))
(wait chr 10)
(dragon/wait-rotation-stopped)
;; concurrent futures for each translation axis besides approach axis x
(wait chr 4)
(println "Translation alignment enabled")
(future (dragon/align-z-translation chr))
(future (dragon/align-y-translation chr))
(wait chr 5)
;; start actual approach to docking port
(dragon/accelerate chr)
(future (dragon/decellerate chr))
(wait-visible chr success {:timeout 420})
(println "Docking confirmed")
(wait chr 10))
(System/exit 0))