from rawe.collocation import Coll import rocket_dae from autogen.torocketProto import toProto from autogen.rocket_pb2 import Trajectory if __name__ == "__main__": dae = rocket_dae.makeDae() N = 100 ocp = Coll(dae, nk=N, nicp=1, collPoly="RADAU", deg=4) endTime = 5 ocp.setupCollocation( endTime ) # bounds ocp.bound('thrust',(-1.3,0.9)) ocp.bound('pos',(-10,10)) ocp.bound('vel',(-10,10)) ocp.bound('mass',(0.001,1000)) # boundary conditions ocp.bound('pos',(0,0),timestep=0) ocp.bound('pos',(5,5),timestep=-1) ocp.bound('vel',(0,0),timestep=0) ocp.bound('vel',(0,0),timestep=-1) ocp.bound('mass',(1,1),timestep=0) ocp.guess("pos",0) ocp.guess("vel",0)
# specify the ode residual mass = 1.0 dae.setResidual([dae.ddt('pos') - vel, dae.ddt('vel') - (force/mass - 3.0*pos - 0.2*vel)] ) ######## make the collocation scheme ######## N = 100 ocp = Coll(dae, nk=N, nicp=1, collPoly="RADAU", deg=4) endTime = 5 ocp.setupCollocation( endTime ) # bounds ocp.bound('abspos',(0,10)) ocp.bound('pos',(-1000,1000)) ocp.bound('vel',(-100,100)) ocp.bound('force',(-30,30)) # boundary conditions ocp.bound('pos',(5,5),timestep=0) ocp.bound('pos',(0.1,0.1),timestep=-1) ocp.bound('vel',(0,0),timestep=0) ocp.bound('vel',(0,0),timestep=-1) ocp.guess("abspos",0) ocp.guess("pos",0) ocp.guess("vel",0) ocp.guess("force",0)