静止衛星投入

Last-modified: 2018-05-15 (火) 20:07:03

仕様

before

  • ほぼ静止軌道にいる
  • ほぼ目標経度の上にいる

after

  • 静止軌道
  • 目標経度の上

となるようにマニューバーを実行します。

制限事項

  • スロットル操作が上手ではありません。スラストリミッターを指定するなどして推力を絞ってください。
  • エンジンを使用します。RCSでは使用できません。
  • スクリプト実行前にSASをオフにしてください。

使用方法

kOSのスクリプトの保存と実行方法はこちらを参考にしてください。

スクリプト:

// get longtitude to move
set target_longtitude to 0.
print "Input target longtitude: ".
set sign to 1.
set ch to terminal:input:getchar().
UNTIL ch = terminal:input:RETURN
{
	if ch = "-"
	{
		set sign to -1.
	}
	else
	{
		set target_longtitude to target_longtitude*10 + ch:tonumber().
	}
	set ch to terminal:input:getchar().
}
set target_longtitude to sign * target_longtitude.
print "Target longtitude[deg] = ".
print target_longtitude.
set current_longtitude to ship:LONGITUDE.
print "Current longtitude[deg] = ".
print current_longtitude.
set current_orbitalperiod to ship:ORBIT:PERIOD.
print "Current orbitalperiod[sec] = ".
print current_orbitalperiod.
set body_rotationperiod to ship:BODY:ROTATIONPERIOD.
set goal_orbitalperiod to ship:BODY:ROTATIONPERIOD.
print "Goal orbitalperiod[sec] = ".
print goal_orbitalperiod.
if target_longtitude > current_longtitude
{
	set ratio to ( target_longtitude-current_longtitude)/360.
	set target_orbitalperiod to body_rotationperiod*(1-ratio).
	print "Target orbitalperiod[sec] = ".
	print target_orbitalperiod.
	lock steering to heading( 270, 0).
	wait 10.
	lock throttle to 1.
	wait until ship:ORBIT:PERIOD < target_orbitalperiod.
	lock throttle to 0.
	wait 3.
	set target_time to time:seconds + target_orbitalperiod.
	kuniverse:timewarp:warpto( target_time).
	wait until time:seconds > target_time.
	lock steering to heading( 90, 0).
	wait 10.
	lock throttle to 1.
	wait until ship:ORBIT:PERIOD > body_rotationperiod.
	lock throttle to 0.
}
else
{
	set ratio to ( current_longtitude-target_longtitude)/360.
	set target_orbitalperiod to body_rotationperiod*(1+ratio).
	print "Target orbitalperiod[sec] = ".
	print target_orbitalperiod.
	lock steering to heading( 90, 0).
	wait 10.
	lock throttle to 1.
	wait until ship:ORBIT:PERIOD > target_orbitalperiod.
	lock throttle to 0.
	wait 3.
	set target_time to time:seconds + target_orbitalperiod.
	kuniverse:timewarp:warpto( target_time).
	wait until time:seconds > target_time.
	lock steering to heading( 270, 0).
	wait 10.
	lock throttle to 1.
	wait until ship:ORBIT:PERIOD < body_rotationperiod.
	lock throttle to 0.
}

スクリプトを実行すると目標とする経度を聞かれるので数字で入力してください。
単位は度で、先頭に-を付けると西経と解釈されます。

使用例

いまロケットは西経175度上空にいますが
screenshot68.jpg

スクリプトを実行して-170上空への移動を指示すると
一周回ってこうなります。
screenshot69.jpg

改良版

kOSはPID制御ができるのでこれを利用すると精度が改善する。

// get longtitude to move
set target_longtitude to 0.
print "Input target longtitude: ".
set sign to 1.
set ch to terminal:input:getchar().
UNTIL ch = terminal:input:RETURN
{
	if ch = "-"
	{
		set sign to -1.
	}
	else
	{
		set target_longtitude to target_longtitude*10 + ch:tonumber().
	}
	set ch to terminal:input:getchar().
}
set target_longtitude to sign * target_longtitude.
print "Target longtitude[deg] = ".
print target_longtitude.
set current_longtitude to ship:LONGITUDE.
print "Current longtitude[deg] = ".
print current_longtitude.
set current_orbitalperiod to ship:ORBIT:PERIOD.
print "Current orbitalperiod[sec] = ".
print current_orbitalperiod.
set body_rotationperiod to ship:BODY:ROTATIONPERIOD.
set goal_orbitalperiod to ship:BODY:ROTATIONPERIOD.
print "Goal orbitalperiod[sec] = ".
print goal_orbitalperiod.
if target_longtitude > current_longtitude
{
	set ratio to ( target_longtitude-current_longtitude)/360.
	set target_orbitalperiod to body_rotationperiod*(1-ratio).
	print "Target orbitalperiod[sec] = ".
	print target_orbitalperiod.
	lock steering to heading( 270, 0).
	wait 10.
	set PID to pidloop( 0.01, 0.001, 0.01, -1, 0).
	set PID:SETPOINT to target_orbitalperiod.
	until ship:ORBIT:PERIOD < target_orbitalperiod
	{
		set t to -PID:UPDATE( TIME:SECONDS, ship:ORBIT:PERIOD).
		lock throttle to t.
		wait 0.1.
	}
	lock throttle to 0.
	wait 3.
	set target_time to time:seconds + target_orbitalperiod.
	kuniverse:timewarp:warpto( target_time).
	wait until time:seconds > target_time.
	lock steering to heading( 90, 0).
	wait 10.
	set PID to pidloop( 0.01, 0.001, 0.01, 0, 1).
	set PID:SETPOINT to body_rotationperiod.
	until ship:ORBIT:PERIOD > body_rotationperiod
	{
		set t to PID:UPDATE( TIME:SECONDS, ship:ORBIT:PERIOD).
		lock throttle to t.
		wait 0.1.
	}
	lock throttle to 0.
}
else
{
	set ratio to ( current_longtitude-target_longtitude)/360.
	set target_orbitalperiod to body_rotationperiod*(1+ratio).
	print "Target orbitalperiod[sec] = ".
	print target_orbitalperiod.
	lock steering to heading( 90, 0).
	wait 10.
	set PID to pidloop( 0.01, 0.001, 0.01, 0, 1).
	set PID:SETPOINT to target_orbitalperiod.
	until ship:ORBIT:PERIOD > target_orbitalperiod
	{
		set t to PID:UPDATE( TIME:SECONDS, ship:ORBIT:PERIOD).
		lock throttle to t.
		wait 0.1.
	}
	lock throttle to 0.
	wait 3.
	set target_time to time:seconds + target_orbitalperiod.
	kuniverse:timewarp:warpto( target_time).
	wait until time:seconds > target_time.
	lock steering to heading( 270, 0).
	wait 10.
	set PID to pidloop( 0.01, 0.001, 0.01, -1, 0).
	set PID:SETPOINT to body_rotationperiod.
	until ship:ORBIT:PERIOD < body_rotationperiod
	{
		set t to -PID:UPDATE( TIME:SECONDS, ship:ORBIT:PERIOD).
		lock throttle to t.
		wait 0.1.
	}
	lock throttle to 0.
}

コメント