Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated Data Simulator (WIP) #76

Open
wants to merge 70 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
d16ace0
initial framework
wlsanderson Nov 5, 2024
bb4037f
simulating thrust curves
wlsanderson Nov 6, 2024
c2d7235
ruff
wlsanderson Nov 6, 2024
9f9c2ca
added drag force and coast phase
wlsanderson Nov 6, 2024
4976099
reformatting
wlsanderson Nov 7, 2024
35c7f08
starting rotation
wlsanderson Nov 7, 2024
de29610
progress
wlsanderson Nov 7, 2024
e2b7a17
Clean up
JacksonElia Nov 8, 2024
d18e4a8
Clean up
JacksonElia Nov 8, 2024
ab35553
Added simulation stuff to readme
JacksonElia Nov 8, 2024
47c3ada
rotation wip
wlsanderson Nov 8, 2024
0f53f37
rotations almost done, some bugs
wlsanderson Nov 9, 2024
b45df1c
bug fixes wip
wlsanderson Nov 9, 2024
728420a
rotation fixes wip
wlsanderson Nov 9, 2024
af2a007
Made sim config a class
JacksonElia Nov 10, 2024
7cf10cf
Made it so you could pass in the sim config
JacksonElia Nov 10, 2024
d10ab9a
Moved SimIMU variables into the process
JacksonElia Nov 10, 2024
7014bfa
Finished switching config to a class
JacksonElia Nov 10, 2024
c475013
Fixed arg parser
JacksonElia Nov 10, 2024
790c9b3
Cleaned up typing for SimulationConfig
JacksonElia Nov 10, 2024
2c234d3
Fixed everything
JacksonElia Nov 10, 2024
648a35d
rotation almost fixed
wlsanderson Nov 10, 2024
4db8f69
working
wlsanderson Nov 10, 2024
11addf7
added variable mass
wlsanderson Nov 10, 2024
d15a119
atmospheric properties and variable drag
wlsanderson Nov 11, 2024
46453f3
might undo later
wlsanderson Nov 11, 2024
04a286f
Excluded simulation code from coverage report
JacksonElia Nov 11, 2024
ad963f8
subscale values
wlsanderson Nov 12, 2024
018ba3d
initial framework
wlsanderson Nov 5, 2024
c914a68
simulating thrust curves
wlsanderson Nov 6, 2024
1aebae7
ruff
wlsanderson Nov 6, 2024
6a99579
added drag force and coast phase
wlsanderson Nov 6, 2024
91e89b3
reformatting
wlsanderson Nov 7, 2024
bb4d558
starting rotation
wlsanderson Nov 7, 2024
4b7923a
progress
wlsanderson Nov 7, 2024
cbabad7
Clean up
JacksonElia Nov 8, 2024
6e08a5e
Clean up
JacksonElia Nov 8, 2024
d6a427e
rotation wip
wlsanderson Nov 8, 2024
651c46a
rotations almost done, some bugs
wlsanderson Nov 9, 2024
7096498
bug fixes wip
wlsanderson Nov 9, 2024
e6283d0
rotation fixes wip
wlsanderson Nov 9, 2024
084e8ce
Made sim config a class
JacksonElia Nov 10, 2024
75e5d9f
Made it so you could pass in the sim config
JacksonElia Nov 10, 2024
3fd399f
Moved SimIMU variables into the process
JacksonElia Nov 10, 2024
5a0bab1
Finished switching config to a class
JacksonElia Nov 10, 2024
afa2eb8
Fixed arg parser
JacksonElia Nov 10, 2024
1bca6db
Cleaned up typing for SimulationConfig
JacksonElia Nov 10, 2024
db0e6ed
Fixed everything
JacksonElia Nov 10, 2024
dc98b7a
rotation almost fixed
wlsanderson Nov 10, 2024
a97643a
working
wlsanderson Nov 10, 2024
b7e2789
added variable mass
wlsanderson Nov 10, 2024
b5596d0
atmospheric properties and variable drag
wlsanderson Nov 11, 2024
d0560f7
might undo later
wlsanderson Nov 11, 2024
145b306
Excluded simulation code from coverage report
JacksonElia Nov 11, 2024
d6cbabf
subscale values
wlsanderson Nov 12, 2024
edfb964
Merge remote-tracking branch 'refs/remotes/origin/data-sim' into data…
wlsanderson Nov 14, 2024
24bc98d
drag changes
wlsanderson Nov 14, 2024
075e9ea
Merge remote-tracking branch 'origin/main' into data-sim
wlsanderson Nov 14, 2024
79c6f6d
my changes before merge
JacksonElia Nov 14, 2024
734a444
Merge remote-tracking branch 'origin/sam-changes' into data-sim
JacksonElia Nov 14, 2024
a150dcd
logger fix
wlsanderson Nov 14, 2024
37d716f
Merge remote-tracking branch 'origin/data-sim' into data-sim
JacksonElia Nov 14, 2024
6a35c42
Added differing cds to the sim
JacksonElia Nov 14, 2024
e2704a4
Ruff
JacksonElia Nov 14, 2024
9ec3abd
airbrakes ref area
wlsanderson Nov 14, 2024
0c28f2c
updated readme, standardized variable names
wlsanderson Nov 15, 2024
c943343
Merge main and fix conflicts
harshil21 Nov 16, 2024
486e944
Merge pull request #77 from NCSU-High-Powered-Rocketry-Club/readme-im…
JacksonElia Dec 3, 2024
b09a6b3
Merge branch 'main' into data-sim
wlsanderson Dec 4, 2024
382f2eb
wip, fixing apogee convergence time
wlsanderson Dec 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions airbrakes/data_handling/data_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ def _calculate_rotated_accelerations(self) -> npt.NDArray[np.float64]:
Calculates the rotated acceleration vector. Converts gyroscope data into a delta
quaternion, and adds onto the last quaternion. Will most likely be replaced by IMU
quaternion data in the future, this is a work-around due to bad datasets.

:return: numpy list of rotated acceleration vector [x,y,z]
"""

Expand All @@ -229,7 +228,8 @@ def _calculate_rotated_accelerations(self) -> npt.NDArray[np.float64]:
if any(val is None for val in [x_accel, y_accel, z_accel, gyro_x, gyro_y, gyro_z]):
return rotated_accelerations

# scipy docs for more info: https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.transform.Rotation.html
# scipy docs for more info:
# https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.transform.Rotation.html
# Calculate the delta quaternion from the angular rates
delta_rotation = R.from_rotvec([gyro_x * dt, gyro_y * dt, gyro_z * dt])

Expand Down Expand Up @@ -282,7 +282,7 @@ def _calculate_time_differences(self) -> npt.NDArray[np.float64]:
This cannot be called on the first update as _last_data_packet is None. Units are in
seconds.
:return: A numpy array of the time difference between each data packet and the previous
data packet.
data packet.
"""
# calculate the time differences between each data packet
# We are converting from ns to s, since we don't want to have a velocity in m/ns^2
Expand Down
19 changes: 7 additions & 12 deletions airbrakes/mock/mock_imu.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ class MockIMU(IMU):
and returns data read from a previous log file.
"""

__slots__ = ("_log_file_path",)

def __init__(
self,
log_file_path: Path | bool,
Expand All @@ -32,19 +30,17 @@ def __init__(
):
"""
Initializes the object that pretends to be an IMU for testing purposes by reading from a
log file.
log file.
:param log_file_path: The path of the log file to read data from.
:param real_time_simulation: Whether to simulate a real flight by sleeping for a set
period, or run at full
speed, e.g. for using it in the CI.
period, or run at full speed, e.g. for using it in the CI.
:param start_after_log_buffer: Whether to send the data packets only after the log buffer
was filled for Standby state.
was filled for Standby state.
"""
self._log_file_path = log_file_path
# Check if the launch data file exists:
if not log_file_path:
# Just use the first file in the `launch_data` directory:
self._log_file_path = next(iter(Path("launch_data").glob("*.csv")))
log_file_path = next(iter(Path("launch_data").glob("*.csv")))

# We don't call the parent constructor as the IMU class has different parameters, so we
# manually start the process that fetches data from the log file
Expand All @@ -61,7 +57,7 @@ def __init__(
self._data_fetch_process = multiprocessing.Process(
target=self._fetch_data_loop,
args=(
self._log_file_path,
log_file_path,
real_time_simulation,
start_after_log_buffer,
),
Expand All @@ -78,9 +74,9 @@ def _read_file(
Reads the data from the log file and puts it into the shared queue.
:param log_file_path: the name of the log file to read data from located in scripts/imu_data
:param real_time_simulation: Whether to simulate a real flight by sleeping for a set period,
or run at full speed, e.g. for using it in the CI.
or run at full speed, e.g. for using it in the CI.
:param start_after_log_buffer: Whether to send the data packets only after the log buffer
was filled for Standby state.
was filled for Standby state.
"""

start_index = 0
Expand Down Expand Up @@ -120,7 +116,6 @@ def _read_file(
if not self._running.value:
break

imu_data_packet = None
fields_dict = {}

scaled_accel_x = row.get("scaledAccelX") # raw data packet field
Expand Down
7 changes: 7 additions & 0 deletions airbrakes/simulation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Rotation Guide for sim IMU

Vertical orientation of the IMU is described in vector form.
- Example: If the -x axis of the IMU is facing the sky, the vertical orientation is [-1, 0, 0]

Direction the rocket leans to on the pad is the launch_pad_direction. Ranges from 0 to 360 degrees.
Important to note that the IMU does not change position inside of the rocket when changing launch pad angle.
Empty file.
Loading