Skip to content

Commit 458c5b6

Browse files
Merge pull request #215 from RocketPy-Team/doc/rocketpy-hackathon-tutorial
DOC: add more development pages
2 parents 1e78afa + 8148f79 commit 458c5b6

File tree

4 files changed

+357
-0
lines changed

4 files changed

+357
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.. mdinclude:: ./github_tutorial.md
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# RocketPy Hackathon
2+
## _Git and GitHub Introduction_
3+
4+
This tutorial is meant to guide the hackathon participants to the basic functionalities of Git and GitHub that they are going to need while solving the Challenges.
5+
6+
## Git Installation
7+
8+
In order to work with RocketPy Hackathon repository, one must have Git installed in the machine. The install instructions are available at [the official Git page](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) for Linux, Windows and Mac.
9+
10+
Furthermore, specially if the participant is more comfortable with a GUI interface for operating with Git (instead of terminal), it is optional to download [GitHub Desktop](https://desktop.github.com/).
11+
12+
## GitHub Account Configuration
13+
14+
A GitHub account is required for submitting changes to the Hackathon Repository. If the participant does not have an account, it is possible to sign up [here](https://github.com/signup?source=login).
15+
16+
After successfully creating an account, it must be set up with the participant _username_ and _email address_, this can be done with the following terminal commands:
17+
18+
```sh
19+
git config --global user.name "your_username"
20+
git config --global user.email "[email protected]"
21+
```
22+
23+
## Repository Workflow
24+
25+
### Cloning
26+
27+
First and foremost, the participant must open a terminal session and change the current directory to the one in which the Hackathon Repository will be downloaded. Then it is necessary to clone the Hackathon GitHub repository with the following commands:
28+
29+
```sh
30+
cd <your_desired_path>
31+
git clone https://github.com/Projeto-Jupiter/RocketPy-Hackathon-2022.git
32+
```
33+
34+
### Basic Workflow
35+
36+
The basic workflow of interacting with a GitHub repository is through getting the most recent version of code (pull), making necessary changes (commits) and uploading these changes to the remote repository (pushes). For instance, the basic workflow for updating a README.md file from a repository would be similar to this:
37+
38+
```sh
39+
# getting most recent version
40+
git pull
41+
# selecting all changed files to commit
42+
git add .
43+
# update the local repository with changes and
44+
# a descriptive commit message
45+
git commit -m "Updade README.md file"
46+
# upload changes to the remote repository
47+
git push
48+
```
49+
50+
### Pull Requests
51+
52+
Pull Requests are a way to notify others of the changes made to the code, so that these changes may be revised by others before being merged into the final code. Pull Requests are located at the _Pull Request_ tab on the main page of the GitHub repository.
53+
54+
A new Pull Request can be made by specifying which changes should be merged into the repository, as illustrates the figure below:
55+
56+
![pull_request_button](https://docs.github.com/assets/cb-34915/images/help/pull_requests/choose-base-and-compare-branches.png)
57+
58+
## Forks and Branches
59+
60+
### Forks
61+
62+
A Fork is a copy of a GitHub repository that allows the user to make changes to a repository while keeping the original unchanged, the changes are updated to the original repository through pull requests. The participant will solve the Challenges and make contributions to a local Fork of the Hackathon GitHub repository, so that it is possible to keep the solutions organized and avoid conflicts that arise from multiple groups editing the same code. It is recommended to use GitHub environment to create a Fork, the participant has to click on the top right corner of the Hackathon GitHub page:
63+
64+
![fork_button](https://docs.github.com/assets/cb-23088/images/help/repository/fork_button.png)
65+
66+
### Branches
67+
68+
A Branch is a separate development path for the repository. They are specially useful for developing new features, testing changes or bug fixing while keeping the original code unchanged. The changes made in a branch can be merged into another branch through a Pull Request. It is recommended that the participant organize its own workflow with branches, since there are multiple Challenges that must be solved (sometimes working on more than one Challenge concurrently). Branches can be created from the terminal with the following command:
69+
70+
```sh
71+
git checkout -b <new_branch_name>
72+
```
73+
74+
After this command, a new branch will be created and the user is automatically directed to it. Furthermore, changing branches is done with the command ```git checkout <branch_name>``` (existing branches can be seen either on GitHub repository page or in terminal with the command ```git branch```).
75+
76+
![branches_button](https://docs.github.com/assets/cb-107867/images/help/branches/branches-overview-link.png)
77+
78+
## Issues and Challenges
79+
80+
The Hackathon Challenges are going to be released in the form of issues at the RocketPy Hackathon repository. They will be available after the Hackathon starts and can be accessed by clicking on the tab _issues_ as seen below:
81+
82+
![issues_button](https://docs.github.com/assets/cb-25896/images/help/repository/repo-tabs-issues.png)
83+
84+
After solving a Challenge, the participant will have to make a pull request to the main Hackathon repository.
85+
86+
## Further Information
87+
88+
Should the participant have any issues, RocketPy team is willing to help at a wide range of time-zones. Further information on Git/GitHub and GitHub Desktop are available from the official [GitHub Docs](https://docs.github.com/en). The documentation for the main topics covered in this tutorial are available in the table below:
89+
90+
| Topic | Documentation |
91+
| ------ | ------ |
92+
| Git Install and Set Up| [get-started/quickstart/set-up-git](https://docs.github.com/en/get-started/quickstart/set-up-git) |
93+
| GitHub Desktop | [get-started/using-github/github-desktop](https://docs.github.com/en/get-started/using-github/github-desktop) |
94+
| Commits | [creating-and-editing-commits/about-commits](https://docs.github.com/pt/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/about-commits) |
95+
| Forks | [get-started/quickstart/fork-a-repo](https://docs.github.com/en/get-started/quickstart/fork-a-repo) |
96+
| Branches | [creating-and-deleting-branches-within-your-repository](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-and-deleting-branches-within-your-repository) |
97+
| Pull Request | [get-started/quickstart/github-flow](https://docs.github.com/en/get-started/quickstart/github-flow) |
98+

docs/development/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Welcome to RocketPy's development documentation!
55
:maxdepth: 2
66
:caption: Contents:
77

8+
Running RocketPy as a Developer <rocketpy_as_developer.rst>
9+
GitHub Workflow for RocketPy Hackathon 2022 <github_hackathon.rst>
810
Style Guide <style_guide>
911

1012
This section is still a work in progress. Here you will find information on how to contribute to our code base.
Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
========================
2+
Introduction to RocketPy
3+
========================
4+
5+
This tutorial part shows how to open rocketpy files and run a simple simulation.
6+
7+
Opening rocketpy folder
8+
=======================
9+
10+
Go into the cloned repository folder by typing on a terminal
11+
12+
.. code-block:: console
13+
14+
cd <rocketpy directory>
15+
16+
Open your preference editor by typing on a terminal
17+
18+
.. code-block:: console
19+
20+
<editor name> .
21+
22+
For example, to open VS Code type on terminal
23+
24+
.. code-block:: console
25+
26+
code .
27+
28+
Alternatively, you can open the folder directly through your editor's interface.
29+
30+
Preparing directory for code editing
31+
====================================
32+
33+
You may create a testing file in any directory, but you must remember that they should not be included in the commits and pull requests unless they are part of the proposed solution.
34+
With that in mind, it is suggested the creation of a folder with all the testing files, so they can be added in the .gitignore file, which contains the name of all the files and folders that will not be added to the commits. To create the folder, type on the terminal:
35+
36+
.. code-block:: console
37+
38+
mkdir <folder name>
39+
40+
And, to add it on .gitignore, type:
41+
42+
.. code-block:: console
43+
44+
echo <folder name>/ >> .gitignore
45+
46+
It is important to remember that all the files inside this folder will not be included in any commit so, if it is important to the solution, do not add them inside it.
47+
48+
Running a simulation with RocketPy
49+
==================================
50+
51+
Importing the RocketPy files
52+
----------------------------
53+
54+
First, create a python (or .ipynb) file to make the simulation.
55+
To ensure you are using the local files and not the files as a python package (if you installed the library via pip for example), add
56+
57+
.. code-block:: python
58+
59+
pip install -e .
60+
61+
Alternatively you can use the following command to pip install the local library:
62+
63+
.. code-block:: console
64+
65+
import sys
66+
sys.path.append('../') # if you are using a notebook
67+
sys.path.append('../rocketpy') # if you are using a script
68+
69+
Import the classes that will be used, in case:
70+
71+
.. code-block:: python
72+
73+
from rocketpy import Environment, SolidMotor, Rocket, Flight, Function
74+
75+
If it is the first time you are using rocketpy and you do not have all required libraries installed, you could use the command:
76+
77+
.. code-block:: python
78+
79+
pip install -r </path/to/requirements.txt>
80+
81+
Alternatively, if you are in rocketpy folder, just type
82+
83+
.. code-block:: python
84+
85+
pip install -r requirements.txt
86+
87+
Creating an Environment
88+
-----------------------
89+
90+
Here we create the environment object that will be used in the simulation.
91+
It contains information about the local pressure profile, temperature, speed of sound, wind direction and intensity, etc.
92+
93+
.. code-block:: python
94+
95+
Env = Environment(railLength=5.2, latitude=32.990254, longitude=-106.974998, elevation=1400)
96+
97+
RocketPy can use local files via the Ensemble method or meteorological forecasts through OpenDAP protocol.
98+
To work with environment files, it will be very important ensuring tha that you have the netCDF4 library installed.
99+
Assuming we are using forecast, first we set the simulated data with:
100+
101+
.. code-block:: python
102+
103+
import datetime
104+
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
105+
Env.setDate((tomorrow.year, tomorrow.month, tomorrow.day, 12)) # Hour given in UTC time
106+
107+
Then we set the atmospheric model, in this case, GFS forecast:
108+
109+
.. code-block:: python
110+
111+
Env.setAtmosphericModel(type="Forecast", file="GFS")
112+
113+
Weather forecast data can be visualized through two info methods.
114+
115+
``Env.info()`` or ``Env.allInfo()``
116+
117+
Creating the motor that boosts the rocket
118+
-----------------------------------------
119+
120+
Now we need to create the motor.
121+
For example, we will use a solid motor called Pro75M1670, but other configurations are also possible.
122+
The motor class contains information about the thrust curve and uses some geometric parameters to calculate the mass variation over time, as well as the total thrust and other important outputs.
123+
124+
.. code-block:: python
125+
126+
Pro75M1670 = SolidMotor(
127+
thrustSource="../data/motors/Cesaroni_M1670.eng",
128+
burnOut=3.9,
129+
grainNumber=5,
130+
grainSeparation=5 / 1000,
131+
grainDensity=1815,
132+
grainOuterRadius=33 / 1000,
133+
grainInitialInnerRadius=15 / 1000,
134+
grainInitialHeight=120 / 1000,
135+
nozzleRadius=33 / 1000,
136+
throatRadius=11 / 1000,
137+
interpolationMethod="linear",
138+
)
139+
140+
Motor data can be visualized through the following methods:
141+
142+
``Pro75M1670.info()`` or ``Pro75M1670.allInfo()``
143+
144+
145+
Creating the rocket
146+
-------------------
147+
148+
The Rocket class contains all information about the rocket that are necessary to the simulation, including the motor, rocket mass and inertia, aerodynamic surfaces, parachutes, etc.
149+
The first step is to initialize the class with the vital data:
150+
151+
.. code-block:: python
152+
153+
Calisto = Rocket(
154+
motor=Pro75M1670,
155+
radius=127 / 2000,
156+
mass=19.197 - 2.956,
157+
inertiaI=6.60,
158+
inertiaZ=0.0351,
159+
distanceRocketNozzle=-1.255,
160+
distanceRocketPropellant=-0.85704,
161+
powerOffDrag="../../data/calisto/powerOffDragCurve.csv",
162+
powerOnDrag="../../data/calisto/powerOnDragCurve.csv",
163+
)
164+
165+
Then the rail buttons must be set:
166+
167+
.. code-block:: python
168+
169+
Calisto.setRailButtons([0.2, -0.5])
170+
171+
In sequence, the aerodynamic surfaces must be set.
172+
If a lift curve for the fin set is not specified, it is assumed that they behave according to a linearized model with a coefficient calculated with Barrowman's theory.
173+
In the example, a nosecone, one fin set and one tail were added, but each case can be designed differently.
174+
175+
.. code-block:: python
176+
177+
NoseCone = Calisto.addNose(length=0.55829, kind="vonKarman", distanceToCM=0.71971)
178+
179+
FinSet = Calisto.addFins(4, span=0.100, rootChord=0.120, tipChord=0.040, distanceToCM=-1.04956)
180+
181+
Tail = Calisto.addTail(topRadius=0.0635, bottomRadius=0.0435, length=0.060, distanceToCM=-1.194656)
182+
183+
If you are considering the parachutes in the simulation, they also have to be added to the rocket object.
184+
A trigger function must be supplied to trigger the parachutes.
185+
Currently, the pressure `(p)` and the state-space variables `(y)` are necessary inputs for the function.
186+
The state-space contains information about the rocket's position and velocities (translation and rotation).
187+
For example:
188+
189+
.. code-block:: python
190+
191+
def drogueTrigger(p, y):
192+
# p = pressure
193+
# y = [x, y, z, vx, vy, vz, e0, e1, e2, e3, w1, w2, w3]
194+
# activate drogue when vz < 0 m/s.
195+
return True if y[5] < 0 else False
196+
197+
198+
def mainTrigger(p, y):
199+
# p = pressure
200+
# y = [x, y, z, vx, vy, vz, e0, e1, e2, e3, w1, w2, w3]
201+
# activate main when vz < 0 m/s and z < 800 + 1400 m (+1400 due to surface elevation).
202+
return True if y[5] < 0 and y[2] < 800 + 1400 else False
203+
204+
After having the trigger functions defined, the parachute must be added to the rocket:
205+
206+
.. code-block:: python
207+
208+
Main = Calisto.addParachute(
209+
"Main",
210+
CdS=10.0,
211+
trigger=mainTrigger,
212+
samplingRate=105,
213+
lag=1.5,
214+
noise=(0, 8.3, 0.5),
215+
)
216+
217+
Drogue = Calisto.addParachute(
218+
"Drogue",
219+
CdS=1.0,
220+
trigger=drogueTrigger,
221+
samplingRate=105,
222+
lag=1.5,
223+
noise=(0, 8.3, 0.5),
224+
)
225+
226+
Simulating the flight
227+
--------------------
228+
229+
Finally, the flight can be simulated with the provided data.
230+
The rocket and environment classes are supplied as inputs, as well as the rail inclination and heading angle.
231+
232+
.. code-block:: python
233+
234+
TestFlight = Flight(rocket=Calisto, environment=Env, inclination=85, heading=0)
235+
236+
Flight data can be retrieved through:
237+
238+
``TestFlight.info()`` or ``TestFlight.allInfo()``
239+
240+
This function plots a comprehensive amount of flight data and graphs but, if you want to access one specific variable, for example Z position, this may be achieved by `TestFlight.z`.
241+
If you insert `TestFlight.z()` the graph of the function will be plotted.
242+
This and other features can be found in the documentation of the `Function` class, which allows data to be treated in an easier way.
243+
The documentation of each variable used in the class can be found on `Flight.py` file.
244+
245+
Further considerations
246+
======================
247+
248+
RocketPy's classes documentation can be accessed in code via `help(<name of the class>)` command.
249+
For example, to access Flight class parameters, you can use:
250+
251+
.. code-block:: python
252+
253+
help(Flight)
254+
255+
More documentation materials can be found at [read the docs](https://docs.rocketpy.org/en/latest/?badge=latest).
256+
It can also be found on RocketPy's GitHub page on the badge "docs".

0 commit comments

Comments
 (0)