Skip to content

Commit

Permalink
Merge pull request #191 from cwruRobotics/float-depth-offset
Browse files Browse the repository at this point in the history
Float depth offset
  • Loading branch information
NoahMollerstuen authored Jun 15, 2024
2 parents 1316f36 + 3b0abc4 commit cd41184
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/surface/transceiver/test/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_message_parser(packet_handler: SerialReaderPacketHandler) -> None:
profile_number=1,
profile_half=1,
time_data=[5.231683254241943, 5.247383117675781, 5.263083457946777, 5.278783321380615, 5.294483184814453, 5.310183525085449, 5.325883388519287, 5.341583251953125, 5.357283115386963, 5.372983455657959, 5.388683319091797, 5.404383182525635, 5.420100212097168, 5.435766696929932, 5.4514665603637695, 5.467166900634766, 5.4828667640686035, 5.498566627502441, 5.514266490936279, 5.529966831207275, 5.545666694641113, 5.561366558074951, 5.577066898345947, 5.592766761779785, 5.608466625213623, 5.624216556549072, 5.639916896820068, 5.655616760253906, 5.671316623687744, 5.687016487121582, 5.702716827392578], # noqa 501
depth_data=[-0.2521384060382843, -0.25173041224479675, -0.24744650721549988, -0.2212330847978592, -0.1738041341304779, -0.11107552796602249, -0.029477344825863838, 0.08017022162675858, 0.21592919528484344, 0.3771876096725464, 0.39381325244903564, 0.40748095512390137, 0.4087049067020416, 0.41013288497924805, 0.41074487566947937, 0.4113568663597107, 0.41166284680366516, 0.411968857049942, 0.41166284680366516, 0.41156086325645447, 0.4120708405971527, 0.4113568663597107, 0.41084685921669006, 0.41074487566947937, 0.40941891074180603, 0.4096229076385498, 0.41013288497924805, 0.40921491384506226, 0.4097248911857605, 0.4104388654232025, 0.41094887256622314] # noqa 501
depth_data=[0.3828616142272949, 0.38326960802078247, 0.38755351305007935, 0.41376692056655884, 0.46119585633277893, 0.5239244699478149, 0.605522632598877, 0.7151702046394348, 0.8509292006492615, 1.0121876001358032, 1.0288132429122925, 1.0424809455871582, 1.043704867362976, 1.0451328754425049, 1.0457448959350586, 1.0463569164276123, 1.0466628074645996, 1.0469688177108765, 1.0466628074645996, 1.0465608835220337, 1.047070860862732, 1.0463569164276123, 1.0458468198776245, 1.0457448959350586, 1.0444189310073853, 1.0446228981018066, 1.0451328754425049, 1.0442149639129639, 1.044724941253662, 1.0454388856887817, 1.04594886302948] # noqa 501
)

with pytest.raises(ValueError, match="Packet expected 3 sections, found 2 sections"):
Expand Down
9 changes: 6 additions & 3 deletions src/surface/transceiver/transceiver/serial_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

AMBIENT_PRESSURE_DEFAULT = 1013.25 # in (mbar)

# AKA the length of the float in (m)
FLOAT_CONVERSION_FACTOR = 0.635
# Distance from the pressure sensor to the bottom of the float (m)
PRESSURE_SENSOR_VERTICAL_OFFSET = 0.635

AVERAGE_QUEUE_LEN = 5

Expand Down Expand Up @@ -156,7 +156,10 @@ def message_parser(self, packet: str) -> FloatData:

# Starts out as float
depth_data_list.append(
(float(pressure_reading) - self.surface_pressure) * MBAR_TO_METER_OF_HEAD)
(float(pressure_reading) - self.surface_pressure) * MBAR_TO_METER_OF_HEAD
+ PRESSURE_SENSOR_VERTICAL_OFFSET
)

msg.time_data = time_data_list
msg.depth_data = depth_data_list

Expand Down

0 comments on commit cd41184

Please sign in to comment.