 From this distant vantage point, the earth might not seem of any particular interest. But for us, it's different. Look again at that dot. That's here. That's home. That's us. On it, everyone you love, everyone you know, everyone you ever heard of, every whoever was lived out their lives. The aggregate of our joy and suffering. Thousands of confident religions, ideologies and economic doctrines. Every hunter and forager, every hero and coward, every creator and destroyer of civilization. Every king and peasant, every young couple in love, every mother and father, hopeful child inventor and explorer, every teacher of morals, every corrupt politician, every superstar, every supreme leader. Every saint and sinner in the history of our species lived there on a mode of dust suspended in a sunbeam. The earth is a very small stage in a vast cosmic arena. Think of the rivers of blood spilled by all those generals and emperors so that in glory and triumph they could become the momentary masters of a fraction of a dot. Think of the endless cruelties spilled by the inhabitants of one corner of this pixel on the scarcely distinguishable inhabitants of some other corner, how frequent their misunderstandings, how eager they are to kill one another, how fervent their hatreds, our posturings, our imagined self-importance, the delusion that we have some privileged position in this universe are challenged by that point of pale light. Our planet is a lonely speck in the great enveloping cosmic dark. In our obscurity, in all this vastness, there is no hint that help will come from elsewhere to save us from ourselves. The earth is the only known world so far to harbor life. There is nowhere else, at least in the near future, to which our species could migrate. Visit, yes, settle, not yet. Like it or not for the moment, the earth is where we make our stand. Carl wrote these words 20 years ago, at a time when the space shuttle program was in full swing. Plans for the International Space Station were just announced, and 11 of the 12 men to set foot on a celestial body other than our earth were still alive. Today, however, only the governments of Russia and China have human and orbit-capable space abilities. Our space station, never built to full specification, has only a decade of funding remaining, and the youngest living person to set foot on something other than our earth turns 80 next year. In 20 years, we haven't progressed 20 years, we've regressed 30. The only difference between now and 1964 is that in 1964, people actually cared about space. We love comparing the Apollo guidance computer to the phones we use every day like it's some sort of joke. In point of fact, the iPhone 5S is 12 trillion times better than the marvel that landed 12 men on our moon. And what praetel do we use these devices for? To look at cat pictures. Now, that's not fair. If you want a real indictment of our society, we invest seven figures in an app that says yo. Insecurely. We plunge tens of thousands into a potato salad Kickstarter, while 8,000 children under the age of five die every day. The finale, the season finale of the Cosmos TV show garnered a lower Nielsen rating than the show that appeared just before it on the same channel. A rerun of the family guy. Our priorities, it seems, are a bit misplaced. So where does that leave us? In the absence of any scientific leadership whatsoever from our so-called elected leaders, we still have hope. A cornucopia of private space companies ranging from the familiar to the new and exciting are steadily pushing forward. And we have you. You, the crafters of code. You, the designers of delight. You, the experts of agile. You have a place in all of this. Ladies and gentlemen, my name is Brad Griziak, and it is my job today to convince you of your place in our space-faring future. Welcome to the final talk of Cascadia Ruby. I'm honored to be here. It is customary for a presenter to establish credentials. Allow me to present mine. Since the age of 26, I've been acting as co-founder of a software consulting firm called Bendyworks. I also thoroughly enjoy reading science fiction. Should this pedigree not impress, allow me to continue. Prior to Bendyworks, I led a different life. I have an undergraduate degree and half a master's degree in engineering mechanics and astronautics out of the engineering physics department at University of Wisconsin-Madison. I've been classically trained in satellite dynamics, composite materials, and hypersonic aerodynamics. I have spent over 12 minutes in zero gravity aboard NASA's Vomit Comet. I worked on a habitat for rats aboard the International Space Station. Consequently, I know the exit velocity of rat you're in. It's on the order of one meter per second. I designed, built, and tested a prototype lunar mining machine. I applied to be an astronaut, unsuccessfully. I worked on a project that is currently in space, growing the first space-born food designed for astronaut consumption. Through these experiences, I've become ever more fascinated by the idea of space. It is my privilege to share some of that passion with you. This will be a talk in three parts. Launch, orbit, and land. I've warned you all on the abstract of this talk that there won't be much ruby at all. So instead, please sit back, relax, and enjoy learning something new. But first, let's talk about rocket science. Ever since the term existed, rocket science has exuded an error of superiority, an insinuation that only the brightest minds could possibly have any expectation of success. I feel the main reason why rocket science and aerospace engineering are held in such reverence is that because it requires a lot of difficult math. While this may be true sometimes, the same could also be true of programming. Tell me, do you know the Fermi energy equation for semiconductors? How about the assembly code that is generated from your Ruby program? So it goes with rocket science and aerospace engineering. The math is still there. It's just that someone else has done it for us already. Much like programming, aerospace engineers and rocket scientists need to build up a mental encyclopedia of practices. That's what we'll learn today. For example, when coding a web application, we know when to use get versus post. When launching a spacecraft, we know that it's usually best to launch from the equator. So let's talk about that. Let's talk about launch. A stable, simple two-body orbit requires four things. One body needs to be significantly more massive than the other. There needs to be some amount of circumferential velocity. Gravity needs to be the only force in play. And bringing this into reality, we need to make sure that there's no intersection between the two bodies. Less we encounter some other forces other than gravity, like air resistance by going into the atmosphere or plowing straight into the ground. So if we have a planet such as Earth, how much circumferential velocity do we need to achieve during launch in order to have a proper orbit? Let's do a physics. Imagine for a moment that there's no atmosphere on the Earth whatsoever. We live under water or something. Imagine also that the Earth is a perfect sphere. There's no bumps, no valleys, no mountains, nothing, just a perfectly smooth sphere. You may have heard that being in orbit is like being in a perpetual state of falling. Let's apply that to our hypothetical Earth. To get from Portland to Seattle, we need to travel 2.1 degrees of latitude, basically due north. If I run toward Seattle in a straight line, and I'm not talking about a long Earth surface, but in a literal straight line along that arrow, by the time I get to Seattle, I will be using high school mathematics and geometry. I'll be 2.7 miles above Seattle. From high school physics, we know that in the absence of air resistance, it would take me about 30 seconds to fall 2.7 miles in Earth's gravity. Think about the implication here. In order for the Earth's curvature to fall away from me at the same speed that gravity is pulling me towards it, I would need to get from Portland to Seattle, which is about 145 miles in 30 seconds. That's 17,000 miles an hour. Let's check our math. What does Google have to say about that? Yep, that's about right. To get something moving that fast in a vacuum, we need to give it a lot of kinetic energy. In fact, we need 29.6 megajoules for every kilogram that we accelerate to that speed. And note that I said in a vacuum. Around the Earth to have a stable orbit, we need to get outside of the atmosphere so that air drag isn't an issue. The International Space Station is 330 kilometers up, so let's use that as an example. In order to get 1 kilogram that high up in the absence of air resistance, we would need to only spend about 3.2 megajoules per kilogram. That's an interesting result. It takes about 10 times more energy to move something sideways fast enough for orbit than it does to get it up there. Earlier, I mentioned that one should usually launch a spacecraft from the equator, but I didn't explain why. Armed with our new knowledge about the relative energies required to put something into orbit, we should be focused on cheating physics by getting more sideways velocity than cheating physics by getting more altitude, say from launching from a mountain. Because the Earth is spinning, we can use that momentum to reduce our sideways velocity burden. The surface of the Earth at the equator moves along at a blistering 1,040 miles per hour. By launching at the equator, we only have to add 16,000 miles per hour instead of 17,000 miles per hour. That's a 6 percent savings on 90 percent of our energy burden, or 5.4 percent. It's not bad, I think. I should mention that you don't always want to launch from the equator. There are a few situations that I won't go into today where you don't want to do that in order to reduce the burden on your rocket engines. Anyway, how do rocket engines work? Anyway, the reason rockets can send spacecraft skyward is the law of conservation of momentum. We all know that if you're on ice skates and you throw a ball, the forward momentum of the ball will carry you back a little bit. We also know that if instead of throwing a ball, we fire a gun, we'll get pushed back a little bit more. Even though the bullet is going to be much less massive than the ball, its speed gives it much more momentum. Momentum is simply defined as mass times velocity. That's it. And the law of conservation of momentum states that the sum of momentum before an action needs to equal the sum of momentum after the action. Before throwing the ball, everything has zero momentum. And after throwing the ball, the positive momentum of the ball summed with my negative momentum needs to also sum to zero. So it goes with rockets. You basically just have to add a K to everything. And how do we get our rockets going so fast? Oh, of course, we have to use one weird trick. We'll use what's called a converging diverging nozzle. When a highly pressurized gas flows through a tube, it gets choked at its narrowest point. At this choke point, physics dictate that the gas can go no faster than Mach 1 or the speed of sound for that gas, no matter what. But once it starts expanding after that choke point, as long as the back pressure is high enough, the gas speeds up. That's why rockets have bell-shaped nozzles. The space shuttle main engines, for example, get their exhaust velocity up to Mach 13 or so. Now that we've established what it takes to launch, let's learn about orbits themselves. More specifically, let's learn about stable orbits. In the early 1600s, yes, 1600s, Johannes Kepler made this a lot easier for us. Much like Newton, Kepler gave us three laws, Kepler's laws of planetary motion. These laws were originally identified for orbits of planets around the sun, but they hold equally well for any two-body system, where, again, one of the bodies is much more massive than the other. A spacecraft orbiting Earth would be one such example. The first law is the orbit of every planet is an ellipse with the sun at one of the two foci. We tend to think of the Earth as in a circular orbit around the sun, but that's not true. Our orbit around the sun is actually elliptical, but it bears a closer resemblance to a circle. In astrodynamics, we measure the oblongness of an orbit as eccentricity. Coming from the Greek words of out of and center, the value of eccentricity for an orbit can range from zero to almost one. Values one or higher indicate a flyby trajectory, either in the shape of a parabola or a hyperbola. A value of zero means a perfectly circular orbit. The Earth's eccentricity is 0.0167. This makes it the third most circular orbit amongst our eight planets, followed by Venus and, surprisingly enough, Neptune. I learned something during the research of this talk on that. When a satellite orbits the Earth, we call the point of closest approach, the perigee, and the farthest point, the apogee. Around the sun, we call that the perihelion and the aphelion. And the generic terms, when orbiting around anybody, we call the periapsis and apelapsis. So that's Kepler's first law. Orbits are ellipses. The second law is a bit complicated, though it does have a simple takeaway. It states, a line joining a planet and the sun sweeps out equal areas during equal intervals of time. The implications of this law are quite precise, but for us, we can establish a rough takeaway. Given a stable elliptical orbit, the closer you are to the main object, the faster you go. For a circular orbit, this means that your speed will remain a constant. And for a highly eccentric orbit, you will speed up and whip around the main body at the periapsis and slow down to a crawl near the apoapsis. Kepler's third law of planetary motion is this. Bear with me here. The square of the orbital period of a planet is directly proportional to the cube of the semi-major axis of its orbit. Hold on. More succinctly, the bigger the orbit, the longer the orbit takes. We define one year as the time it takes the earth to revolve around the sun once. That takes 365.26 or so days. Venus, which is 27% closer to the sun, has a year that's 38% shorter. And Mars, which is 52% further away than the earth, has a year that's 88% longer. So in review, orbits are elliptical, orbits are faster when you're closer and slower when you're farther away, and big orbits take longer. Putting these three laws together, we can sketch out an idea of what a trip to Mars might look like. Here we have the earth around the sun. Even though I said our eccentricity is not zero, we're going to assume that it is here because circles are much more easy to deal with. Here's the Martian orbit. Again, idealized as a circle. We're also going to assume that these two orbits are coplanar, which in real life is not the case, but it's close enough. Since we're restricted to only elliptical orbits, we need to construct an additional orbit around the sun that is tangent to both the orbits of earth and Mars. And this is simple enough. Let's zoom into earth first. Here we see the stable orbit. We don't have to do anything to stay in this orbit. And here we see the orbit that we want to get into. Remembering that we're orbiting the sun, we want to turn this point into our perihelion. The second law states that the perihelion is where we're going the fastest, so let's do exactly that. Let's speed up by about three kilometers per second. So we light up our engines for a few minutes and we're on our way. We're on our way to Mars. So zooming into where we would intersect the Martian orbit, we're now at our apheleon. The second law states that we're going the slowest for our orbit. To put ourselves in Martian orbit, we just need to speed things up again to match the orbital speed of Mars. Using the precise definition of the third law, we would find out that this trip would take approximately eight and a half months. One last thing we should probably consider is that we want to make sure that Mars is actually there when we arrive in its orbit. It doesn't make a whole lot of sense to arrive in Martian orbit only to have Mars on the other side of the sun. So how do we do that? Well, we've already established how long our trip will take, eight and a half months. So all we have to do is leave Earth eight and a half months before Mars is going to be where we're going to meet up with it. Et voilà! We've mastered what's called the Hohmann transfer orbit. If you're interested in how you might apply this to your everyday life, I suggest you check out Kerbal Space Program. It's a pretty great game. Last, I want to talk about landing. The three major celestial bodies that we would want to land humans on in the near future are the Moon, Mars, and the Earth. Let's talk about Mars and the Earth first because they have atmospheres that help us out here. In our previous example, we went from the Earth to Mars. Let's now consider going in the opposite direction from Mars to the Earth. In such a situation, instead of speeding up at both burns on the Hohmann transfer orbit, we want to slow down. The first technique we can use to slow down is aerobraking. Since we need to slow down to match Earth's orbital velocity around the sun, we can simply got our spacecraft, which has been traveling about 364 million miles or so by now, to within about 100 miles or so of the surface of the Earth. Then we can use the atmospheric drag to reduce our velocity. If we do this accurately enough after this amount of distance, we can actually land on Earth without any approach field whatsoever, though it might be handy to have some just in case. Another method of deceleration is parachutes. Obviously, parachutes won't work at all on the Moon, and they don't work particularly well on Mars, either. You can use them on Mars in the upper atmosphere to scrub a bunch of speed, but the atmosphere is just too thin to ensure a soft landing. So in order to have a soft landing, we would need to use retro rockets. Retro rockets are just rockets that fire in the opposite direction of where we're traveling, slowing something down rather than speeding it up. So as our spacecraft approaches the Terran, Lunar or Martian surface, the retro rockets are a great way to ensure a perfectly soft landing. It's what the Apollo missions use to land on the Moon, and it's what SpaceX plans to use for their first stage rockets to land back at the launch pad for reuse. Sometimes, however, the simple application of retro rockets is just not enough. Enter the Sky Crane. Used for the first time in 2012, NASA's engineers designed the Sky Crane to lower the one-ton curiosity rover to Mars without the need for a surface deployment mechanism. That is, once curiosity hit the ground, it was ready to go. The principle of the Sky Crane is actually quite simple. You separate the rover from the retro rockets by a long tether. Once the rover hits ground, you sever the tethers, and without the mass of the rover keeping the retro rockets down anymore, the retro rockets will have more than enough thrust to take it safely beyond the landing area for the rover. And this is where I finally bring some Ruby into the presentation. I mentioned Kerbal Space Program earlier. It's a game where you get to build and fly rockets. It's very easy to build a rocket that doesn't work in Kerbal Space Program. I made one that doesn't work, though. I'm going to fire up Kerbal Space Program right now because it takes a while to load. And my computer would be on fire if I started it at the beginning of this presentation. So anyway, someone created a rocket part in Kerbal Space Program that effectively spins up an HTTP server. This provides both remote control and remote sensing capabilities to your rocket. While there are other more powerful custom parts that you can add to your rocket in KSP, I chose the Telemachus because of its simplicity. So what did I make? I made a spacecraft that launches itself and hovers at 150 meters all by itself. Here we see part of the Ruby program that I wrote. It's up on GitLab if you'd like to see it. This first part just sets things up, and there's not a whole lot interesting going on here in terms of control theory. Here is the run loop. This is the important part. It reads the current altitude and adjusts the throttle so that the ship hovers at 150 meters. It's in the form of a PID controller, proportional integral derivative controller. The proportional part determines the present error. How far above or below 150 meters are we? The integral part determines the accumulation of errors so far. This helps the ship accelerate quicker towards the goal height. And the derivative part helps predict the system's behavior, letting it settle out at the goal height quicker. Combining these with coefficients that we figure out mostly by trial and error, we get a desired thrust. Now, keep in mind the types of input and output that we have here. The input is the throttle, which is effectively a force, and the output is height, which is a distance. Converting from force to height is not an easy task for a hovering rocket. Thanks to Newton, we know that force is equal to a mass times acceleration. The problem with controlling rockets, however, is that both mass and acceleration change over time. In order to produce thrust, we need to light a bunch of mass on fire and shoot it at the business end. That is, the rockets get lighter the longer that they're firing their engines. So the one knob we have, the throttle, needs to be converted through a nonlinear relationship between mass and acceleration. Then that acceleration needs to get integrated twice to get to distance. That is, the problem that we're facing here is a second order nonlinear differential equation. Fortunately for us, PID controller doesn't care about that. We tell it our goal, and we give it the reins. So let's see it in action, shall we? Hopefully it's fired up. All right. We may have a problem with the size of what we're playing with here. So I'm going to load up the rocket that I made called Hovercraft, and it's down below. And go to the launch pad. There we go. So up here, you see the altitude. We're at 79 meters because we're above sea level. And down here, we see the throttle. Have this Ruby Hover program that I'm going to run, and then quickly switch over back. So I'm going to hit that and switch over, and there we go. So it went to full throttle, and it's going to 150 meters, and you'll be able to see, oh, it cut out the throttle already, and it's kind of figuring it itself out, getting back to 150, settling out a bit, and there we go. It's hovering. All I did was hit Enter in the terminal, and this happened. It is slightly moving to the left. I haven't figured that part out yet. One thing to notice, though, is that I mentioned the rocket gets lighter as it continues to fire. And if you watch this, this slowly goes down, because it doesn't need quite as much throttle to keep the lower mass at the same height. So that's that program. It's up on GitLab, like I said. We're going to quit this. We're just going to go back here. Launch orbit and landing. The three main components for space travel. I hope you all enjoyed learning about space today, and I urge you to jump onto Wikipedia and start learning from there. For a fun starting point, I suggest you check out the article on nuclear pulse propulsion. You might be surprised to learn how far the United States got on that. I'd like to thank Cascadia Ruby for the opportunity to entertain you on the topic of space today. It's something that I've been passionate about for a very long time, and I hope some of that has rubbed off on you. I thought about, I thought long and hard about how I would end this presentation, and I kept coming back to the pale blue dot by Carl Sagan. I never did finish that passage at the beginning, so let me do that here. It has been said that astronomy is a humbling and character building experience. There is perhaps no better demonstration of the folly of human conceits than this distant image of our tiny world. To me, it underscores our responsibility to deal more kindly with one another and to preserve and cherish the pale blue dot, the only home we've ever known. Thank you.