Skip to content

Commit 83ba607

Browse files
authored
Merge pull request #9 from Mizu49/attitude-control
Fundamental rigid-body 3D Dynamics has been implemented! Our `v0.0.0` release is deployed now!
2 parents f78c3c9 + 0a5c75d commit 83ba607

16 files changed

+509
-126
lines changed

.devcontainer/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ RUN apt-get install -y libxt6 libxrender1 libxext6 libgl1-mesa-glx libqt5widgets
1616

1717
# Install `Plots.jl and precompile it`
1818
RUN julia -e 'using Pkg; Pkg.REPLMode.pkgstr("add Plots;precompile");using Plots'
19+
20+
# Install `Reexport.jl`
21+
RUN julia -e 'import Pkg; Pkg.add("Reexport")'
22+

.devcontainer/devcontainer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
"dockerFile": "Dockerfile",
88

99
"settings": {
10-
// use bash as terminal
11-
"terminal.integrated.shell.linux": "/bin/bash",
1210

1311
// set path of git
1412
"git.path": "/usr/bin/git",
@@ -20,8 +18,9 @@
2018
// user name of container
2119
"remoteUser": "root",
2220

23-
// specify vs code extentions you will use on remote
21+
// specify vs code extensions you will use on remote
2422
"extensions": [
25-
"julialang.language-julia"
23+
// mandatory for julia development
24+
"julialang.language-julia",
2625
]
2726
}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Output files generated by our program
2+
*.gif
3+
14
# Files generated by invoking Julia with --code-coverage
25
*.jl.cov
36
*.jl.*.cov

.vscode/launch.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "julia",
9+
"request": "launch",
10+
"name": "Run active Julia file",
11+
"program": "${file}",
12+
"stopOnEntry": false,
13+
"cwd": "${workspaceFolder}",
14+
"juliaEnv": "${command:activeJuliaEnvironment}"
15+
}
16+
]
17+
}

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# FlexibleSpacecraft.jl
2-
## 開発環境
3-
`devcontainer`にある`Dockerfile`を基にDockerコンテナの中で開発する.
2+
3+
`FlexibleSpacecraft.jl` is an **Open Source Spacecraft Attitude-Structure Coupling Simulator** developed in Julia Language.
4+
5+
*This project is quite new and under active initial development for open-source release.*
6+

basic-study/metaprogramming.jl

Lines changed: 0 additions & 7 deletions
This file was deleted.

basic-study/modulefile.jl

Lines changed: 0 additions & 9 deletions
This file was deleted.

basic-study/study-module.jl

Lines changed: 0 additions & 23 deletions
This file was deleted.

basic-study/study_composite-types.jl

Lines changed: 0 additions & 29 deletions
This file was deleted.

main.jl

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
include("src/FlexibleSpacecraft.jl")
2+
using .FlexibleSpacecraft
3+
4+
# Inertia matrix
5+
Inertia = diagm([1.0, 1.0, 2.0])
6+
7+
# Disturbance torque
8+
Torque = [0.02, 0.0, 0.0]
9+
10+
11+
# Dynamics model (mutable struct)
12+
dynamicsModel = AttitudeDynamics.DynamicsModel(Inertia, Torque)
13+
14+
# サンプリング時間
15+
Ts = 1e-2
16+
17+
simulationTime = 60
18+
19+
# 時刻
20+
time = 0:Ts:simulationTime
21+
22+
# Numbers of simulation data
23+
simDataNum = round(Int, simulationTime/Ts) + 1;
24+
25+
# Coordinate system of a
26+
coordinateA = TimeLine.CoordinateVector(
27+
[1, 0, 0],
28+
[0, 1, 0],
29+
[0, 0, 1]
30+
)
31+
32+
# Coordinate system of b
33+
coordinateB = TimeLine.initBodyCoordinate(simDataNum, coordinateA)
34+
35+
omegaBA = TimeLine.initAngularVelocity(simDataNum, [0, 0, 1])
36+
37+
quaternion = TimeLine.initQuaternion(simDataNum, [0, 0, 0, 1])
38+
39+
println("Begin simulation!")
40+
for loopCounter = 1:simDataNum-1
41+
42+
# println(loopCounter)
43+
44+
currentCoordB = hcat(coordinateB.x[:,loopCounter] , coordinateB.y[:,loopCounter], coordinateB.z[:,loopCounter])
45+
46+
omegaBA[:, loopCounter+1] = AttitudeDynamics.updateAngularVelocity(dynamicsModel, time[loopCounter], omegaBA[:, loopCounter], Ts, currentCoordB)
47+
48+
quaternion[:, loopCounter+1] = AttitudeDynamics.updateQuaternion(omegaBA[:,loopCounter], quaternion[:, loopCounter], Ts)
49+
50+
C = AttitudeDynamics.getTransformationMatrix(quaternion[:, loopCounter])
51+
52+
coordinateB.x[:, loopCounter+1] = C * coordinateA.x
53+
coordinateB.y[:, loopCounter+1] = C * coordinateA.y
54+
coordinateB.z[:, loopCounter+1] = C * coordinateA.z
55+
56+
end
57+
println("Simulation is completed!")
58+
59+
# fig1 = PlotGenerator.plotAngularVelocity(time, omegaBA)
60+
# display(fig1)
61+
62+
63+
fig2 = PlotGenerator.getCoordinateGif(time, Ts, coordinateA, coordinateB)
64+
display(fig2)
65+
66+
# bodyCoordinate = TimeLine.extractCoordinateVector(10, Ts, coordinateB)
67+
# fig3 = PlotGenerator.plotCoordinate(10, coordinateA, bodyCoordinate)
68+
# display(fig3)

0 commit comments

Comments
 (0)