33"""pypozyx.structures.sensor_data - Contains container classes for data from the Pozyx's many sensors."""
44from math import sqrt
55
6- from pypozyx .definitions .constants import (POZYX_ACCEL_DIV_MG , POZYX_MAG_DIV_UT , POZYX_GYRO_DIV_DPS ,
7- POZYX_QUAT_DIV , POZYX_MAX_LIN_ACCEL_DIV_MG , POZYX_TEMP_DIV_CELSIUS , POZYX_PRESS_DIV_PA , POZYX_EULER_DIV_DEG )
6+ from pypozyx .definitions .constants import PozyxConstants
87from pypozyx .structures .byte_structure import ByteStructure
98from pypozyx .structures .generic import XYZ , SingleSensorValue
109
@@ -14,7 +13,7 @@ class Coordinates(XYZ):
1413 byte_size = 12
1514 data_format = 'iii'
1615
17- def load (self , data , convert = 0 ):
16+ def load (self , data , convert = False ):
1817 self .data = data
1918 self .x = data [0 ]
2019 self .y = data [1 ]
@@ -23,36 +22,36 @@ def load(self, data, convert=0):
2322
2423class Acceleration (XYZ ):
2524 """Container for acceleration in x, y, and z (in mg)."""
26- physical_convert = POZYX_ACCEL_DIV_MG
25+ physical_convert = PozyxConstants . POZYX_ACCEL_DIV_MG
2726
2827 byte_size = 6
2928 data_format = 'hhh'
3029
3130
3231class Magnetic (XYZ ):
3332 """Container for coordinates in x, y, and z (in uT)."""
34- physical_convert = POZYX_MAG_DIV_UT
33+ physical_convert = PozyxConstants . POZYX_MAG_DIV_UT
3534
3635 byte_size = 6
3736 data_format = 'hhh'
3837
3938
4039class AngularVelocity (XYZ ):
4140 """Container for angular velocity in x, y, and z (in dps)."""
42- physical_convert = POZYX_GYRO_DIV_DPS
41+ physical_convert = PozyxConstants . POZYX_GYRO_DIV_DPS
4342
4443 byte_size = 6
4544 data_format = 'hhh'
4645
4746
4847class LinearAcceleration (XYZ ):
4948 """Container for linear acceleration in x, y, and z (in mg), as floats."""
50- physical_convert = POZYX_ACCEL_DIV_MG
49+ physical_convert = PozyxConstants . POZYX_ACCEL_DIV_MG
5150
5251 byte_size = 6
5352 data_format = 'hhh'
5453
55- def load (self , data , convert = 1 ):
54+ def load (self , data , convert = True ):
5655 if convert :
5756 self .x = float (data [0 ]) / self .physical_convert
5857 self .y = float (data [1 ]) / self .physical_convert
@@ -96,7 +95,7 @@ def __str__(self):
9695
9796class Quaternion (XYZ ):
9897 """Container for quaternion data in x, y, z and w."""
99- physical_convert = POZYX_QUAT_DIV
98+ physical_convert = PozyxConstants . POZYX_QUAT_DIV
10099
101100 byte_size = 8
102101 data_format = 'hhhh'
@@ -107,7 +106,7 @@ def __init__(self, w=0, x=0, y=0, z=0):
107106 self .data = [w , x , y , z ]
108107 self .w = w
109108
110- def load (self , data , convert = 1 ):
109+ def load (self , data , convert = True ):
111110 for i in range (len (data )):
112111 data [i ] = float (data [i ])
113112 XYZ .load (self , data [1 :4 ], convert )
@@ -141,14 +140,14 @@ def __str__(self):
141140
142141
143142class MaxLinearAcceleration (SingleSensorValue ):
144- physical_convert = POZYX_MAX_LIN_ACCEL_DIV_MG
143+ physical_convert = PozyxConstants . POZYX_MAX_LIN_ACCEL_DIV_MG
145144
146145 byte_size = 2
147146 data_format = 'h'
148147
149148
150149class Temperature (SingleSensorValue ):
151- physical_convert = POZYX_TEMP_DIV_CELSIUS
150+ physical_convert = PozyxConstants . POZYX_TEMP_DIV_CELSIUS
152151
153152 byte_size = 1
154153 data_format = 'b'
@@ -158,15 +157,15 @@ def __str__(self):
158157
159158
160159class Pressure (SingleSensorValue ):
161- physical_convert = POZYX_PRESS_DIV_PA
160+ physical_convert = PozyxConstants . POZYX_PRESS_DIV_PA
162161
163162 byte_size = 4
164163 data_format = 'I'
165164
166165
167166class EulerAngles (ByteStructure ):
168167 """Container for euler angles as heading, roll, and pitch (in degrees)."""
169- physical_convert = POZYX_EULER_DIV_DEG
168+ physical_convert = PozyxConstants . POZYX_EULER_DIV_DEG
170169
171170 byte_size = 6
172171 data_format = 'hhh'
@@ -178,7 +177,7 @@ def __init__(self, heading=0, roll=0, pitch=0):
178177 self .roll = roll
179178 self .pitch = pitch
180179
181- def load (self , data , convert = 1 ):
180+ def load (self , data , convert = True ):
182181 self .data = data
183182 if convert :
184183 self .heading = float (data [0 ]) / self .physical_convert
@@ -236,7 +235,7 @@ def __init__(self, data=[0] * 24):
236235 self .gravity_vector = LinearAcceleration (data [20 ], data [21 ], data [22 ])
237236 self .temperature = Temperature (data [23 ])
238237
239- def load (self , data , convert = 1 ):
238+ def load (self , data , convert = True ):
240239 self .data = data
241240 self .pressure .load ([data [0 ]], convert )
242241 self .acceleration .load (data [1 :4 ], convert )
@@ -272,5 +271,5 @@ def __init__(self, data=[0] * 24):
272271 """Initializes the RawSensorData object"""
273272 SensorData .__init__ (self , data )
274273
275- def load (self , data , convert = 0 ):
276- SensorData .load (self , data , convert = 0 )
274+ def load (self , data ):
275+ SensorData .load (self , data , convert = False )
0 commit comments