kerbal_space_program.rb

B4753ed732e72ff2568262c9387bbc4c?s=47 listrophy
October 27, 2017

 kerbal_space_program.rb

So there's this game, Kerbal Space Program. You basically create your own space program from scratch. Well, you can control it via TCP, and—using Ruby—we're gonna launch, orbit, and crash our brave Kerbins. You might even learn a thing or two about orbital mechanics and control theory along the way.

B4753ed732e72ff2568262c9387bbc4c?s=128

listrophy

October 27, 2017
Tweet

Transcript

  1. > kerbal_space_program.rb ~brad_grzesiak/keep_ruby_weird | 2017-10-27 14:30 ~brad_grzesiak/keep_ruby_weird | 2017-10-27 14:29

    > groups brad_grzesiak wheel bendyworks twitter.listrophy
  2. Whenever Brad is drinking, you wanna make sure you're sitting

    next to him, because instead of being obnoxious, he teaches you orbital mechanics. Ashe Dryden
  3. Whenever Brad is drinking, you wanna make sure you're sitting

    next to him, because instead of being obnoxious, he teaches you orbital mechanics. Ashe Dryden GET YOUR ALTERCONF TICKETS!
  4. PREFACE PREREQUISITES

  5. PREFACE PREREQUISITES ▸ Buy KSP ($40 on Steam)

  6. PREFACE PREREQUISITES ▸ Buy KSP ($40 on Steam) $24

  7. PREFACE PREREQUISITES ▸ Buy KSP ($40 on Steam) ▸ Install

    ckan $24
  8. PREFACE PREREQUISITES ▸ Buy KSP ($40 on Steam) ▸ Install

    ckan ▸ Install kRPC on ckan $24
  9. PREFACE PREREQUISITES ▸ Buy KSP ($40 on Steam) ▸ Install

    ckan ▸ Install kRPC on ckan ▸ EMA 550: Astrodynamics $24
  10. PREFACE PREREQUISITES ▸ Buy KSP ($40 on Steam) ▸ Install

    ckan ▸ Install kRPC on ckan ▸ EMA 550: Astrodynamics ▸ ME 446: Automatic Controls $24
  11. PREFACE PREREQUISITES ▸ Buy KSP ($40 on Steam) ▸ Install

    ckan ▸ Install kRPC on ckan ▸ EMA 550: Astrodynamics ▸ ME 446: Automatic Controls ▸ Install ruby correctly #%&! $24
  12. PREFACE PREREQUISITES ▸ Buy KSP ($40 on Steam) ▸ Install

    ckan ▸ Install kRPC on ckan ▸ EMA 550: Astrodynamics ▸ ME 446: Automatic Controls ▸ Install ruby correctly #%&! ▸ gem install krpc $24
  13. PREFACE PREREQUISITES ▸ Buy KSP ($40 on Steam) ▸ Install

    ckan ▸ Install kRPC on ckan ▸ EMA 550: Astrodynamics ▸ ME 446: Automatic Controls ▸ Install ruby correctly #%&! ▸ gem install krpc ▸ Write some ruby $24
  14. SPACE.FAIL:3000

  15. PROJECT 1: MERCURY HOVER

  16. MAKE A ROCKET HOVER PROBLEM STATEMENT:

  17. MAKE A ROCKET HOVER PROBLEM STATEMENT: MAKE ALTITUDE CONSTANT (AND

    SUFFICIENTLY >0)
  18. MAKE A ROCKET HOVER PROBLEM STATEMENT: MAKE ALTITUDE CONSTANT (AND

    SUFFICIENTLY >0) 1 CONTROL: THROTTLE (ALSO, VARIABLE MASS)
  19. PROJECT 1: MERCURY SOME MATHS F = m⋅a ∑ T

    − m⋅ g = m⋅a T − m⋅ g = m⋅ d dt v T − m⋅ g = m⋅ d2 dt2 x T(t) − m(t)⋅ g = m(t)⋅ d2 dt2 x(t)
  20. PROJECT 1: MERCURY SOME MATHS F = m⋅a ∑ T

    − m⋅ g = m⋅a T − m⋅ g = m⋅ d dt v T − m⋅ g = m⋅ d2 dt2 x T(t) − m(t)⋅ g = m(t)⋅ d2 dt2 x(t) Nonlinear 2nd Order
 Differential Equation
  21. PROJECT 1: MERCURY SOME MATHS F = m⋅a ∑ T

    − m⋅ g = m⋅a T − m⋅ g = m⋅ d dt v T − m⋅ g = m⋅ d2 dt2 x T(t) − m(t)⋅ g = m(t)⋅ d2 dt2 x(t) Nonlinear 2nd Order
 Differential Equation ಠ_ಠ
  22. PID CONTROLLER

  23. P I D CONTROLLER roportional ntegral erivative

  24. P I D CONTROLLER roportional ntegral erivative

  25. PROJECT 1: MERCURY NEGATIVE FEEDBACK THROTTLE

  26. PROJECT 1: MERCURY NEGATIVE FEEDBACK THROTTLE ROCKET

  27. PROJECT 1: MERCURY NEGATIVE FEEDBACK ACTUAL ALTITUDE THROTTLE ROCKET

  28. PROJECT 1: MERCURY NEGATIVE FEEDBACK ACTUAL ALTITUDE THROTTLE ROCKET PID

    CONTROLLER DESIRED ALTITUDE
  29. PROJECT 1: MERCURY NEGATIVE FEEDBACK ACTUAL ALTITUDE THROTTLE ROCKET PID

    CONTROLLER DESIRED ALTITUDE
  30. PROJECT 1: MERCURY PID CONTROLLER prev_time = Time.now dt =

    0.1 prev_error = 0 accumulated_error = 0 while true do sleep dt curr_time = Time.now error = DESIRED_ALTITUDE - current_altitude() accumulated_error += error * dt derivative = (error - prev_error) / dt set_throttle( P * error + I * accumulated_error + D * derivative ) prev_error, prev_time = error, curr_time end
  31. DEMO

  32. PROJECT 2: GEMINI ORBIT Photo courtesy of: SpaceX

  33. MAKE A ROCKET ORBIT PROBLEM STATEMENT:

  34. MAKE A ROCKET ORBIT PROBLEM STATEMENT: GO REAL HIGH, THEN

    ON THE WAY BACK DOWN, MISS
  35. OUR ROCKET

  36. First Stage OUR ROCKET

  37. OUR ROCKET Second Stage }

  38. OUR ROCKET Third Stage }

  39. ORBIT?

  40. ORBIT?

  41. ORBIT?

  42. ORBIT?

  43. ORBIT?

  44. ORBIT?

  45. ORBIT? 1 foot Austin Houston

  46. ORBIT? 1 foot Austin Houston d = 237km

  47. ORBIT? 1 foot Austin Houston d = 237km h =

    4.41km
  48. ORBIT? 1 foot Austin Houston d = 237km h =

    4.41km t = 30s
  49. ORBIT? 1 foot Austin Houston d = 237km h =

    4.41km t = 30s v = 7.9km/s
  50. ENERGIES

  51. ENERGIES Get up there m g h = E g

    h = E/m (9.81/1000) 200 1.96 MJ
  52. ENERGIES Get up there m g h = E g

    h = E/m (9.81/1000) 200 1.96 MJ Go real fast E = ½ m v2 E/m = ½ v2 ½ (7.8)2 30.4 MJ
  53. PROJECT 2: GEMINI OK, BUT HOW? ▸ Checklist! ▸ 2

    state machines: staging & control ▸ On each tick, use case-when for each state machine ▸ On each state-transition, maybe do a single thing ▸ "Pitch over while managing stages"
  54. DEMO

  55. PROJECT 3: APOLLO TO THE MUN!

  56. LAND A ROCKET ON THE MUN PROBLEM STATEMENT:

  57. LAND A ROCKET ON THE MUN PROBLEM STATEMENT: LANDING SPEED

    UNSPECIFIED; LEFT TO DEVELOPER
  58. ORBIT TRANSFERS

  59. ORBIT TRANSFERS

  60. ORBIT TRANSFERS

  61. ORBIT TRANSFERS

  62. TO THE MUN

  63. TO THE MUN

  64. PROJECT 3: APOLLO STATES 1. determining insertion burn delta v

    2. determining insertion burn location 3. waiting for insertion burn far 4. waiting for insertion burn mid 5. waiting for insertion burn near 6. insertion burning 7. finalizing insertion burn 8. transmunar orbit 9. outer munar orbit 10.mid munar orbit 11.final approach
  65. DEMO

  66. THANK YOU! Brad Grzesiak - @listrophy CEO, Bendyworks