Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
//==CMLS SUICIDE BURN SCRIPT== SET scriptVersion TO "v0.2.1". //0.1.0 // - First stable version // //0.1.1 //--Major improvements-- // - Experimental PI controller // - Automatic engine activation and deactivation handling // - Automatic Kp adjustment based on TWR //--Minor improvements-- // - Exported initial engine setup to shutdown script // - Added PILOTMAINTHROTTLE control to ensure that the // booster doesn't revert to half or full throttle once // the script ends // //0.2.0 //--Major improvements-- // - Automatic opMode checking to handle the different // types of cores (side booster vs S1) // - Reverted to P controller for simplicity; PI controller // did not improve results and was difficult to tune // - Automatic handling of occasionally-necessary // re-entry burn based on speed and remaining delta-v //--Minor improvements-- // - Replaced shutdown script with the same CMLSeng script // that handles the engine tagging and shutdown for the // launch sequence. Updated launch scripts to // automatically copy that script to the core/booster // computers // - Added remaining delta-v and booster type readouts // - Moved altitude triggers outside of control loop // //0.2.1 //--Major improvements-- // - Integrated automatic re-entry burn into the terminal // guidance control block; each action in the sequence of // events is now part of one overall trigger block //--Minor improvements-- // - Changed delta-v remaining readout to always show sea- // level delta-v // - Further tuning of P controller //~~~~~SPLASHSCREEN~~~~~ SET TERMINAL:WIDTH TO 50. SET TERMINAL:HEIGHT TO 25. CLEARSCREEN. PRINT "==========COYOTE MLS SUICIDE BURN SCRIPT==========". PRINT "----------------------" + scriptVersion + "----------------------". WAIT 1. PRINT "Initializing...". RUN CMLSeng. //~~~~~Variable Declaration~~~~~ SET nextLine TO 7. //Tracks next line that events should print at in the event log IF SHIP:PARTSTAGGED("S1Alpha"):LENGTH > 0 { SET opMode TO "Core". } ELSE IF SHIP:PARTSTAGGED("LBAlpha"):LENGTH > 0 { SET opMode TO "LeftBooster". } ELSE IF SHIP:PARTSTAGGED("RBAlpha"):LENGTH > 0 { SET opMode TO "RightBooster". }. //IF-ELSE opMode FOR eng IN engAll { IF eng:GETMODULE("ModuleEnginesFX"):HASEVENT("Shutdown Engine") { //Shutdown all engines eng:GETMODULE("ModuleEnginesFX"):DOEVENT("Shutdown Engine"). }. }. IF opMode = "Core" { S1Alpha[0]:GETMODULE("ModuleEnginesFX"):DOEVENT("Activate Engine"). //Activate alpha-group engines FOR eng IN S1Bravo { eng:GETMODULE("ModuleEnginesFX"):DOEVENT("Activate Engine"). //Activate bravo-group engines }. //FOR eng } ELSE IF opMode = "LeftBooster" { LBAlpha[0]:GETMODULE("ModuleEnginesFX"):DOEVENT("Activate Engine"). //Activate alpha-group engines FOR eng IN LBBravo { eng:GETMODULE("ModuleEnginesFX"):DOEVENT("Activate Engine"). //Activate bravo-group engines }. //FOR eng } ELSE IF opMode = "RightBooster" { RBAlpha[0]:GETMODULE("ModuleEnginesFX"):DOEVENT("Activate Engine"). //Activate alpha-group engines FOR eng IN RBBravo { eng:GETMODULE("ModuleEnginesFX"):DOEVENT("Activate Engine"). //Activate bravo-group engines }. //FOR eng }. //IF opMode RCS ON. GEAR OFF. SET thrott TO 0. SET I TO 0. SET SBSA TO -10000. SET SBSAmargin TO 10. //Margin to allow for burns that start a little too late LOCK dvRemain TO (285 * 9.82) * LN(SHIP:MASS / SHIP:DRYMASS). //Keeps track of remaining delta-v LOCK TWR TO SHIP:MAXTHRUST / (SHIP:MASS * SHIP:SENSORS:GRAV:MAG). //Keeps track of TWR LOCK vsActual TO SHIP:VERTICALSPEED. SET radaltOffset TO 18.4. //Fixed offset amount from probe core to landing legs LOCK radaltActual TO (ALT:RADAR - radaltOffset). //Uses offset amount to track distance from bottom of landing legs to ground. SET vsSetpoint TO -10000. //Starts out really low so that the PI doesn't try to adjust the vertical speed whilst falling back to the launch site WAIT 0.5. //Readout header CLEARSCREEN. PRINT "==========COYOTE MLS MK1R SUICIDE BURN============" AT(0,0). PRINT "TWR: " AT(0,2). //Readout at 6,2 PRINT "BSA: " AT(16,2). //Readout at 22,2 PRINT "ARA: " AT(33,2). //Readout at 39,2 PRINT "OPM: " AT(0,3). //Readout at 6,3 PRINT opMode AT(6,3). //opMode readout; static from script start PRINT "DVR: " AT(33,3). //Readout at 39,3 PRINT "--------------------EVENT LOG---------------------" AT(0,5). PRINT "Stage ready for boostback burn" AT(0,nextLine). SET nextLine to nextLine + 1. //~~~~~Boostback completion~~~~~ WAIT UNTIL vsActual < 0. //Wait until apogee WAIT 30. //Wait another 10 seconds to allow for late/extended boostback burns FOR eng IN S1Bravo { eng:GETMODULE("ModuleEnginesFX"):DOEVENT("Shutdown Engine"). //Shutdown bravo-group engines, this leaves the single alpha engine running }. FOR eng IN LBBravo { eng:GETMODULE("ModuleEnginesFX"):DOEVENT("Shutdown Engine"). }. FOR eng IN RBBravo { eng:GETMODULE("ModuleEnginesFX"):DOEVENT("Shutdown Engine"). }. PRINT "Stage prepared for re-entry." AT(0,nextLine). SET nextLine TO nextLine + 1. //~~~~~Burn control~~~~~ WHEN ALTITUDE < 40000 THEN { //Check performed at 40km IF dvRemain >= 500 AND VELOCITY:SURFACE:MAG > 1400 { //If the velocity is high and enough dv remains... PRINT "Re-entry velocity high;" AT(0,nextLine). SET nextLine TO nextLine + 1. PRINT "Performing re-entry burn" AT(0,nextLine). SET nextLine TO nextLine + 1. SET SHIP:CONTROL:PILOTMAINTHROTTLE TO 0.5. //...set the throttle to half... WHEN dvRemain < 500 THEN { SET SHIP:CONTROL:PILOTMAINTHROTTLE TO 0. //...and burn until 500dv remains PRINT "Re-entry burn complete" AT(0,nextLine). SET nextLine TO nextLine + 1. }. //WHEN dvRemain } ELSE IF dvRemain < 500 AND VELOCITY:SURFACE:MAG > 1400 //If there's not enough dv left, don't burn. Just pray. PRINT "Re-entry velocity high;" AT(0,nextLine). SET nextLine TO nextLine + 1. PRINT "Delta-V margin below threshold; no re-entry burn" AT(0,nextLine). SET nextLine TO nextLine + 1. }. //IF-ELSE WHEN ALTITUDE < 10000 THEN { LOCK SBSA TO (((vsActual^2) / (2 * (SHIP:MAXTHRUST / SHIP:MASS) - SHIP:SENSORS:GRAV:MAG)) + SBSAmargin). //Determines suicide burn start altitude SET SHIP:CONTROL:PILOTMAINTHROTTLE TO 0. //Stops re-entry burn if it's still going PRINT "Atmospheric re-entry complete" AT(0,nextLine). SET nextLine TO nextLine + 1. WHEN radaltActual < (SBSA + 250) THEN { //Waits until 250m above SBSA SAS ON. //Vehicle should be completely vertical and with no horizontal velocity at this point PRINT "Prepare for suicide burn." AT(0,nextLine). SET nextLine TO nextLine + 1. WHEN radaltActual < SBSA THEN { //Waits until SBSA LOCK vsSetpoint TO -5. //Stage will burn fully until 5m/s descent LOCK THROTTLE TO thrott. GEAR ON. PRINT "Suicide burn initiated. Gear down." AT(0,nextLine). SET nextLine TO nextLine + 1. WHEN radaltActual < 3 THEN { //Below 3 meters, it switches to 1m/s descent LOCK vsSetpoint TO -1. }. //WHEN < 3 }. //WHEN < SBSA }. //WHEN < 250 + SBSA }. //WHEN altitude }. //WHEN surf velocity SAS OFF. LOCK Kp TO MAX(0.001,((TWR * -0.1) + 1.1)). //Adjusts the gain based on the TWR LOCK P to (vsSetpoint - vsActual). //Error - difference between desired VS and actual VS LOCK dthrott TO Kp * P. //~~~~~P Loop/Readouts~~~~~ UNTIL STATUS = "LANDED" { //Loops until touchdown SET thrott TO MIN(1, MAX(0,thrott + dthrott)). PRINT ROUND(TWR,1) + " " AT(6,2). //Prints TWR PRINT ROUND(SBSA,1) + " " AT(22,2). //Prints suicide burn start alt PRINT ROUND(radaltActual,1) + " " AT(39,2). //Prints the radar altitude adjusted for the landing legs PRINT ROUND(dvRemain) + " " AT(39,3). //Prints remaining DV WAIT 0.001. }. //UNTIL PRINT "Touchdown!" at (0,nextLine). SET nextLine TO nextLine + 1. UNLOCK THROTTLE. SAS OFF. RCS OFF. SET SHIP:CONTROL:PILOTMAINTHROTTLE TO 0. WAIT 3. CLEARSCREEN.
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
Untitled
JSON | 1 hour ago | 1.15 KB
2026_06_updated_lune
10 hours ago | 1.82 KB
other setups
13 hours ago | 0.15 KB
Untitled
13 hours ago | 0.16 KB
DROP20
19 hours ago | 1.44 KB
API 'ping' test
Python | 1 day ago | 0.53 KB
Slide notes
1 day ago | 2.46 KB
AMP floater example implementation
1 day ago | 2.32 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!