Skip to content

Commit

Permalink
update doc string
Browse files Browse the repository at this point in the history
  • Loading branch information
dxg-aceinna committed Dec 10, 2018
1 parent a50f1cd commit 019e8ef
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 42 deletions.
3 changes: 1 addition & 2 deletions gnss_ins_sim/sim/ins_algo_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

class InsAlgoMgr(object):
'''
A class that manage all algorithms in an INS solution. Plann to support multiple algorithms
in case users want to compare results of different algorithms in a simulation.
A class that manages all algorithms in an INS solution.
'''
def __init__(self, algo):
'''
Expand Down
19 changes: 11 additions & 8 deletions gnss_ins_sim/sim/ins_data_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __init__(self, fs, ref_frame=0):
self.gps_visibility = Sim_data(name='gps_visibility',\
description='GPS visibility')
self.ref_pos = Sim_data(name='ref_pos',\
description='true pos in the navigation frame',\
description='true LLA pos in the navigation frame',\
units=['rad', 'rad', 'm'],\
output_units=['deg', 'deg', 'm'],\
legend=['ref_pos_lat', 'ref_pos_lon', 'ref_pos_alt'])
Expand All @@ -90,23 +90,23 @@ def __init__(self, fs, ref_frame=0):
description='true attitude (quaternion)',\
legend=['q0', 'q1', 'q2', 'q3'])
self.ref_gyro = Sim_data(name='ref_gyro',\
description='true angular velocity',\
description='true angular velocity in the body frame',\
units=['rad/s', 'rad/s', 'rad/s'],\
output_units=['deg/s', 'deg/s', 'deg/s'],\
legend=['ref_gyro_x', 'ref_gyro_y', 'ref_gyro_z'])
self.ref_accel = Sim_data(name='ref_accel',\
description='True accel',\
description='true accel in the body frame',\
units=['m/s^2', 'm/s^2', 'm/s^2'],\
legend=['ref_accel_x', 'ref_accel_y', 'ref_accel_z'])
self.ref_gps = Sim_data(name='ref_gps',\
description='true GPS pos/vel',\
description='true GPS LLA position and NED velocity',\
units=['rad', 'rad', 'm', 'm/s', 'm/s', 'm/s'],\
output_units=['deg', 'deg', 'm', 'm/s', 'm/s', 'm/s'],\
legend=['ref_gps_lat', 'ref_gps_lon', 'ref_gps_alt',\
'ref_gps_vN', 'ref_gps_vE', 'ref_gps_vD'])
# downsampled true pos/vel
self.ref_mag = Sim_data(name='ref_mag',\
description='true magnetic field',\
description='true magnetic field in the body frame',\
units=['uT', 'uT', 'uT'],\
legend=['ref_mag_x', 'ref_mag_y', 'ref_mag_z'])
# sensor measurements
Expand All @@ -120,7 +120,7 @@ def __init__(self, fs, ref_frame=0):
units=['m/s^2', 'm/s^2', 'm/s^2'],\
legend=['accel_x', 'accel_y', 'accel_z'])
self.gps = Sim_data(name='gps',\
description='GPS measurements',\
description='GPS LLA position and NED velocity measurements',\
units=['rad', 'rad', 'm', 'm/s', 'm/s', 'm/s'],\
output_units=['deg', 'deg', 'm', 'm/s', 'm/s', 'm/s'],\
legend=['gps_lat', 'gps_lon', 'gps_alt',\
Expand Down Expand Up @@ -194,7 +194,8 @@ def __init__(self, fs, ref_frame=0):
legend=['AD_ax', 'AD_ay', 'AD_az'])
# if using virtual inertial frame
if self.ref_frame.data == 1:
# position units and legned
# description, position units and legned
self.ref_pos.description = 'true position in the local NED frame'
self.ref_pos.units = ['m', 'm', 'm']
self.ref_pos.output_units = ['m', 'm', 'm']
self.ref_pos.legend = ['ref_pos_x', 'ref_pos_y', 'ref_pos_z']
Expand All @@ -205,10 +206,12 @@ def __init__(self, fs, ref_frame=0):
self.ref_vel.legend = ['ref_vel_x', 'ref_vel_y', 'ref_vel_z']
self.vel.legend = ['vel_x', 'vel_y', 'vel_z']
# GPS units and legend
self.ref_gps.description = 'true GPS position and velocity in the local NED frame'
self.ref_gps.units = ['m', 'm', 'm', 'm/s', 'm/s', 'm/s']
self.ref_gps.output_units = ['m', 'm', 'm', 'm/s', 'm/s', 'm/s']
self.ref_gps.legend = ['ref_gps_x', 'ref_gps_y', 'ref_gps_z',\
'ref_gps_vx', 'ref_gps_vy', 'ref_gps_vz']
self.gps.description = 'GPS position and velocity measurements in the local NED frame'
self.gps.units = ['m', 'm', 'm', 'm/s', 'm/s', 'm/s']
self.gps.output_units = ['m', 'm', 'm', 'm/s', 'm/s', 'm/s']
self.gps.legend = ['gps_x', 'gps_y', 'gps_z',\
Expand Down Expand Up @@ -302,7 +305,7 @@ def add_data(self, data_name, data, key=None, units=None):
If data is a numpy of size(m,n), units should be a list of n strings
to define the units.
If data is a dict, units should be the same as the above two depending on if
each value in the dict is a scalr or a numpy array.
each value in the dict is a scalar or a numpy array.
'''
if data_name in self.__all:
self.__all[data_name].add_data(data, key, units)
Expand Down
38 changes: 6 additions & 32 deletions gnss_ins_sim/sim/ins_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def __init__(self, fs, motion_def, ref_frame=0, imu=None,\
row 2: initial states, which include:
col 1-3: initial position (LLA, deg, meter),
col 4-6: initial velocity in body frame(m/s),
col 7-9: initial attitude (Euler angles, deg)
col 7-9: initial attitude (Euler angles that rotate the reference frame to the
body frame according to the ZYX rotation sequence, deg).
row 3: header line for motion command
row >=2: motion commands, which include
col 1: motion type. The following types are supported:
Expand All @@ -71,8 +72,9 @@ def __init__(self, fs, motion_def, ref_frame=0, imu=None,\
0: NED (default), with x axis pointing along geographic north,
y axis pointing eastward,
z axis pointing downward.
Position will be expressed in LLA form, and the velocity of the vehicle
relative to the ECEF frame will be expressed in local NED frame.
Position will be expressed in LLA form, and the reference velocity of
the vehicle relative to the ECEF frame will be expressed in the body
frame, and GPS velocity will be expressed in the NED frame.
1: a virtual inertial frame with constant g,
x axis pointing along geographic/magnetic north,
z axis pointing along g,
Expand All @@ -82,7 +84,7 @@ def __init__(self, fs, motion_def, ref_frame=0, imu=None,\
the initial position in ecef and the relative position in the virutal
inertial frame. Indeed, two vectors expressed in different frames should
not be added. This is done in this way here just to preserve all useful
information to generate .kml files.
information to generate .kml files.
Keep this in mind if you use this result.
imu: Define the IMU error model. See IMU in imu_model.py.
Expand Down Expand Up @@ -694,31 +696,3 @@ def __euler2quat_zyx(self, src):
return dst
else:
raise ValueError('%s is not a dict or numpy array.'% src.name)

def __lla_err(self, err_stat):
'''
convert LLA error in [deg, deg, m] to NED position error in [m, m, m].
The NED frame is defined by the first LLA.
This is just an estimation and can providing good accuracy when comparing
points in a small area.
'''
first_lla = self.dmgr.ref_pos.data[0, :]
earth_param = geoparams.geo_param(first_lla)
rm = earth_param[0]
rn = earth_param[1]
rm_effective = rm + first_lla[2]
rn_effective = (rn + first_lla[2]) * math.cos(first_lla[0])
scale = np.array((rm_effective*attitude.D2R, rn_effective*attitude.D2R, 1.0))
if isinstance(err_stat['max'], dict):
for sim_run in sorted(err_stat['max'].keys()):
err_stat['max'][sim_run] = err_stat['max'][sim_run] * scale
err_stat['avg'][sim_run] = err_stat['avg'][sim_run] * scale
err_stat['std'][sim_run] = err_stat['std'][sim_run] * scale
else:
err_stat['max'] = err_stat['max'] * scale
err_stat['avg'] = err_stat['avg'] * scale
err_stat['std'] = err_stat['std'] * scale




0 comments on commit 019e8ef

Please sign in to comment.