-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.Rmd
99 lines (56 loc) · 4.12 KB
/
index.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Title: "Design a Controller to stabilize a spacecraft's Attitude"
# Author: Hadarou Sare
# Introduction
Space Exploration has always captivated the attention of all human being from women to men, from kids to adults. However, going to space is much more easier than developing the best vehicle with the right control system to reach space. In fact, in order to conduct activities in space (send human or robots, do science,...), Aerospace Engineers need to come up with innovative ideas not only to build the spacecraft but mostly to stabilize it in order to allow it to perform its mission. For example, a spacecraft designed to capture an asteroids, mining it, and bring its valuable resource back to Earth need a strong control system to be stable and perform its mission safely.
In this project, I assumed that the transfer function system of a spacecraft I call "Controller" is unstable and I design (implememt) a new controller to stabilize the spacecraft.
# Materials and methods
I use the Control package available in the library. Other than that I created all the rest of the data by myself.
I firstly assumed a chosen transfer function system of the spacecraft I called "Controller" and tried to see if that controller could stabilize the spacecraft by ploting its step response curve. After being sure that the system is unstable with that controller by looking at the poles of the system and its step response curve, I designed a controller I called "Controller2" with some parameters I choose to make sure that it can stabilize the system of the spacecraft. I ploted the step response of the controller I designed to show that it can stabilize the system.
#Load any required packages in a code chunk (you may need to install some packages):
```{r}
library(control)
```
# Definition of Transfer Function
A transfer function is a frequency domain, i.e. the ratio of the output to the input of the control system.
## Download and clean all required data (1)
```{r}
#Example of Transfer Function
a <- 10; b <- 7; k <- 3
TF("1/(a*s^2 + b *s + k)")
```
Some transfer function are able to stabilize the system of a spacecraft without the need of designing or implementing a controller but depending on diverse factors such as forces acting on the sapcecraft, gravity torques,...the transfer function only might not be able to stabilize the spacecraft. So it is always better to test its stability depending on the mission we want to perform.
## Download and clean all required data (2)
```{r}
e <- 0.000003;
m <- 0.000003;
p <- 0.03;
d <- 4;
w <- 0.000003;
Controller <- TF("p/(s*((e*s + m)*(w*s + d) + p^2))")
time <- seq(0,0.5,0.0010)
```
# Results
```{r}
stepplot(Controller, t = time)
```
#Is the system Stable?
From the plot of the system’s step response, it is clear that the system is unstable. The Stability of the system can also be determined by looking at the poles of the system.
```{r}
pole(Controller)
```
One of the poles of the open-loop transfer function is on the imaginary axis and the other two poles are in the left half of the complex s-plane. So the system is not stable.
Since the system is not stable, we need to add a feedback controller and check the closed-loop step response of the system to see if it is stable or not.
#Closed-Loop Response of the Controller
```{r}
Controller2<- feedback(Controller, 1)
print(Controller2)
```
#Plot
```{r}
stepplot(Controller2, t = time)
```
The closed-loop step response shows that the system is stable after adding a feedback controller. Then the spacecraft's attitude is stabilized by the feedback controller.
# Conclusions
R is a suitable tool not only to explore the stability of a system but also to design a controller that will be able to stabilize the spacecraft. Most of the Aerospace Engineers use Matlab which is a software with lot of tools for spacecraft's controller design in term of ploting the Bode diagram, ploting the compensated and uncompensated system, getting the gain margin and the phase margin,..but I am sure R is also a good tool and could perform some of the work we do in Aerospace using Matlab.
# References
Ubah B. C., (2017), A Control System Toolbox, 0.2.5