This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This file is part of CasADi. | |
* | |
* CasADi -- A symbolic framework for dynamic optimization. | |
* Copyright (C) 2010 by Joel Andersson, Moritz Diehl, K.U.Leuven. All rights reserved. | |
* | |
* CasADi is free software; you can redistribute it and/or | |
* modify it under the terms of the GNU Lesser General Public | |
* License as published by the Free Software Foundation; either | |
* version 3 of the License, or (at your option) any later version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
#include <ctime> | |
#include <iomanip> | |
#include <symbolic/casadi.hpp> | |
#include <symbolic/stl_vector_tools.hpp> | |
using namespace CasADi; | |
using namespace std; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
classdef Circle < Shape | |
methods | |
function self = Circle(varargin) | |
self@Shape('_swigCreate',uint64(0),false); | |
if nargin==3 && ischar(varargin{1}) && strcmp(varargin{1},'_swigCreate') | |
self.swigCPtr = varargin{2}; | |
self.swigOwn = varargin{3}; | |
else | |
% How to get working on C side? Commented out, replaed by hack below | |
%self.swigCPtr = example_wrap('new_Circle',varargin{:}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as NP | |
import casadi as C | |
def qpsolve(H,g,lbx,ubx,A=NP.zeros((0,0)),lba=NP.zeros(0),uba=NP.zeros(0)): | |
# Convert to CasADi types | |
H = C.DMatrix(H) | |
g = C.DMatrix(g) | |
lbx = C.DMatrix(lbx) | |
ubx = C.DMatrix(ubx) | |
A = C.DMatrix(A) | |
A = A.reshape((A.size1(),H.size1())) # Make sure matching dimensions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pylab import * | |
# End time | |
T = 10. | |
# Number of control intervals | |
N = 20 | |
# Number of Runge-Kutta 4 steps per interval and step size | |
NK = 20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from casadi import * | |
from numpy import * | |
import matplotlib.pyplot as plt | |
N = 20 # Control discretization | |
T = 10.0 # End time | |
# Declare variables (use scalar graph) | |
u = SX.sym("u") # control | |
x = SX.sym("x",2) # states |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from casadi import * | |
from numpy import * | |
import matplotlib.pyplot as plt | |
N = 20 # Control discretization | |
T = 10.0 # End time | |
# Declare variables (use scalar graph) | |
u = SX.sym("u") # control | |
x = SX.sym("x",2) # states |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import casadi | |
import numpy | |
from casadi import * | |
# Initial and final position | |
px0 = 0.0; py0 = 1.5 | |
pxF = 20.0; pyF = 0.0 | |
# Time horizon and discretization | |
T = 3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from casadi import * | |
from casadi.tools import * | |
import numpy | |
from numpy import cos,sin, vstack, hstack, multiply | |
class Quadcopter: | |
""" | |
Quadcopter model |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as NP | |
from casadi import * | |
# Choose collocation points | |
d = 4 # Degree | |
tau_root = collocationPoints(d,"legendre") | |
# Calculate coefficients | |
C = DMatrix.nan(d+1,d+1) # For the collocation equation | |
D = DMatrix.nan(d+1) # For the continuity equation |
OlderNewer