Closed MateusStano closed 1 month ago
Attention: Patch coverage is 90.80460%
with 48 lines
in your changes are missing coverage. Please review.
Please upload report for BASE (
enh/sensors-impl@fbeff2c
). Learn more about missing BASE report.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
I forgot to comment in the review:
Flight
class if a Rocket
has AirBrakes
and overshootable
is True
. The same apply for Controllers
.Hey! So I have changed the way the sensors readings. The initial implementation had the measurements saved in the sensor object being used, this caused the following problems:
measured_data
would have intercalated datameasured_data
However, the measured_data
attribute was an useful way to get previous sensor readings inside the controller function. My solution was to save the data both in the Flight
class and in the Sensors
. In the Flight
the sensors reading are saved as a dict, while in the Sensors
its saved as a list. This grants versatility to the code.
To do this I had to:
Sensors._attatched_rockets
property, which maps how many times that Sensors
instance has been added to a rocket. This lets us deal with repeatedly added sensorsSensors.measured_data
every simulation. This means that a sensor object will only have data of one simulation max. This could be changed to have several simulations but I see no use for that.measured_data
are cached into a property in the Flight
class called sensor_data
. sensor_data
sensor data is a dict that maps each sensor to its reading listSo the final structure is of the saved attributes is as follows:
Given an Accelerometer
that is added once to the rocket. We have that its:
.measured_data
is a list in the form [(t1, ax1, ay1, az1), (t2, ax2, ay2, az3), ...]
Flight.sensors_data
is a dict in the form {Accelerometer : [(t1, ax1, ay1, az1), (t2, ax2, ay2, az3), ...]}
If there is an Accelerometer
that is added twice to the rocket. We have that its:
.measured_data
is a list in the form [[(t1, ax1, ay1, az1), (t2, ax2, ay2, az3), ...], [(t1, ax1, ay1, az1), (t2, ax2, ay2, az3), ...]]
Flight.sensors_data
is a dict in the form {Accelerometer : {1 : [(t1, ax1, ay1, az1), (t2, ax2, ay2, az3), ...]}, 2: [(t1, ax1, ay1, az1), (t2, ax2, ay2, az3), ...]} }
However, we could also have the Flight.sensors_data
be {Accelerometer : [[(t1, ax1, ay1, az1), (t2, ax2, ay2, az3), ...], [(t1, ax1, ay1, az1), (t2, ax2, ay2, az3), ...]] }
in this last case. Any opinions on this?
@Gui-FernandesBR @phmbressan This is ready for a new review
This is awesome!
@MateusStano , tomorrow I will invest some time to test the jupyter notebook and search for any bug. In the mean time, there are still a few conversations opened, would you mind addressing them?
This is a already too large PR (70 commits), feel free to write down some TODOs in the code if you think something is not crucial, just let us know please.
Btw the head branch seems to be outdated with respect to the develop branch.
Seems like we have an inverted direction somewhere:
This result is supposed to be right because the noisy gyroscope is upside down. Please check the orientation and see if it makes any sense
Also I did not care so much about the new jupyter notebook, I think it is there as a fast testing option only, right?
Yes, its just for testing right now
I'll go ahead and merge this then
Pull request type
Checklist
black rocketpy/ tests/
) has passed locallypytest tests -m slow --runslow
) have passed locallyCHANGELOG.md
has been updated (if relevant)Description
This PR tackles issue #273 and builds on top of #580
Added:
Sensors
abstract classAccelerometer
classGyroscope
classSensors
are included in theFlight
simulation loop. Having any amount of sensors in the simulated rocket will add only one additional call tou_dot
per simulation step. Sensors only worktime_overshoot=False
add_sensor
method in rocket class that receives the sensor and its position and saves them in aComponent
object__and__
operator for elementwise multiplication betweenVector
objectseuler_to_quaternions
function intools.py
for conversion from euler angles to quaternionstransformation_euler_angles
static method in theMatrix
class for construction of a rotation matrix from euler anglesComponents
class for speed purposestriggerfunc
can now receive a list of sensors as its last argumentcontroller_function
can now receive a list of sensors as its last argumentSensors Architecture
Sensors
have theirorientation
and noise information saved in itself. When added to the rocket, a position must be givenmeasure
method that characterizes the sensor. Themeasure
function receives(t, state, state_derivative, *args)
.*args
refers to the specific input required by the sensor. Different types of sensors will receive different*args
.measure
method, the sensor's reading is saved in themeasured_data
attribute. This means that the state of the sensor changes throughout the simulation.Notes
sensors_testing.ipynb
for testing the current sensor implementation. It does not need to be reviewedtest_ideal_sensors
. The tolerance in this test is limited by numerical errors in the calculation of the rotation matrix from the quaternions. This is probably causing inaccuracies in the simulation. We should fix this soonz
axis of theCalisto
flight. Seems to be related to errors in the derivation of the motor'smass_dot
. This does not happen when the old udot is used. We should fix this soonBreaking change