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
% Load the matrices from files | |
actual = casadi.Sparsity.from_file('debug_fatrop_actual.mtx'); | |
A = casadi.Sparsity.from_file('debug_fatrop_A.mtx'); | |
B = casadi.Sparsity.from_file('debug_fatrop_B.mtx'); | |
C = casadi.Sparsity.from_file('debug_fatrop_C.mtx'); | |
D = casadi.Sparsity.from_file('debug_fatrop_D.mtx'); | |
I = casadi.Sparsity.from_file('debug_fatrop_I.mtx'); | |
errors = row(casadi.Sparsity.from_file('debug_fatrop_errors.mtx')); | |
% Create a new figure |
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 * | |
# Example on how to use the DaeBuilder class | |
# Joel Andersson, UW Madison 2017 | |
# Start with an empty DaeBuilder instance | |
dae = DaeBuilder('rocket') | |
# Add input expressions |
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 was automatically generated by CasADi 3.6.5+. | |
* It consists of: | |
* 1) content generated by CasADi runtime: not copyrighted | |
* 2) template code copied from CasADi source: permissively licensed (MIT-0) | |
* 3) user code: owned by the user | |
* | |
*/ | |
#ifdef __cplusplus | |
extern "C" { | |
#endif |
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 * | |
# Generate 3D data to fit | |
x = np.linspace(0,2,10) | |
y = np.linspace(2,4,10) | |
z = np.linspace(3,5,10) | |
[X,Y,Z] = np.meshgrid(x,y,z) | |
xyz_flat = np.vstack((X.ravel(),Y.ravel(),Z.ravel())).T |
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 * | |
opti = Opti() | |
x = opti.variable(10) | |
y = opti.variable(10) | |
opti.subject_to(x>=0) | |
opti.subject_to(x+y==0) | |
opti.subject_to(y>=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
m = 10 # Limite memory size | |
x_latest = MX.sym("x_latest",nx) | |
g_latest = MX.sym("g_latest",nx) | |
x_prev = MX.sym("x_prev",nx) | |
g_prev = MX.sym("g_prev",nx) | |
s_latest = x_latest-x_prev | |
y_latest = g_latest-g_prev |
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 as cs | |
import numpy as np | |
xp = [1, 2, 3] | |
fp = [3, 2, 0] | |
x = [2.5,1.1] | |
print(np.interp(x=x,xp=xp,fp=fp)) |
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
XYZ_ref = [ simOut.EndEffector_AbsPos{1}.Values.Data,simOut.EndEffector_AbsPos{2}.Values.Data,simOut.EndEffector_AbsPos{3}.Values.Data ]'; | |
Nsim = size(Gantry_out_D.Data,1); | |
XYZ = zeros(3,Nsim); | |
for k=1:Nsim | |
XYZ(:,k) = ForwardKinematicsFun(Gantry_out_D.Data(k,2),... | |
Axis1_Out_D.Data(k,2)/180*pi,... | |
Axis2_Out_D.Data(k,2)/180*pi,... | |
Axis3_Out_D.Data(k,2)/180*pi,... | |
Axis4_Out_D.Data(k,2)/180*pi,... |
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 * | |
x = MX.sym("x",30) | |
x0 = DM.rand(x.shape) | |
print("Reference approach") | |
# Repetitive | |
c = 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
import casadi | |
from casadi import * | |
from casadi.casadi import OPTI_INEQUALITY, Opti_bounded | |
import matplotlib.pyplot as plt | |
# https://epubs.siam.org/doi/pdf/10.1137/16M1062569 | |
m1 = 1 | |
m2 = 0.3 |
NewerOlder