Skip to content

Commit

Permalink
MNT: minor adjustments before merging sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
Gui-FernandesBR committed Sep 12, 2024
1 parent 2c142c4 commit bb8af25
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 24 deletions.
2 changes: 1 addition & 1 deletion rocketpy/environment/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ def utm_to_geodesic( # pylint: disable=too-many-locals,too-many-statements
x, y, utm_zone, hemis, semi_major_axis=6378137.0, flattening=1 / 298.257223563
):
# NOTE: already documented in the Environment class.
# TODO: deprecated the static method from the environment class, use only this one.
# TODO: deprecate the static method from the environment class, use only this one.

if hemis == "N":
y = y + 10000000
Expand Down
2 changes: 1 addition & 1 deletion rocketpy/motors/tank.py
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ def gas_volume(self):
Function
Volume of the gas as a function of time.
"""
# TODO: there's a bug on the gas_center_of_mass is I don't discretize here
# TODO: there's a bug on the gas_center_of_mass if I don't discretize here
func = Function(self.geometry.total_volume).set_discrete_based_on_model(
self.liquid_volume
)
Expand Down
4 changes: 2 additions & 2 deletions rocketpy/rocket/parachute.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class Parachute:
``sensor.measurement`` attribute. The sensors are listed in the same
order as they are added to the rocket.
The function should return True if the parachute ejection system should
be triggered and False otherwise.
The function should return ``True`` if the parachute ejection system
should be triggered and False otherwise.
- A float value, representing an absolute height in meters. In this
case, the parachute will be ejected when the rocket reaches this height
Expand Down
25 changes: 12 additions & 13 deletions rocketpy/rocket/rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -1347,30 +1347,29 @@ def add_parachute(
self.parachutes.append(parachute)
return self.parachutes[-1]

def add_sensor(self, sensor, position, x_offset=0, y_offset=0):
def add_sensor(self, sensor, position):
"""Adds a sensor to the rocket.
Parameters
----------
sensor : Sensor
Sensor to be added to the rocket.
position : int, float, tuple
Position, in meters, of the sensor's coordinate system origin
relative to the user defined rocket coordinate system.
x_offset : int, float, optional
Distance in meters by which the sensor is to be translated in the
rocket's x direction relative to geometrical center line.
Default is 0.
y_offset : int, float, optional
Distance in meters by which the sensor is to be translated in the
rocket's y direction relative to geometrical center line.
Default is 0.
position : int, float, tuple, list, Vector
Position of the sensor. If a Vector, tuple or list is passed, it
must be in the format (x, y, z) where x, y, and z are defined in the
rocket's user defined coordinate system. If a single value is
passed, it is assumed to be along the z-axis (centerline) of the
rocket's user defined coordinate system and angular_position and
radius must be given.
Returns
-------
None
"""
self.sensors.add(sensor, Vector([x_offset, y_offset, position]))
if isinstance(position, (float, int)):
position = (0, 0, position)
position = Vector(position)
self.sensors.add(sensor, position)
try:
sensor._attached_rockets[self] += 1
except KeyError:
Expand Down
2 changes: 1 addition & 1 deletion rocketpy/sensors/barometer.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__(
sampling_rate : float
Sample rate of the sensor in Hz.
measurement_range : float, tuple, optional
The measurement range of the sensor in the Pa. If a float, the same
The measurement range of the sensor in Pa. If a float, the same
range is applied both for positive and negative values. If a tuple,
the first value is the positive range and the second value is the
negative range. Default is np.inf.
Expand Down
3 changes: 1 addition & 2 deletions rocketpy/sensors/gyroscope.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,7 @@ def measure(self, time, **kwargs):
)
W = inertial_to_sensor @ omega

# Apply noise + bias
# Apply noise + bias and quatize
# Apply noise + bias and quantize
W = self.apply_noise(W)
W = self.apply_temperature_drift(W)

Expand Down
2 changes: 0 additions & 2 deletions rocketpy/sensors/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,6 @@ def __init__(
standard rotation sequence is z-y-x (3-2-1) is used, meaning the
sensor is first rotated by ψ around the x axis, then by θ around
the new y axis and finally by φ around the new z axis.
TODO: x and y are not defined in the rocket class. User has no
way to know which axis is which.
- A list of lists (matrix) of shape 3x3, representing the rotation
matrix from the sensor frame to the rocket frame. The sensor frame
of reference is defined as to have z axis along the sensor's normal
Expand Down
4 changes: 2 additions & 2 deletions rocketpy/simulation/flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ def __simulate(self, verbose):
callback(self)

if self.sensors:
# udot for all sensors
# u_dot for all sensors
u_dot = phase.derivative(self.t, self.y_sol)
for sensor, position in node._component_sensors:
relative_position = position - self.rocket._csys * Vector(
Expand Down Expand Up @@ -3229,7 +3229,7 @@ def export_sensor_data(self, file_name, sensor=None):

with open(file_name, "w") as file:
json.dump(data_dict, file)
print("Sensor data exported to", file_name)
print("Sensor data exported to: ", file_name)

def export_kml( # TODO: should be moved out of this class.
self,
Expand Down

0 comments on commit bb8af25

Please sign in to comment.