mirror of
https://gitlab.com/lander-team/lander-cpp.git
synced 2025-06-16 07:06:51 +00:00
Resolve "Implement CI/CD"
This commit is contained in:
parent
e18a0f03f7
commit
192ebffee4
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
*.exe
|
||||||
|
*.csv
|
||||||
|
output
|
||||||
|
public
|
47
.gitlab-ci.yml
Normal file
47
.gitlab-ci.yml
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
# This file is a template, and might need editing before it works on your project.
|
||||||
|
# To contribute improvements to CI/CD templates, please follow the Development guide at:
|
||||||
|
# https://docs.gitlab.com/ee/development/cicd/templates.html
|
||||||
|
# This specific template is located at:
|
||||||
|
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/C++.gitlab-ci.yml
|
||||||
|
|
||||||
|
# use the official gcc image, based on debian
|
||||||
|
# can use verions as well, like gcc:5.2
|
||||||
|
# see https://hub.docker.com/_/gcc/
|
||||||
|
|
||||||
|
|
||||||
|
build:
|
||||||
|
image: gcc
|
||||||
|
stage: build
|
||||||
|
script:
|
||||||
|
- mkdir public
|
||||||
|
- g++ ./src/main.cpp -I include -o ./public/sim.out
|
||||||
|
- ./public/sim.out
|
||||||
|
- mv simOut.csv public
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- public
|
||||||
|
|
||||||
|
plots:
|
||||||
|
# stage: build
|
||||||
|
image: python:3.9-buster
|
||||||
|
dependencies:
|
||||||
|
- build
|
||||||
|
script:
|
||||||
|
- pip install --no-cache-dir -U -r ./pythonHelpers/requirements.txt
|
||||||
|
- python ./pythonHelpers/plots.py
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- public
|
||||||
|
|
||||||
|
pages:
|
||||||
|
stage: deploy
|
||||||
|
dependencies:
|
||||||
|
- build
|
||||||
|
- plots
|
||||||
|
script:
|
||||||
|
- ""
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- public
|
||||||
|
only:
|
||||||
|
- master
|
0
.vscode/.gitkeep
vendored
0
.vscode/.gitkeep
vendored
26
.vscode/tasks.json
vendored
26
.vscode/tasks.json
vendored
@ -9,31 +9,9 @@
|
|||||||
"-g",
|
"-g",
|
||||||
"${workspaceFolder}\\src\\main.cpp",
|
"${workspaceFolder}\\src\\main.cpp",
|
||||||
"-o",
|
"-o",
|
||||||
"${workspaceFolder}\\build\\debug\\main.exe",
|
"${workspaceFolder}\\main.exe",
|
||||||
"-I",
|
"-I",
|
||||||
"${workspaceFolder}\\include",
|
"${workspaceFolder}\\include"
|
||||||
],
|
|
||||||
"options": {
|
|
||||||
"cwd": "${fileDirname}"
|
|
||||||
},
|
|
||||||
"problemMatcher": [
|
|
||||||
"$gcc"
|
|
||||||
],
|
|
||||||
"group": {
|
|
||||||
"kind": "build",
|
|
||||||
"isDefault": true
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "cppbuild",
|
|
||||||
"label": "Release",
|
|
||||||
"command": "g++",
|
|
||||||
"args": [
|
|
||||||
"${workspaceFolder}\\src\\main.cpp",
|
|
||||||
"-o",
|
|
||||||
"${workspaceFolder}\\build\\release\\main.exe",
|
|
||||||
"-I",
|
|
||||||
"${workspaceFolder}\\include",
|
|
||||||
],
|
],
|
||||||
"options": {
|
"options": {
|
||||||
"cwd": "${fileDirname}"
|
"cwd": "${fileDirname}"
|
||||||
|
10
README.md
10
README.md
@ -20,8 +20,12 @@ The json files are already configured, so if you need any assistance with instal
|
|||||||
|
|
||||||
## Results
|
## Results
|
||||||
|
|
||||||

|
Download the raw CSV: https://lander-team.gitlab.io/lander-cpp/simOut.csv
|
||||||
|
|
||||||

|
Download Linux Binaries: https://lander-team.gitlab.io/lander-cpp/sim.out
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 40 KiB |
Binary file not shown.
Before Width: | Height: | Size: 39 KiB |
Binary file not shown.
Before Width: | Height: | Size: 35 KiB |
File diff suppressed because it is too large
Load Diff
@ -1,30 +0,0 @@
|
|||||||
clear all; clc;
|
|
||||||
|
|
||||||
syms R11 R22 R33
|
|
||||||
R = [R11 0 0;
|
|
||||||
0 R22 0;
|
|
||||||
0 0 R33];
|
|
||||||
|
|
||||||
syms I33
|
|
||||||
Q = eye(6) * I33;
|
|
||||||
|
|
||||||
syms F11 F22 F33
|
|
||||||
F = [F11 0 0;
|
|
||||||
0 F22 0
|
|
||||||
0 0 F33];
|
|
||||||
|
|
||||||
syms G13 G31
|
|
||||||
G = [0 0 G13;
|
|
||||||
0 0 0;
|
|
||||||
G31 0 0];
|
|
||||||
|
|
||||||
syms I11 I22 d
|
|
||||||
I = [I11 0 0;
|
|
||||||
0 I22 0;
|
|
||||||
0 0 I33];
|
|
||||||
|
|
||||||
A = [zeros(3,3), d * eye(3); F, G];
|
|
||||||
B = [zeros(3,3); inv(I)];
|
|
||||||
P = [-Q, -A'] * pinv([A, -B*inv(R)*B']);
|
|
||||||
|
|
||||||
K = simplify((R^-1) * B' * P)
|
|
@ -1,66 +0,0 @@
|
|||||||
clear all; clc;
|
|
||||||
%% User Defined Values
|
|
||||||
M0 = 1.2; % [kg]
|
|
||||||
vehicleHeight = 0.5318; % [m]
|
|
||||||
vehicleRadius = 0.05105; % [m]
|
|
||||||
|
|
||||||
%% Calcs
|
|
||||||
I11 = (1/12) * vehicleHeight^2 + 0.25 * vehicleRadius^2; % (1/12) * h^2 + 0.25 * r^2
|
|
||||||
I22 = (1/12) * vehicleHeight^2 + 0.25 * vehicleRadius^2; % (1/12) * h^2 + 0.25 * r^2
|
|
||||||
I33 = 0.5 * vehicleRadius^2; % 0.5 * r^2
|
|
||||||
I = M0 * [I11 0 0; 0 I22 0; 0 0 I33];
|
|
||||||
|
|
||||||
Q = eye(6) * I(3, 3);
|
|
||||||
Mu = 398600;
|
|
||||||
r0 = [6678; 0; 0];
|
|
||||||
|
|
||||||
k1 = (I(2,2) - I(3,3)) / I(1,1);
|
|
||||||
k2 = (I(1,1) - I(3,3)) / I(2,2);
|
|
||||||
k3 = (I(2,2) - I(1,1)) / I(3,3);
|
|
||||||
|
|
||||||
n = sqrt(Mu/(norm(r0)^3));
|
|
||||||
|
|
||||||
F = -2 * n^2 * [4 * k1, 0, 0; 0, 3 * k2, 0; 0, 0, k3];
|
|
||||||
G = n * [0, 0, (1 - k1); 0, 0, 0; (k3 - 1), 0, 0];
|
|
||||||
|
|
||||||
Iinv = [1 / I(1,1), 0, 0; 0, 1 / I(2,2), 0; 0, 0, 1 / I(3,3)];
|
|
||||||
|
|
||||||
A = [zeros(3,3), 0.5 * eye(3); F, G];
|
|
||||||
B = [zeros(3,3); Iinv];
|
|
||||||
|
|
||||||
R = eye(3)*10^-6;
|
|
||||||
Rinv = R^-1;
|
|
||||||
|
|
||||||
S = icare(A, B, Q, R);
|
|
||||||
|
|
||||||
K = Rinv * B' * S;
|
|
||||||
|
|
||||||
%% Outputs
|
|
||||||
% Copy results in command window to LQRcalc function in C++
|
|
||||||
fprintf("double K11 = %3.5f;\n", K(1, 1))
|
|
||||||
fprintf("double K12 = %3.5f;\n", K(1, 2))
|
|
||||||
fprintf("double K13 = %3.5f;\n", K(1, 3))
|
|
||||||
fprintf("double K14 = %3.5f;\n", K(1, 4))
|
|
||||||
fprintf("double K15 = %3.5f;\n", K(1, 5))
|
|
||||||
fprintf("double K16 = %3.5f;\n", K(1, 6))
|
|
||||||
fprintf("double K21 = %3.5f;\n", K(2, 1))
|
|
||||||
fprintf("double K22 = %3.5f;\n", K(2, 2))
|
|
||||||
fprintf("double K23 = %3.5f;\n", K(2, 3))
|
|
||||||
fprintf("double K24 = %3.5f;\n", K(2, 4))
|
|
||||||
fprintf("double K25 = %3.5f;\n", K(2, 5))
|
|
||||||
fprintf("double K26 = %3.5f;\n", K(2, 6))
|
|
||||||
fprintf("double K31 = %3.5f;\n", K(3, 1))
|
|
||||||
fprintf("double K32 = %3.5f;\n", K(3, 2))
|
|
||||||
fprintf("double K33 = %3.5f;\n", K(3, 3))
|
|
||||||
fprintf("double K34 = %3.5f;\n", K(3, 4))
|
|
||||||
fprintf("double K35 = %3.5f;\n", K(3, 5))
|
|
||||||
fprintf("double K36 = %3.5f;\n", K(3, 6))
|
|
||||||
|
|
||||||
syms yaw pitch roll yawdot pitchdot rolldot gain
|
|
||||||
w = [0.5*yaw 0.5*pitch 0.5*roll yawdot pitchdot rolldot]';
|
|
||||||
|
|
||||||
syms K11 K12 K13 K14 K15 K16 K21 K22 K23 K24 K25 K26 K31 K32 K33 K34 K35 K36
|
|
||||||
K = gain * [K11 K12 K13 K14 K15 K16; K21 K22 K23 K24 K25 K26; K31 K32 K33 K34 K35 K36];
|
|
||||||
|
|
||||||
simplify(K*w)
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 39 KiB |
Binary file not shown.
Before Width: | Height: | Size: 31 KiB |
Binary file not shown.
Before Width: | Height: | Size: 34 KiB |
File diff suppressed because it is too large
Load Diff
@ -1,81 +0,0 @@
|
|||||||
clear all; close all; clc;
|
|
||||||
|
|
||||||
% Read data and transfer to variables
|
|
||||||
T = readmatrix('simOut.csv');
|
|
||||||
t = T(:, 1);
|
|
||||||
x = T(:, 2);
|
|
||||||
y = T(:, 3);
|
|
||||||
z = T(:, 4);
|
|
||||||
vx = T(:, 5);
|
|
||||||
vy = T(:, 6);
|
|
||||||
vz = T(:, 7);
|
|
||||||
ax = T(:, 8);
|
|
||||||
ay = T(:, 9);
|
|
||||||
az = T(:, 10);
|
|
||||||
yaw = T(:, 11);
|
|
||||||
pitch = T(:, 12);
|
|
||||||
roll = T(:, 13);
|
|
||||||
yawdot = T(:, 14);
|
|
||||||
pitchdot = T(:, 15);
|
|
||||||
rolldot = T(:, 16);
|
|
||||||
Servo1 = T(:, 17);
|
|
||||||
Servo2 = T(:, 18);
|
|
||||||
m = T(:, 19);
|
|
||||||
thrust = T(:, 20);
|
|
||||||
|
|
||||||
% Acceleration
|
|
||||||
subplot(3, 1, 1)
|
|
||||||
plot(t, az)
|
|
||||||
title('Acceleration vs Time')
|
|
||||||
xlabel('Time (s)')
|
|
||||||
ylabel('Acceleration (g''s)')
|
|
||||||
|
|
||||||
% Velocity
|
|
||||||
subplot(3, 1, 2)
|
|
||||||
plot(t, vz)
|
|
||||||
title('Velocity vs Time')
|
|
||||||
xlabel('Time (s)')
|
|
||||||
ylabel('Velocity (m/s)')
|
|
||||||
|
|
||||||
% Altitude
|
|
||||||
subplot(3, 1, 3)
|
|
||||||
plot(t, z)
|
|
||||||
title('Altitude vs Time')
|
|
||||||
xlabel('Time (s)')
|
|
||||||
ylabel('Altitude (m)')
|
|
||||||
ylim([0 z(1)+5])
|
|
||||||
saveas(gcf,'outputs/Accel-Vel-Alt vs Time.png')
|
|
||||||
|
|
||||||
figure(2)
|
|
||||||
|
|
||||||
% Euler Angles
|
|
||||||
subplot(2, 1, 1)
|
|
||||||
plot(t, yaw, pitch, roll)
|
|
||||||
title('Euler Angles vs Time')
|
|
||||||
xlabel('Time (ms)')
|
|
||||||
ylabel('Euler Angles (deg)')
|
|
||||||
|
|
||||||
% Angular Velocity
|
|
||||||
subplot(2, 1, 2)
|
|
||||||
plot(t, yawdot, pitchdot, rolldot)
|
|
||||||
title('Angular Velocity vs Time')
|
|
||||||
xlabel('Time (ms)')
|
|
||||||
ylabel('Angular Velocity (deg/s)')
|
|
||||||
saveas(gcf,'outputs/Euler Angles vs Time.png')
|
|
||||||
|
|
||||||
figure(3)
|
|
||||||
|
|
||||||
% Servo 1 Position
|
|
||||||
subplot(2, 1, 1)
|
|
||||||
plot(t, Servo1)
|
|
||||||
title('Servo 1 Position vs Time')
|
|
||||||
xlabel('Time (ms)')
|
|
||||||
ylabel('Servo 1 Position (rad)')
|
|
||||||
|
|
||||||
% Servo 2 Position
|
|
||||||
subplot(2, 1, 2)
|
|
||||||
plot(t, Servo2)
|
|
||||||
title('Servo 2 Position vs Time')
|
|
||||||
xlabel('Time (ms)')
|
|
||||||
ylabel('Servo 2 Position (rad)')
|
|
||||||
saveas(gcf,'outputs/Servo Position vs Time.png')
|
|
@ -1,7 +1,7 @@
|
|||||||
clear all; close all; clc;
|
clear all; close all; clc;
|
||||||
|
|
||||||
% Read data and transfer to variables
|
% Read data and transfer to variables
|
||||||
T = readmatrix('simOut.csv');
|
T = readmatrix('../simOut.csv');
|
||||||
t = T(:, 1);
|
t = T(:, 1);
|
||||||
x = T(:, 2);
|
x = T(:, 2);
|
||||||
y = T(:, 3);
|
y = T(:, 3);
|
73
pythonHelpers/plots.py
Normal file
73
pythonHelpers/plots.py
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
for path in Path(".").iterdir():
|
||||||
|
print(path)
|
||||||
|
|
||||||
|
plt.style.use("ggplot")
|
||||||
|
|
||||||
|
df = pd.read_csv("./public/simOut.csv", delimiter=", ")
|
||||||
|
|
||||||
|
|
||||||
|
# Acceleration
|
||||||
|
plt.subplot(3, 1, 1)
|
||||||
|
plt.title("Acceleration, Velocity, and Altitude Plots")
|
||||||
|
plt.plot(df.t, df.az)
|
||||||
|
# plt.title("Acceleration vs Time")
|
||||||
|
plt.xlabel("Time (s)")
|
||||||
|
plt.ylabel("Acceleration (g" "s)")
|
||||||
|
|
||||||
|
# Velocity
|
||||||
|
plt.subplot(3, 1, 2)
|
||||||
|
plt.plot(df.t, df.vz)
|
||||||
|
# plt.title("Velocity vs Time")
|
||||||
|
plt.xlabel("Time (s)")
|
||||||
|
plt.ylabel("Velocity (m/s)")
|
||||||
|
|
||||||
|
# Altitude
|
||||||
|
plt.subplot(3, 1, 3)
|
||||||
|
plt.plot(df.t, df.z)
|
||||||
|
# plt.title("Altitude vs Time")
|
||||||
|
plt.xlabel("Time (s)")
|
||||||
|
plt.ylabel("Altitude (m)\n")
|
||||||
|
|
||||||
|
plt.savefig("./public/AVA.png")
|
||||||
|
|
||||||
|
|
||||||
|
# Euler Angles
|
||||||
|
plt.figure(2)
|
||||||
|
|
||||||
|
plt.subplot(2, 1, 1)
|
||||||
|
plt.title("Deflection and Angular Velocity Plots")
|
||||||
|
plt.plot(df.t, df.yaw, label="Yaw")
|
||||||
|
plt.plot(df.t, df.pitch, label="Pitch")
|
||||||
|
plt.plot(df.t, df.roll, label="Roll")
|
||||||
|
plt.xlabel("Time (ms)")
|
||||||
|
plt.ylabel("Euler Angles (deg)")
|
||||||
|
plt.legend()
|
||||||
|
|
||||||
|
# Angular Velocity
|
||||||
|
plt.subplot(2, 1, 2)
|
||||||
|
plt.plot(df.t, df.yawdot, label="Yaw")
|
||||||
|
plt.plot(df.t, df.pitchdot, label="Pitch")
|
||||||
|
plt.plot(df.t, df.rolldot, label="Roll")
|
||||||
|
plt.xlabel("Time (ms)")
|
||||||
|
plt.legend()
|
||||||
|
|
||||||
|
plt.savefig("./public/Angles.png")
|
||||||
|
|
||||||
|
# Servo Positions
|
||||||
|
plt.figure(3)
|
||||||
|
|
||||||
|
plt.plot(df.t, df.Servo1, label="Servo1")
|
||||||
|
plt.plot(df.t, df.Servo2, label="Servo2")
|
||||||
|
plt.xlabel("Time (ms)")
|
||||||
|
plt.ylabel("Position (rad)")
|
||||||
|
plt.legend()
|
||||||
|
plt.title("Servo Positions")
|
||||||
|
|
||||||
|
plt.savefig("./public/Servos.png")
|
||||||
|
|
||||||
|
plt.show()
|
2
pythonHelpers/requirements.txt
Normal file
2
pythonHelpers/requirements.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
matplotlib==3.4.3
|
||||||
|
pandas==1.3.3
|
Loading…
x
Reference in New Issue
Block a user