Skip to content

Instantly share code, notes, and snippets.

View alphaville's full-sized avatar
:octocat:
(De)coding

Pantelis Sopasakis alphaville

:octocat:
(De)coding
View GitHub Profile
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Mar 30 20:41:07 2023
@author: Pantelis Sopasakis
"""
import numpy as np
import scipy.special as sp
#include <Arduino.h>
#include <Wire.h>
#include "Adafruit_BME680.h"
#include "WiFi.h"
#include "WebServer.h"
/* CHANGE THESE: */
#define NETWORK_SSID "YOUR_WIFI_SSID_HERE"
#define NETWORK_PASSWD "YOUR_WIFI_PASSWORD_HERE"
#define DEVICE_NAME "YellowDragon"
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
#include <Arduino.h>
/**
* Choose the GPIO port
* Wiring:
* ESP32-GND to LED-
* ESP-G2 to LED+
*/
#define LED 2
@alphaville
alphaville / myRouth.m
Last active March 22, 2022 21:47
Routh's tabulation
function R = myRouth(b)
%% ROUTH-HURWITZ Array
%
% Examples:
%
% 1. P = s^4 + 10*s^3 + 35*s^2 + 50*s + 24 ;
% R = myRouth( [1 10 35 50 24] )
%
% 2. syms a b c d s , P = s^4 + a*s^3 + b*s^2 + c*s + d ;
% R = myRouth( [1 a b c d] )
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import solve_ivp
# constant control action:
u = 0.5
# define the system dynamics
def system_dynamics(_t, z):
@alphaville
alphaville / task1.py
Last active May 27, 2023 00:21
Simulator: Bicycle model + Discrete-time PID controller in Python
from scipy.integrate import solve_ivp
import numpy as np
# Define the system dynamics as a function of the
# form f(t, z)
def dynamics(_t, z):
return np.sin(z)
import math
from scipy.integrate import solve_ivp
class Car:
def __init__(self,
length=2.5,
velocity=5,
x_pos=0,
@alphaville
alphaville / pid.c
Last active March 11, 2022 02:37
Simple C implementation of PID controller. MIT Licence.
#include "pid.h"
pid_controller_t new_pid(real_t Kp, real_t Ki, real_t Kd)
{
pid_controller_t ctrl;
ctrl.Kp = Kp;
ctrl.Ki = Ki;
ctrl.Kd = Kd;
ctrl.sum_errors = 0.0;
ctrl.previous_error = 0.0;
@alphaville
alphaville / icallocator.c
Last active September 24, 2019 18:53
Memory allocator in C for Optimization Engine
#include <stdio.h>
#include <stdlib.h>
#ifndef casadi_real
#define casadi_real double
#endif
#ifndef casadi_int
#define casadi_int long long int
#endif