TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: SpaceX Dragon simulator docking autopilot in Clojure

181 点作者 danpetrov大约 5 年前

11 条评论

VLM大约 5 年前
I have a question about control flow of the overall system. Note that I haven&#x27;t actually run this or debugged it. Or frankly, thought about it for more than a minute or two. Its more of an architectural question.<p>So in dragon.clj there&#x27;s a case statement to execute commands in the translate function such that the command to go down or left in an abstract calculated sense is implemented as hitting a virtual down or left keyboard key.<p>What happens if you have to go down AND left?<p>I was just thinking why not pass a Clojure list to the translate function and when list contains a down it hits the virtual s key AND if the list contains a left command it hits a virtual a key, then you could wiggle &quot;down-left&quot; at the same time.<p>I mean, obviously it works and sometimes architectural decisions have no technical reason and are arbitrary, which would be perfectly OK. I was just idly curious.<p>Clojure is cool, like programmer catnip, so I had to look at it.
评论 #23258421 未加载
GistNoesis大约 5 年前
<a href="https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;spacex&#x2F;comments&#x2F;gigmfh&#x2F;spacex_iss_docking_simulator&#x2F;fqfzatb&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;spacex&#x2F;comments&#x2F;gigmfh&#x2F;spacex_iss_d...</a> does it in one line but it&#x27;s kind of cheating.
评论 #23259103 未加载
评论 #23258897 未加载
评论 #23258423 未加载
评论 #23258925 未加载
评论 #23261810 未加载
ggerganov大约 5 年前
From all the auto-pilots I&#x27;ve seen so far, I believe mine docks the fastest (without cheating):<p><a href="https:&#x2F;&#x2F;youtu.be&#x2F;jWQQH2_UGLw" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;jWQQH2_UGLw</a><p>Source code:<p><a href="https:&#x2F;&#x2F;gist.github.com&#x2F;ggerganov&#x2F;092b86a59fa34926998953701ae22ca1" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;ggerganov&#x2F;092b86a59fa34926998953701a...</a>
评论 #23269638 未加载
thom大约 5 年前
Not to say this is bad or incorrect, but this is very unidiomatic Clojure. I would question the amount of global state, and the broad use of loops inside threads. This can’t be fun to try and test!<p>Perhaps better would be to make pure functions to take current telemetry as an argument and return actions as outputs, perhaps all at once or more likely individually for each control. You could then capture all of this inside core.async go-loops to manage the control flow and timeouts, but you could also probably build something simple with one or more agents wrapping the current state and updating a set of commands to be executed later. Another argument for core.async would be to make it easier to funnel all commands into a single channel because I’m not entirely convinced a WebDriver is multithreaded, but perhaps the library manages that for you.<p>Anyway, cool stuff!
评论 #23262890 未加载
评论 #23262308 未加载
jcadam大约 5 年前
Back when I worked on spacecraft simulation we used Ada, and we liked it (no, we didn&#x27;t).
tosh大约 5 年前
related article: <a href="https:&#x2F;&#x2F;medium.com&#x2F;@thedanpetrov&#x2F;creating-a-spacex-crew-dragon-simulator-autopilot-in-clojure-1ac095d9209b" rel="nofollow">https:&#x2F;&#x2F;medium.com&#x2F;@thedanpetrov&#x2F;creating-a-spacex-crew-drag...</a>
frompdx大约 5 年前
For some reason I expected this to just interact with some form of http API. After digging into the source code I discovered the author is using etaoin. This is a really neat use of the etaoin library for selenium bindings in Clojure.
fnord77大约 5 年前
Really nice. Made it right up until almost docked.<p>It crashed for me right as it docked with:<p><pre><code> Syntax error (ExceptionInfo) compiling at (&#x2F;private&#x2F;var&#x2F;folders&#x2F;8f&#x2F;wlmmp1rs38966nkmrs_slnjd1vkfkk&#x2F;T&#x2F;form- init8037093313867620508.clj:1:125). throw+: {:type :etaoin&#x2F;timeout, :message &quot;Wait for {:css \&quot;#success &gt; h2\&quot;} element is visible&quot;, :timeout 300, :interval 0.33, :times 910, :predicate #object[etaoin.api$wait_visible$fn__4868 0x173b24c4 &quot;etaoin.api$wait_visible$fn__4868@173b24c4&quot;]}</code></pre>
TeMPOraL大约 5 年前
If you want the reverse of an autopilot, try this:<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=23172281" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=23172281</a><p>... and pull the appropriate Interstellar music up in a separate tab.
bloopernova大约 5 年前
OK so yes the ISS docking sim is old news, but good lord do I love that UX. I really hope someone has modded it into Kerbal Space Program!
评论 #23259903 未加载
karl11大约 5 年前
That is some nice looking code!