# You should have received a copy of the GNU Lesser General Public License # along with rawesome. If not, see <http://www.gnu.org/licenses/>. import matplotlib.pyplot as plt import rawe 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)
[pos,vel] = dae.addX( ["pos","vel"] ) dae.addX('abspos') force = dae.addU( "force" ) # some extra outputs for the dae model dae['force_over_pos'] = force/pos # 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)