Skip to content

Instantly share code, notes, and snippets.

View jgillis's full-sized avatar

Joris Gillis jgillis

View GitHub Profile
Contributor's Statement of Intellectual Property Transfer
I certify that:
(a) I have read and understood the statement below on Ownership and Transfer of Intellectual Property;
(b) for any contribution I make to the CasADi project, I will make all reasonable efforts to determine the legal owners of the contribution, and I will obtain the permission of the owners of the contribution to make the contribution available under the terms of this agreement;
(c) if I am employed, I have discussed contributing to CasADi with my employer and have obtained their permission to transfer the intellectual property rights or have determined that they do not assert ownership rights to my contributions;
(d) I hereby transfer and assign all rights, title, and interest, including all intellectual property rights, in any contributions that I make to the CasADi project, to the CasADi copyright holders;
(e) I will not knowingly submit any contribution of which I am not the owner or for which I do not have the owner's permission, n
@jgillis
jgillis / debug_fatrop.m
Last active November 16, 2024 20:24
Fatrop debugging tools
% 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
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 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
@jgillis
jgillis / scalable.py
Last active April 2, 2024 10:11
bspline fitting
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
@jgillis
jgillis / demo.py
Created November 21, 2023 15:22
is_constraint_added
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)
@jgillis
jgillis / outline.py
Last active September 7, 2023 08:16
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
@jgillis
jgillis / demo.py
Last active May 28, 2023 21:27
How to do np.interp in CasADi
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))
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,...
from casadi import *
x = MX.sym("x",30)
x0 = DM.rand(x.shape)
print("Reference approach")
# Repetitive
c = 0