Reddy

PEGAS - Powered Explicit Guidance Ascent System - devlog

Recommended Posts

On 2018/2/18 at 3:52 AM, Reddy said:

It sounds like a common problem with kOS and RCS steering. Try to run something like this:


LOCK STEERING TO RETROGRADE.
WAIT 20.
UNLOCK STEERING.

and see what happens. If you observe the same symptoms, it's the kOS fault (or your vehicle, but I'm not sure).

 

@LAND ASAP I see you're trying to launch to zero inclination orbit. Where is your launch site located?

Thank you for your reply! 

I launch the rocket in Cape Canaveral. Is it where the problem lies in?

Should I use kourou for such launch?

Share this post


Link to post
Share on other sites

One more question. After receiving your reply, I tried to launch the vehicle without setting the inclination in the mission config. Still converging most of the time time. I have tried times and times again.

 But when it works, it’s really amazing!

 Or should I submit it to github? Thanks!:kiss:

Edited by LAND ASAP

Share this post


Link to post
Share on other sites

OK, so, after seeing this I've actually started reading articles in Journal of Guidance, Control and Dynamics. Damn you, science!

Share this post


Link to post
Share on other sites

Just a quick question,  tried to use this with the Shuttle Lifting Body mod, which uses the Mk3 cockpit as the control point.  Got the following error: "CONTROLFROM command found a generic part value."  Am I doing something wrong?  or does this not work with manned rockets?

Share this post


Link to post
Share on other sites

I'm working on my own PEG implementation in KOS as a side project. I've got it sort of working, I'm having issues with the delta v - it's off by a factor of about 5. It starts decreasing towards zero, then around 30 seconds before cutoff, jumps randomly by huge amounts, changing sign. As far as I can tell I've implemented the algorithm just as described in the NASA paper / orbiter notes. If I comment out the derivative terms it basically works. Anyone here want to take a peek at my script and see if anything jumps out?

	function GuidanceLoop
{    
    SetOldTime(GetTimer()).
    SetTimer(time:seconds()).
	    local T is GetT().
    local r_v is -ship:body:position.
    local r is r_v:mag.
    //solve for guidance parameters A and B    
    local b0 is -ve() * ln(1 - min(0.9999, T / GetTau())). 
    local b1 is b0 * GetTau() - ve() * t.
    local c0 is b0 * t - b1.
    local c1 is c0 * GetTau() - ve() * t^2 / 2.
    local M_B_0 is r_d_t - verticalspeed. 
    local M_B_1 is r_t - r - verticalspeed * T. 
    //update steering parameters
    if T > 10
    {
        SetB(((M_B_1 / c0) - (M_B_0 / b0)) / ((c1 / c0) - (b1 / b0))).
        SetA((M_B_0 / b0) - GetB() * b1 / b0).
        SetOldA(GetA() + delta_t * GetB()).
        SetOldB(GetB()).
    }
    SetOldT(T - delta_t).
    
    //update state vectors
    local h_v is vcrs(r_v, ship:velocity:orbit). 
    local theta_unit is vcrs(h_v:normalized, r_v:normalized).
    local delta_h is h_t - h_v:mag.
    local r_mean is (r_t + r) / 2. 
    
    //performance
    local omega is vdot(ship:velocity:orbit, theta_unit) / r.
    local C_t is C(r_t, omega_t, GetOldT(), GetTau()).
    SetTau(tau()).
    if T > 10
    {
        SetC(C(r, omega, 0, GetTau())).
    }
    
    //calculate delta v
    local f_r is GetOldA() + GetC(). 
    local f_r_d is GetOldB() + (C_t - f_r) / GetOldT(). 
    local f_theta is 1 - f_r^2 / 2.
    local f_theta_d is -f_r * f_r_d.
    local f_theta_d2 is - f_theta_d^2 / 2.
    //local delta_v is (delta_h / r_mean) + ve()* T * (f_theta_d + f_theta_d2) * GetTau() + (f_theta_d2 * ve() * T^2 / 2 ). 
    //set delta_v to delta_v / (f_theta + f_theta_d * GetTau() + f_theta_d2 * GetTau()^2).
    local delta_v is (delta_h / r_mean) / f_theta.
    SetT(GetTau() * (1 - constant:e^(-delta_v / ve()))).
}
	

 

Share this post


Link to post
Share on other sites
11 hours ago, Desdinova said:

I'm working on my own PEG implementation in KOS as a side project. I've got it sort of working, I'm having issues with the delta v - it's off by a factor of about 5. It starts decreasing towards zero, then around 30 seconds before cutoff, jumps randomly by huge amounts, changing sign. As far as I can tell I've implemented the algorithm just as described in the NASA paper / orbiter notes.

That isn't PEG, that is the old Surveyor-era Atlas-Centaur guidance that precedes both IGM and PEG.  The correct reference for that is here:

https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19660006073.pdf

The orbiter notes are incorrect and buggy, and I can't recall exactly where (it's been over a year and I've forgotten the algorithm, not to mention the specific bugs in that wiki).  An implementation of that code that works is here:

https://github.com/MuMech/MechJeb2/blob/7a78a57740a37eeb5509e2c3f8d09c012b347648/MechJeb2/MechJebModuleAscentPEG.cs

(Yes that file is still named "PEG" but I named it incorrectly ages ago)

Where my code agrees with the NASA code and disagrees with OrbiterWiki you should not use the Wiki pseudo-code (where my code disagrees with the NASA paper, I'd bet I've got bugs and NASA knew what they were doing...)

Note that I never got the yaw steering implemented.  The N-stage summations in Terens paper are brutal to implement and debug to eliminate typos.  The actual PEG algorithm is easier to implement fully.

Share this post


Link to post
Share on other sites
On 9/23/2018 at 11:52 PM, Jim DiGriz said:

That isn't PEG, that is the old Surveyor-era Atlas-Centaur guidance that precedes both IGM and PEG.  The correct reference for that is here:

https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19660006073.pdf

The orbiter notes are incorrect and buggy, and I can't recall exactly where (it's been over a year and I've forgotten the algorithm, not to mention the specific bugs in that wiki).  An implementation of that code that works is here:

https://github.com/MuMech/MechJeb2/blob/7a78a57740a37eeb5509e2c3f8d09c012b347648/MechJeb2/MechJebModuleAscentPEG.cs

(Yes that file is still named "PEG" but I named it incorrectly ages ago)

Where my code agrees with the NASA code and disagrees with OrbiterWiki you should not use the Wiki pseudo-code (where my code disagrees with the NASA paper, I'd bet I've got bugs and NASA knew what they were doing...)

Note that I never got the yaw steering implemented.  The N-stage summations in Terens paper are brutal to implement and debug to eliminate typos.  The actual PEG algorithm is easier to implement fully.

 

My implementation is almost identical to yours, but in MATLAB. I'm getting strange results - I believe it converges as Tgo is consistenly reducing, but the fr term begins to go crazy and ends up being >1, clearly impossible! Did you ever experience behaviour like this? It should be near zero as my velocity vector is near the local horizontal and the vehicle isn't far off the target insertion altitude, but instead it begins to rise hence adding to the radial component.

Share this post


Link to post
Share on other sites
22 hours ago, GRAVITY_TURN said:

 

My implementation is almost identical to yours, but in MATLAB. I'm getting strange results - I believe it converges as Tgo is consistenly reducing, but the fr term begins to go crazy and ends up being >1, clearly impossible! Did you ever experience behaviour like this? It should be near zero as my velocity vector is near the local horizontal and the vehicle isn't far off the target insertion altitude, but instead it begins to rise hence adding to the radial component.

If that's in the last couple of seconds, then its terminal guidance issues, you need to freeze guidance at some point before the end or you get swamped by errors.  Basically the same problem that MJ has when it has nearly burned a maneuver node to zero and if you have the deltav m/s tuned up too high it'll constantly try to 'hunt' the maneuver node and due to errors can never burn it down to exactly 0 m/s.  All guidance has this problem.

Share this post


Link to post
Share on other sites
On 10/21/2018 at 7:16 PM, Jim DiGriz said:

If that's in the last couple of seconds, then its terminal guidance issues, you need to freeze guidance at some point before the end or you get swamped by errors.  Basically the same problem that MJ has when it has nearly burned a maneuver node to zero and if you have the deltav m/s tuned up too high it'll constantly try to 'hunt' the maneuver node and due to errors can never burn it down to exactly 0 m/s.  All guidance has this problem.

The issue seems to be occuring earlier than that. Tgo is around 59 seconds before suddently going crazy, with the fr term blowing up too. Very strange behaviour as the plot for Tgo is linear up until this point.

Share this post


Link to post
Share on other sites
This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.