Orbital Rocket Guidance with Ruby
This is a modal window.
The media could not be loaded, either because the server or network failed or because the format is not supported.
Formal Metadata
Title |
| |
Title of Series | ||
Number of Parts | 69 | |
Author | ||
License | CC Attribution - ShareAlike 3.0 Unported: You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this | |
Identifiers | 10.5446/37789 (DOI) | |
Publisher | ||
Release Date | ||
Language |
Content Metadata
Subject Area | ||
Genre | ||
Abstract |
|
Ruby Conference 201728 / 69
2
5
8
11
13
19
20
21
32
33
34
35
37
40
43
44
52
54
55
56
57
58
62
64
65
67
00:00
CountingPower (physics)2 (number)Execution unitRight angleMultiplication signMereologyHeat transferAreaShared memoryPhase transitionJSONXMLUMLComputer animation
01:10
2 (number)Execution unitSequenceMultiplication signComputer programmingSpacetimeGame controllerComputer animation
01:42
Computer programMIDIMaxima and minimaService (economics)Product (business)Integrated development environmentStack (abstract data type)Client (computing)BlogComplete metric spaceElectronic program guideWeb pageFilm editingCartesian coordinate systemSpacetimeNeuroinformatikProgramming languageComputer simulationComputer programmingMetropolitan area networkNatural numberWeb applicationComputer animationXML
02:21
SpacetimeComputer programSound effectSpacetimeComputer programmingVideo gameGenderComputer simulationPhysicalismQuicksortSound effectComputer animation
02:59
Sound effectObject-oriented programmingTable (information)Projective planeSpacetimeComputer programmingModulare ProgrammierungCompilation albumSimulationReal numberPhysicalismComputer programmingComputer simulationTraffic reportingOrbitUniverse (mathematics)WordLibrary (computing)Mereology
03:41
Control flowClient (computing)SpacetimeComputer programGame theorySoftware developerLink (knot theory)Internet forumThread (computing)Web pageKeyboard shortcutConnectivity (graph theory)GodQuicksortState of matterVirtual machineResultantCASE <Informatik>Real-time operating systemIntegrated development environmentSpacetimeGame controllerComputer programmingNeuroinformatikComputer configurationLibrary (computing)VacuumMathematicsRight angleBessel functionObject-oriented programmingJoystickCalculationOrbitDecision theoryPunched cardGoogolSystem callKeyboard shortcutClient (computing)Video game consoleRemote procedure callComputer animation
06:02
PlanningNeuroinformatikDesign by contractElectronic program guideGodRight angle
06:34
SpacetimeSpacetimePoint (geometry)Position operatorTrail2 (number)Process (computing)Greatest elementArrow of timeGraphics tabletComputer animation
07:28
Limit (category theory)Office suitePattern recognitionSpacetimeView (database)DemosceneMobile appMachine visionBitMereologyRight angleComputer programmingPosition operatorAngleComputer animation
08:27
Maxima and minimaExecution unitElectric currentChannel capacityLiquidVideo gameSet (mathematics)BitView (database)State of matterProof theoryMultiplication signComputer filePhase transitionRight angleAdditionMaxima and minimaElectronic program guideTask (computing)Object-oriented programmingTheoryWebsiteFilm editing2 (number)Computer programmingSpacetimeClient (computing)Greatest elementTowerGraphics tabletComputer animation
10:48
ComputerSpacetimeGreatest elementComputer simulationSpacetimeMetropolitan area networkDigital electronics19 (number)CuboidPlotterVirtual machineNeuroinformatikMereologyComputerComputer programmingQuicksortMultiplicationExistential quantificationMultiplication signRevision controlExecution unitBitComputer animation
12:27
NeuroinformatikElectronic visual displayPoint (geometry)TowerRight angleWhiteboardPopulation densityWorkstation <Musikinstrument>State of matterDivisorForm factor (electronics)Keyboard shortcut
13:06
Software developerSoftwareWhiteboardControl flowSystem programmingCycle (graph theory)Right angleComputer simulationVideo gameReal numberMachine codeLine (geometry)Multiplication signSolid geometryComputer programmingNeuroinformatikGame controllerOperating systemComputer programmingLimit (category theory)Set (mathematics)QuicksortModulare ProgrammierungMassAssembly languageEquivalence relationComputer animation
14:32
OrbitGradient descentInjektivitätWave packetPoint (geometry)Process (computing)Translation (relic)InjektivitätTransmissionskoeffizientOrbitWordNumberOperator (mathematics)TransputerWebsiteMachine visionNormal (geometry)
15:32
Euler anglesKey (cryptography)SimulationComputerWeightComputer programmingSimulationSource codeEmulatorProcess (computing)Computer animation
16:07
Computer programmingProjective planeField (computer science)Formal grammarReal numberQuicksortMachine codeSource codeSoftwareHamiltonian (quantum mechanics)HypermediaLine (geometry)IterationSystem programmingNeuroinformatikPoint (geometry)WordExecution unitSummierbarkeitElectronic mailing listRight angleCellular automatonComputer animationDrawing
17:14
10 (number)Programmable read-only memorySource codeComputerModul <Datentyp>Tangible user interfaceMenu (computing)Link (knot theory)IntelFormal languageSystem callBit rateComputer-aided designHydraulic jumpDigital electronicsContinuous functionMultiplication signWave packetPoint (geometry)Formal grammarNeuroinformatikComputer scienceSocial classMathematicsMachine codeModulare ProgrammierungGame controllerPosition operatorNichtlineares GleichungssystemRight anglePower (physics)Goodness of fitComputer programmingFrame problemSlide ruleSystem callOnline helpOffice suiteComputer programmingComputer animation
18:59
Process (computing)ManifoldDifferent (Kate Ryan album)Real numberOperating systemQuicksortTrailResultantRight angleMultiplication signMeeting/Interview
19:35
QuicksortAdditionSoftware testingRight angleComputer programmingMixed realityVideo gameMultiplication signCuboidComputer programmingShared memoryNichtlineares GleichungssystemWave packetComputer animation
20:29
1 (number)Fiber (mathematics)Social classCore dumpLoop (music)ClefReverse engineeringTask (computing)Computer fileThread (computing)EmailSimultaneous localization and mappingComputer programmingProcess (computing)Type theoryWebsiteGroup actionFlow separationMultiplication signAreaElectronic mailing listSemiconductor memoryPoint (geometry)Workstation <Musikinstrument>Programmer (hardware)QuicksortMereologyForcing (mathematics)1 (number)TrailCore dumpSoftwareSocial classState of matterSystem programmingLevel (video gaming)Field (computer science)Different (Kate Ryan album)Interrupt <Informatik>Table (information)GodSet (mathematics)Power (physics)Stability theory4 (number)FreewareSoftware testingOrder (biology)Task (computing)Game controllerDemosceneWordBit rateFrequency2 (number)Representation (politics)Sheaf (mathematics)Fiber (mathematics)CoroutineZoom lensSymbol tableNeuroinformatikThread (computing)Scheduling (computing)DampingLoop (music)PredictabilitySpacetimeBlock (periodic table)XMLComputer animation
26:43
Computer simulationValidity (statistics)Projective planeElectronic visual displayNoise (electronics)Computer programmingComputer animation
27:28
Multiplication signBuildingRight angleComputer programmingInformation overloadInterrupt <Informatik>Process (computing)Power (physics)Procedural programmingSurfaceNeuroinformatikCoprocessorTable (information)Error messageCore dumpComputer animation
28:57
Control flowPhase transitionFirst-person shooterVelocityLogic gateNominal numberGradient descentTrajectoryPosition operatorSurfaceIdentity managementState of matterComputer programmingBlogOrbitService (economics)NeuroinformatikTask (computing)SurfaceInertialsystemMaß <Mathematik>Frame problemComputing platformMiniDiscOrientation (vector space)Process (computing)Bit rateElectronic program guide1 (number)MeasurementComputer animationEngineering drawingDiagramXML
29:53
Control flowTransmitterKeyboard shortcutComputerTelecommunicationOpticsComputer simulationView (database)Source codeTupleModulare ProgrammierungTask (computing)NeuroinformatikFigurate numberRight angleComputer programmingAtomic numberComputer programmingAsymmetryMereologyEngineering drawing
30:55
Execution unitComputer fontSpacetimeOrbitMereologyGame controllerComputer programmingRight angleQuicksortProfil (magazine)
31:27
Dedekind cutRange (statistics)DistanceOrbitNominal numberUser profileGravitationOpen setLoop (music)GravitationOrbitInstance (computer science)SpacetimeFraction (mathematics)State of matterQuicksortLoop (music)Open setClosed setAlgorithmComputer animation
32:06
GravitationBitOrbitDegree (graph theory)Right angleSource codeComputer animation
32:40
Multiplication signPoint (geometry)GravitationoutputGame controllerComputer programmingMoving averageComplete metric spaceBitMereologyComputer animationMeeting/InterviewLecture/Conference
33:36
Maxima and minimaPlane (geometry)Euler anglesConstraint (mathematics)Degree (graph theory)Computer simulationDesign by contractNormal (geometry)Degree (graph theory)Source codeForcing (mathematics)2 (number)Euler anglesConstraint (mathematics)Different (Kate Ryan album)IterationAsynchronous Transfer ModeLoop (music)AlgorithmPoint (geometry)Closed setFrequencyComputer animation
34:28
Mach's principleAngleNichtlineares GleichungssystemSicEuler anglesFiber (mathematics)Computer programmingRight angleBitSatellitePower (physics)CurvatureUniverse (mathematics)TheoryTangent2 (number)Graphics tabletEuler anglesSpherical trigonometryLoop (music)AlgorithmClosed setLinearizationGravitationDegree (graph theory)Computer animation
35:30
TowerLoop (music)Degree (graph theory)PressureComputer simulationMetropolitan area networkRight angleTouchscreenVideoconferencingSocial classWhiteboardGraphics tabletPoint (geometry)Closed setSpacetimeEuler anglesTowerOrbitTask (computing)PressureLoop (music)Game controllerGravitationDegree (graph theory)Dynamical systemCartesian coordinate systemWeightComputer animation
36:34
QuicksortCategory of beingRight angleSet (mathematics)LiquidDemoscene
37:06
Right angleGoodness of fitSlide ruleComputer programmingSpacetimeKernel (computing)WebsiteFerry CorstenProcess (computing)Computer programmingGraphics tabletMeeting/InterviewComputer animation
37:44
Core dumpFiber (mathematics)Process (computing)Loop (music)Object-oriented programmingGame controllerState of matterWeightSet (mathematics)GravitationTowerCore dumpGraphics tabletComputer animationLecture/Conference
38:20
Fiber (mathematics)Core dumpOrbitAngleCommon Language InfrastructureSocial classDedekind cutExecution unitOrbitGravitationTask (computing)CASE <Informatik>2 (number)Degree (graph theory)Renewal theoryMetreProcess (computing)Basis <Mathematik>Loop (music)Closed setRule of inferenceState of matterComputer animation
38:59
AerodynamicsPressureOrbitFiber (mathematics)Social classClefLoop (music)AngleOrbitMultiplication signCharge carrierComputer animation
39:36
SpeicherbereinigungMultiplication signParallel portGoodness of fitSpacetimeComputer programmingCrash (computing)Real numberPhase transitionOrbitLine (geometry)Assembly languageMachine codeAddress spaceNeuroinformatikSurfaceParameter (computer programming)Lattice (group)Electronic program guideServer (computing)Software testingEmailComputer animation
41:54
Coma BerenicesXML
Transcript: English(auto-generated)
00:11
keeping an eye at t-minus 50 seconds the s4b propellants now all pressurized s4b propellant
00:24
that's the third stage of the Saturn 5 pressurized one minute 15 seconds and counting the spacecraft equipment now is on its own internal cooling it's been uh sharing its cooling from getting its cooling from an external power source up to this time we're now approaching the
00:41
t-minus one minute mark t-minus one minute t-minus one minute and counting today because of our countdown we get quite a shaking here 30 seconds that they uh keep the sound down you're right it's interesting let's see if they play together as we pass the t-minus 50 seconds mark the power transfer takes place first stage second stage third stage and the instrument
01:03
unit going to internal power t-minus 37 seconds and our count continues to go well we'll be looking for an ignition of those five the first stage engines at the t-minus 8.9 second mark we passed t-minus 30 t-minus 25 seconds and counting and Apollo
01:20
13 is go t-minus 20 seconds t-minus 20 seconds and counting 17 guidance release 15 14 13 12 11 10 9 8 ignition sequence has started 6 5 4 3
01:40
1 my name is nate burkapek i am the mission control director for the ruby space program as you know we've had a lot of budget cuts over the last couple of years so you are here today to learn how to program a spacecraft computer in the ruby programming
02:01
language uh obviously ruby is not known for its aerospace applications but we're not going to let that one stop us um like i said my name is nate i know nothing about space i have no background in space at all um in fact all i do is write about uh how to make ruby web applications faster so i have no qualification for this but that doesn't stop me from teaching this session
02:23
uh we're going to be using a uh program called kerbil space program kerbil space program is a video game uh that simulates spacecraft uh and space launches um it's more known for its sort of like wacky weird stuff that people do in it like this it's just a physics sandbox
02:42
so like people do this crazy stuff in it that's probably your experience with kerbil space program um but it's also an extremely accurate physics simulator um it will simulate something called the janevikov effect um janevikov was a soviet um cosmonaut um and uh the janevikov effect basically it just shows that uh a object that rotates um is stable in two axes but not
03:07
on the third so that's kerbil space program there uh and what you saw before was an experiment on the iss so it's actually an extremely accurate physics simulation which means we can use it to uh simulate uh real world space launches uh we're gonna use a mod compilation
03:24
called realism overhaul which takes kerbil space program's universe and turns it into a model of the actual solar system and we're gonna use that today to launch a saturn 5 rocket into orbit using a program written in ruby uh the ruby part is going to be managed by a library called
03:45
krpc which stands for kerbil remote procedure call uh basically just turns any running kerbil space program into uh an api that you can make calls to and it's managed with google protobufs um there's a ruby client library uh it's really slick uh basically you can
04:02
control anything in kerbil space program that you could control normally with a keyboard or joystick or whatever uh here's an example program uh for krpc written in ruby we just require it uh we connect to a running uh kerbil space program with krpc installed uh and then we've got
04:21
this vessel object which is going to contain all of our telemetry like how fast we're going which way we're pointed then we've got a control object which will let us do things like change the throttle activate the next stage and stuff like that i've used pry here just to open up a console let me play around with different objects that krpc makes available okay so how are
04:42
going to design a program to get us to orbit um i want to look at some of the space computers of the past uh space computers have to be three very important things they have to work in real time that just means that uh rocket launch is a pretty sort of like fast and furious thing these computers have to do their calculations quickly and they have to interact with astronauts
05:02
in real time as well astronauts have to interact with this computer back in the 1960s that was when you would put a punch card into a machine and get a result 10 minutes later so a real-time computer back then was sort of this new novel thing um computers also have to be extremely reliable uh the apollo guidance computer uh actually had all of its components
05:22
in triplicate um so if there was a sensor you had three sensors and uh if one sensor was reading incorrectly you took the result from the other two uh this kind of stuff was done because space is an extremely harsh environment it's got vacuum the temperatures can vary wildly um and of course if this computer stops working people are probably gonna die
05:44
so our space computers have to be extremely reliable uh they also have to be simple and they have to work in simple ways um because unfortunately mostly because of the reliability requirements here um it's difficult to send a very complicated computer into space we have to send simple computers into space so that we know that they'll work um the origins of space
06:05
computing go back to this guy named charles draper um who ran the draper mit uh lab uh that he was actually the guy that got the apollo guidance computer contract in the 1950s he basically put a bunch of gyroscopes and accelerometers into the back of a plane and let the plane fly
06:21
itself with no external landmarks from the east coast to the west coast and it was only off by a couple of miles when it got all the way to san francisco so no navigation of landmarks just the the gyroscopes and the accelerometers um that's draper right there on the right and that's obviously really important for space guidance because in space there is no reference
06:42
point we have to uh navigate without any external references and keep track of our position also in the 1950s we were doing something uh called uh building sounding rockets sounding rockets uh our upper atmosphere research rockets they basically go straight up and then do some
07:00
experiments in the upper atmosphere and then fall back down to earth um the most common one that the us built was called the arrow b rocket that's that second one there that's the one i'm going to talk about uh so the arrow b had two stages the top stage here was a sustainer stage it was liquid fuel the really short stage here on the bottom is a booster stage it's made
07:21
with solid fuel it only lasted about five seconds its job was to get the rocket off the pad um uh let's uh take a look at the arrow b launch here a camera is adjusted in an arrow b rocket which is going to penetrate outer space on a photographic mission the sky is the limit here's the view from 50 miles up the second boost from the rockets and if you look back over your
07:52
shoulder this is what the world looks like a hundred miles away i feel terrible how do you feel the reason the the view is spinning there is because the rocket itself was spinning
08:03
most sounding rockets were spin stabilized that just means that the fins on the rocket are canted slightly to one angle which imparts a spin on the rocket as it accelerates through the atmosphere that's because uh a spinning rocket is more stable than one that's just going uh straight up because think of it like a spinning top right like a top keeps its position
08:23
upward because it's spinning it's the same way a gyroscope works which is what we'll talk about in a little bit okay so if we want to uh write a ruby program to guide a sounding rocket into the upper atmosphere we have three important things we need to do we need to detach from the launch tower uh when thrust is at maximum most rockets do not immediately have
08:42
full thrust available when you light them it takes a while for the thrust to sort of build to lift off thrust so if we just detach the launch pylon immediately our rocket will just fall over and then shoot off to the side so we shouldn't do that we got to wait until the thrust is all the way up to where we want it to be then seconds before the booster stage that's this stage right here on the right cuts out we need to light the second stage so we
09:04
have both stages firing at the same time now the reason we do that is because the second stage like i said is liquid fuel so it's a bunch of liquid jet fuel rocket fuel sloshing around in the tank and if the first stage cuts out and the second stage isn't already going you'll go from about two g's of acceleration to nothing right and the fuel in the in the
09:26
second stage will start to slosh around and then there's nothing pushing the fuel into the engine itself and then the light engine won't start and you're screwed so you need to start the second stage before the first stage burns out that's called hot
09:41
staging there the stages were actually connected with like a little cage there wasn't like a solid bearing on the outside so the thrust could get out to see the cage in a second and then we run out of fuel on the first stage we uh separate the booster stage and let it fly away and then we go into the upper atmosphere so let's just take a quick look at what that
10:02
looks like in purpose space program uh so we've got a client object from care if you see that we connect to we activate the first stage which is the ignition of the engines we wait until uh the engine comes up to 60 of maximum thrust that's enough to get us off the pad and then we activate the next stage which is to uh detach the launch pylon
10:24
so the rocket launches um and then we've got to uh uh hot stage and detach the first stage uh we just kind of take note of how much fuel we have in the first uh stage fuel tank when we have about 10 remaining what will uh activate the second stage the sustainer rocket
10:41
and then when we run out of fuel uh we will activate the next stage which is the the detaching uh looks a little bit like this that's the booster stage in the bottom here's the cage and there goes the sustainer stage and it'll go up to 100 miles or whatever
11:02
see it's spinning there too obviously okay so that's an unmanned sounding rocket very simple let's talk about manned space flight so the soviets had a who were obviously in a space race with at the time had a very different idea of what the role of a computer was in a manned space program um in the soviet space program the astronauts themselves were sort of like spam
11:25
in a can uh just along for the ride everything was automated and uh the reasons for that are sort of multiple but uh mostly it was the soviets did not want their space program to fail they thought that the political consequences of a failed launch would be too much
11:41
so it was better to have it all automated and run by machine rather than you know down to some uh monkey and capsule so what they did was they built these electromechanical computers this is the globus imu unit that was flown in the bokshad spacecraft and versions of this were flown until 2005 uh in the soviets the soviets did not have a computer on their rockets with
12:04
circuits in it a digital computer until 1980 um so this is as you can see this is sort of like a steampunk clockwork kind of looking thing the reason they did this was because it's very easy to formally verify like something with switches and gears rather than something with circuits it's a little bit less complicated something that you can definitely trust
12:24
will do what you tell it to the agc was a little different it was a digital computer in fact it was one of the first um especially at that at that uh form factor this is the agc itself it's 70 pounds most of which is the aluminum casing um on the outside there uh it was probably about
12:46
the size of a modern pc tower it's about this big um and that thing on the right is the discy the display keyboard it looks it makes the computer look smaller but that discy is actually really big uh because it had to be big enough for like fat finger astronaut like space suit
13:03
people to like uh use it so it makes the agc itself look a little smaller a lot is made about how limited the agc was and it was i mean 32k of rom 2k of ram and a two megahertz clock cycle um there were two of these so like uh there was one in the command module and one in
13:22
the lunar module so i guess you had a massive 64k of rom um but that's all it takes that's all it takes to get to the moon um how do you get to the moon with that sort of limited amount of resources um the answer is is twofold um one you have to be really careful and
13:45
uh basically you're writing an assembly uh so you have much more control over all the resources there's no operating system to get in your way um everything is done pretty much like it's the it's the computer equivalent of building a ship in a bottle um it's it's very minute
14:01
um the pro the programs themselves are um uh totally handcrafted and also you have a crap ton of money um the the program itself costs 45 million at the time that's 350 million in dollars um the program itself the the the agc code ends up being about 70 000 lines of assembler
14:22
so that's like five thousand dollars a line um so when you have a nasa budget it's a little easier to cram stuff in the really tiny um tiny computers um but that's not to say that this wasn't a difficult mission um just the transmitter injection itself so the agc
14:41
really did its job from basically after we left earth orbit and then all the way back home to landing on earth that's kind of when the agc was controlling the mission so the translator injection uh which is what got you from earth orbit to moon orbit you can think about that as if trying to hit a moving target 500 000 kilometers away
15:04
while you're on a train that's going around a curve and you're doing that with like you however many million pounds of rocket thrust behind you right um so it's a very difficult problem and uh there was no floating point operations it was all fixed point and you had
15:21
a 15-bit word size so you could only represent in one register numbers from zero to 32 000 unsigned um so it's a pretty amazing accomplishment for sure um one of the great things about the agc is it's extremely well documented we have all the source code from the apollo 11 mission
15:41
it's been hand transcribed and scanned in it's on github um and people have built their own um agc simulators and agc replicas from this documentation uh there's one online called moon js it's written in uh javascript and uses uh asm.js and you can play with an agc emulator
16:01
it's really cool that's it's running the um the disky uh light check program uh in this shot uh we've seen this picture before yeah it got kind of popular it kind of blew up on social media so who can tell me who this is margaret hamilton yeah so margaret hamilton was the director of uh flight software for the apollo program um this this picture is sometimes captioned
16:26
as uh standing next to the code she wrote for the apollo program of course she didn't write the program herself i think kind of undersells her her accomplishments uh because she was the sophomore person for the apollo program like that was her 350 million dollars going into that
16:43
project um margaret hamilton ended up being um a real sort of thought leader and luminary in the in the field of software reliability and formal systems um i did a lot of work after the um and like i said the uh the apollo source code of the guidance computer source code itself
17:03
is only 70 000 lines um uh these that's probably like one of these phone books so she's probably standing in front of multiple you know iterations of the hcc code um and it's worth remembering that margaret and everyone else that worked on the apollo guidance computer had no formal training computer science was not a thing at this point you couldn't
17:25
take a class anywhere on it um almost everything that they did for the apollo guidance computer people were doing for the first time um like i said it's it's all available on uh github um this is the apollo 11 code they would make little changes to each mission code as they went along
17:45
um they had a pretty good sense of humor uh this was the name of the routine that controlled the engines uh it's actually so this was the 60s right so this was a reference to the uh la riots and the black power movement at the time uh this one i'll give you a guess as to what
18:05
this control this was the diskey control uh for the keypad and all the associated lights on it i like this one lunar landing guidance equations yeah i got us in the mood uh this is a good
18:22
one so uh the lunar module had a landing radar that had to be pointed at the ground and if it wasn't pointed in the correct position this routine got called and asked you to please crank the silly thing around like crank the radar around uh see if he's lying and whether or not he did it um and then off to see the wizard uh that will go to the bird baby birds
18:45
oh this isn't really showing up um so uh even though this program is 50 years old doesn't stop people from opening new issues on github about it um this is obviously referring to the apollo 13 explosion okay so uh one of the difficult things about a space mission
19:04
is you have to do a lot of different things at once during the launch for example we're going to have to keep track of what stage of the rocket we're in and whether or not we're out of fuel plus we got to keep ourselves pointed the right way so it's an inherently multitasking sort of problem um at the time uh multitasking was pretty new um this guy hal lanny
19:25
was the guy that designed basically the operating system for the agc it wasn't a real operating system it just sort of managed all the different processes that were running it was called the executive uh and hal kind of just made it up um no one had ever done this sort of thing before um so hal was like yeah i guess i have to invent priority based multitasking uh so
19:46
before the agc what you did to share time between programs was something called the box car method uh basically it's time slicing so you split a second into you know smaller intervals and you give an interval to a program and then when you're done with that interval you switch
20:04
to the next program in the next uh the next interval it's like a box car passing by on a train and the problem with that is what if the thing that you're doing right now is really important it's more important than the next box car uh you know you're working on the guidance equations right now and then the you know light update program wants time well obviously we
20:25
shouldn't do that right um so hal invented priority based multitasking um so this is uh a ruby representation of how the agc worked uh the agc had seven core sets
20:41
um a core set was an area that a job was assigned um it was their sort of memory space it was only 15 bytes and only seven of those bytes were available to the programmer to use um for you know scratch space and memory so if you can imagine writing a method that can only take uh seven bytes of memory that's what the agc programmers had to deal with i would also
21:03
keep track of what where it was in its routine that's the at loc and then each core set had a priority so higher priority core sets would run before the other ones it would always the executive would always run the highest priority core set job first and a core set with a priority
21:25
of zero was available it was it didn't have anything going on so you could only have seven tasks running at any given time so if you want to ask for a new core set to run a new job we give it a priority we look for an empty entry in the core in the core set table and then we're
21:41
going to give it a fiber so most multitasking in the agc was done cooperatively there were interrupts there was software interrupts but it wasn't done very often because obviously interrupting a computer with like you know 15 registers at any given time uh it would be
22:03
dangerous because things get out of order and then you're screwed so they tried not to use interrupts and mostly used cooperative multitasking so we have that in ruby with fibers so that's what we're going to use to emulate it and then we just set a priority to whatever we want okay a job itself is just going to be a class and we're going to delegate
22:26
a bunch of plumbing back to the core set so we can get access to like our telemetry and stuff like that here's an example of a job this will just print the priorities of all the current core sets so we just go through the core set table and and print the priority
22:43
and then we're going to yield with a fiber so that'll at this point we'll yield control back to the executive the executive will then decide if this gets to run again or not when we call uh fiber dot resume we enter here and go back to the beginning of the loop and so on and so forth okay so this job just runs over and over and over and it doesn't do
23:03
anything else obviously okay so then this is what the actual executive routine looks like we set we sort the core set table by priority highest priority at the top we take the highest priority job we call the zoom on that unless it's priority zero or less than zero because
23:21
then it's available and if we fiber dot yield with a kill symbol we're going to say that's when this task of this job is done we'll make that core set available again this is pretty much how the agency worked um the so like that that uh core set printer program it would just
23:40
run over and over right so that's not very useful like what if we only wanted to print the core set priorities every five seconds well we can do that with something called the wait list this was sort of um the way that you manage scheduled work on the agc the wait list was also about seven entries long what it would do would so the any task on the wait list only had six
24:06
milliseconds allotted to it to run it would the waitlist task were basically just like hey schedule this job manipulate the priority of this other job they were very quick little things that got scheduled for the future at a particular time one thing that was used a lot
24:22
for and what we're going to use it a lot for in our program is to sleep or delay a job what we're going to do is just reverse the priority of the job so if a job is priority 10 we'll make it priority negative 10 and give it a time to execute in the future and then we'll just go through the wait list every once in a while and say hey is there any thing in the wait list
24:41
whose time has come and then just quickly call it uh we'll just give it a block call the block that's our waitlist that's exactly the wait list is uh just pulled straight from how the agc actually worked the agc um had a requirement that it had to be able to restart
25:01
at any time um part of this is because power was unpredictable um if power could you know spike or go down at any time and then the agc would have to shut off it would have to restart from where it was it also used to restart as a way to you know turn it on and off again fix the problem we'll get back to that in a minute we can kind of emulate this by just marshall
25:23
dumping the core set table and then reloading it again it's kind of the not super accurate way of doing this in agc jobs can actually sign up for different kinds of restart protection you could register a waypoint during your routine and say if we restart please restart here things like that that's way too complicated we're not going to bother with that
25:43
um this is uh you could also stop reset there was a button on the agc to reset uh we're going to emulate that by just clearing out the core set table and the wait list um so the only thing that really enforced how much time a computer uh sorry how much time a
26:01
job could take was something called the night watchman and it was sort of a last resort there was really nothing um that said that oh you have to check the you know you have to return control every once in a while or whatever it was assumed that you would return control to the executive every 20 milliseconds uh but that wasn't strictly enforced there was something called the night watchman which um i don't remember the interval in the agc uh but it
26:24
would just if you hadn't checked into the executive in a certain period of time it would blow up and restart the whole computer so that's what we're going to do here we're just going to start a thread and every one second if the uh main uh routine has not been run
26:40
that will blow up and when we start okay so the restart protection actually came in very handy during the apollo 11 landing this is a somebody's model of an agc and it's going through the moon landing you'll hear the uh astronauts in the background uh let's just watch that clicking noise is the actual display
27:15
you can hear the tone of his voice there um a program alarm was something that the executive
27:26
would raise when it had a problem you can mess it up by playing there
28:06
let's play so this is as they're coming down to the moon surface suddenly they're getting this computer error right and he's like give us a reading the 1202 program alarm because they were they were putting their hand over the abort button and thinking well this is it like we're not going
28:20
to make it to the moon uh a 1202 alarm was what happened when the core set table overflowed that just meant that basically the computer didn't have enough time for all the work that it was doing uh it would raise the 1202 alarm and you would reset the computer and hope that it didn't happen again that's really actually what they did on the way down to the lunar surface they just keep restarting the computer every time that this alarm happened it was caused by this
28:44
the landing radar had like a power problem and sending too many interrupts to the processor and overloading it they never actually did fix that they just changed the procedure during landing so that it wouldn't occur okay so we're going to write our launch program now so
29:02
what do we have to do we have to guide the spacecraft guidance is just where do you want to go what is the exact path that we're going to take to orbit um it was an extremely important task in the apollo guidance computer obviously uh how do you get down to the surface of the moon navigation is where are you right now so where are you pointed and how fast are you going
29:24
and can uh so i was talking about gyroscopes earlier the apollo guidance computer had something called the imu that's the inertial measurement unit it was just a bunch of gyroscopes and accelerometers a gyroscope works like this this is actually draper himself demonstrating this so you see how the the spinning disc there it's keeping its orientation
29:44
even as the the frame is being moved so that's all a gyroscope does that it provides a stable platform that you can make a reference against if the gyroscope got out of whack which it did every like day it would eventually just become inaccurate you actually used a sextant which
30:01
i think is kind of amazing they had a sextant built in to both the uh command module and the lunar module you take some star sightings and then reset where you were pretty amazing uh technology from you know literally the 1500s the third task we have to do is control uh we have to control the rocket uh nothing in the uh apollo program uh was uh manual uh everything
30:29
was fly by wire everything went through the computer part of this was because flying the spacecraft is actually very complicated uh the lunar module if you look at it it's asymmetric so if you have an asymmetric rocket with um an engine directly underneath that's actually very
30:43
difficult to control it's like trying to balance a broomstick on your finger but the broomstick is like bent right that's actually kind of complicated to think about and and work with so everything went through the computer and it corrected for that but today we're just going to talk about guidance um krfc and kerbil space program basically like do the navigation and
31:03
control part for you so we're just going to talk about guidance we're going to go to orbit orbit is fundamentally about taking a rocket which is moving zero miles an hour and pointed straight up and going to 200 kilometers above the earth and moving at 17 000 miles an hour
31:21
sideways uh the 7-5 had three stages which to accomplish this um the launch profile um took about 11 or 12 minutes to get into orbit uh this path this curved path uh was something called a gravity turn a gravity turn um is a kind of uh is usually implemented as an open
31:44
loop algorithm this just means that it doesn't take into account the exterior state of the it's just sort of a pre-programmed thing go up you know a certain amount turn this way and then wait it's not saying okay let's figure out where we are and make some corrections it doesn't do any of that that's a closed loop guidance algorithm so we
32:04
start with open loop guidance gravity turn looks like this this is from a spacex uh rocket launch so you go up a little bit and then you turn the rocket over and you let the force of gravity slowly tip the rocket over um as you go to space and so the the way to orbit
32:20
looks like this long elliptical path uh movie apollo 13 actually gets the gravity turn maneuver really right um so gravity turn maneuver you go up to until you're moving at a certain speed and you pitch the rocket over so the saturn 5 pitched over uh 5 degrees so let's just watch to see what that looks like pitch so after that five degree pitch maneuver you
32:53
just let the engines point straight down and let gravity do the rest of the work for you you don't do any other control input after that until you're out of the atmosphere uh this is
33:02
the real Apollo 13 launch it's a little harder to see but i want you to listen to what Jim Lovell says so it's kind of hard to hear but what he says is roll and pitch program
33:31
complete so the rocket would roll slightly and then it would fall it would just pitch over a little bit um the reason we don't do more guidance during this part of the flight in
33:42
the atmosphere is because the rocket is actually very fragile it's under a lot of forces uh both from the enormous rocket engines underneath and the atmosphere pushing against it um the this is the actual constraint you couldn't move more than one uh degree uh per second in pitch and yaw um that's just so much there's just too much aerodynamic forces working on the vehicle for
34:03
us to do anything else once you got out of the atmosphere um the uh Apollo did something called uh iterative iterative guidance mode and it had a bunch of different modes and it's really complicated just it's a closed loop guidance algorithm which just means that it's at that point that it could take into account where it was where it wanted to be and then it would make
34:24
the corrections you could only do that outside of the atmosphere because that was the place where you could maneuver um they use something called linear tangent steering which is a bunch of spherical trigonometry that i'm not going to explain other than to say that's what it looks like and that's what our program is going to use um if you start accounting for things which
34:43
the linear tangent steering algorithm doesn't uh like the earth uh not being flat and uh the earth's gravity varies and uh all these other things uh it starts to get really complicated really quick so uh i'm not going to talk too much about closed loop guidance uh the last thing as the Saturn V comes off the pad it does what's called a yaw maneuver
35:05
so it tilts slightly and then goes back up straight the reason it does this is because if uh they just want to avoid a wind blowing it back into the tower and if a engine blows out right as you come off the pad you don't want the rocket to tilt back into the pad right
35:21
uh that program would look a bit like this in groovy we tilt over about a degree uh and wait eight seconds and then go back up straight that's called a yaw maneuver um i couldn't find a good video of the Saturn V doing this but here's the uh Antares rocket this is a more modern rocket doing the same maneuver notice the wind coming in from the right hand side of
35:42
screen three two one and we have ignition and there's that tilt and then it goes back straight so it's really subtle but it just keeps you from falling back into the pad okay so this is our task we're going to ignite the engines wait for them to come up
36:03
the thrust and lift off we're going to do a quick yaw away from the tower accelerate to 100 meters per second then pitch eastward five degrees then we're going to disable the pitch control on our autopilots that'll just let the rocket slowly tilt just with gravity um and then we'll wait until we're through the atmosphere when dynamic pressure on the rocket
36:22
is low then we'll begin close loop guidance uh and then burn until our uh the periapsis that's the lowest point in our orbit so we'll burn until the lowest point in our orbit is basically in space uh remember i talked about how liquid fuel and a rocket can get sloshed around so they didn't hot stage on the apollo uh the Saturn V what they did was they had these
36:45
things called ullage motors they're solid rocket uh solid fuel rockets on the side of the stage that basically sort of ignite before the main engines and then get the rocket moving so that the fuel settles and then they light the main liquid engines it's another great scene in hall 13 so i'll just point out the ullage motors in here that's the first stage burning
37:07
looks good slide right down the middle notice how they slow down there's the ullage
37:36
motors and then you see the second stage actually light okay so this is what it looks
37:41
like in Kerbal Space Program we're on the pad ready to launch um we start a new RGC process uh we just start the executive in a loop that's it very simple uh we ignite the engines uh so that's the control object we light wait until the thrust comes up to 60 percent and then uh we activate the next stage which releases the rocket from the tower
38:06
then we'll request some core sets for our gravity turn and a staging uh job so that will control the actual rockets you know stages separating and then we uh kill this process this core set and let someone else use the core set there we have liftoff lifting off the pad
38:25
on our way to orbit first stage uh this is what the gravity turn task ends up looking like you wait until you're over 100 meters per second pitch over six degrees in this case and then we've disabled the autopilot down here after we've waited 15 seconds
38:41
and that will just let the gravity turn slowly turn you over there's the ullage motors firing for the second stage there's the interstage fairing dropping off uh there's a staging job just basically says hey if there's an engine in this stage wait until it's out of fuel when it's out of fuel stage and we're on our way to orbit um i've a very simple closed loop guidance job
39:06
it's not closed loop actually um and we just slowly pitch over the rocket at a predetermined angle and that's separating off the third stage and there we are in orbit so that's how you get to
39:20
orbit uh with ruby thank you very much i was moving a little quick there at the end because i realized i'm really low on time but i do want to take at least uh one question i have the code and the text for this talk at that github address any questions did i ever turn off
39:49
the garbage collector no i didn't go that deep anybody else any questions about the apollo guidance computer yeah uh like a couple hours no i don't have a picture of me next to the code
40:08
pronounce it's uh it's only a couple hundred lines it's really not that much code actually definitely less than 70 000 lines of assembler yes sorry can you say that again finding out
40:24
recreating other apollo missions so yeah obviously this is only the launch that's actually like the simplest phase in the real apollo program uh this the launch was not controlled by the guidance computer at all it was a separate computer uh called the lvdc that was actually mounted in this in the saturn rocket itself the mission program for the apollo are actually way more
40:45
extensive landing on the loon on the lunar surface was pretty was extremely complicated so the answer to that is probably not because it's really complicated uh but uh it's a fun way to play kerbil space program just to like reduce yourself to saying
41:00
like hey i can only write ruby to control the rocket but it makes everything take really long anybody else yeah how many times did i crash dude it's awful so remember i said it takes it takes uh about 12 minutes to get to orbit so the only way to test your program is to go to
41:21
orbit so if you have a problem that happens 11 minutes in it's like well now i have to go you start and wait 11 minutes again to see if i fix it so it took forever yeah why didn't i try parallel testing five rockets that's a good idea yeah my rig is not that good i think i could run
41:41
it's a very resource intensive program yeah you could not run kerbil space program on the apollo guns computer all right that's my time thank you