Skip to content

Commit

Permalink
mc_wind_estimator_tuning: optionally use GNSS velocity
Browse files Browse the repository at this point in the history
Sometimes GNSS is logged but not used
  • Loading branch information
bresch committed Mar 14, 2024
1 parent b2f1122 commit 7c6ecd9
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,20 @@
import quaternion
from scipy import optimize

def getAllData(logfile):
def getAllData(logfile, use_gnss):
log = ULog(logfile)

v_local = np.matrix([getData(log, 'vehicle_local_position', 'vx'),
getData(log, 'vehicle_local_position', 'vy'),
getData(log, 'vehicle_local_position', 'vz')])
if use_gnss:
v_local = np.array([getData(log, 'vehicle_gps_position', 'vel_n_m_s'),
getData(log, 'vehicle_gps_position', 'vel_e_m_s'),
getData(log, 'vehicle_gps_position', 'vel_d_m_s')])
t_v_local = ms2s(getData(log, 'vehicle_gps_position', 'timestamp'))

t_v_local = ms2s(getData(log, 'vehicle_local_position', 'timestamp'))
else:
v_local = np.array([getData(log, 'vehicle_local_position', 'vx'),
getData(log, 'vehicle_local_position', 'vy'),
getData(log, 'vehicle_local_position', 'vz')])
t_v_local = ms2s(getData(log, 'vehicle_local_position', 'timestamp'))

accel = np.matrix([getData(log, 'sensor_combined', 'accelerometer_m_s2[0]'),
getData(log, 'sensor_combined', 'accelerometer_m_s2[1]'),
Expand Down Expand Up @@ -126,8 +132,8 @@ def getData(log, topic_name, variable_name, instance=0):
def ms2s(time_ms):
return time_ms * 1e-6

def run(logfile):
(t, v_body, a_body) = getAllData(logfile)
def run(logfile, use_gnss):
(t, v_body, a_body) = getAllData(logfile, use_gnss)

rho = 1.15 # air densitiy
rho15 = 1.225 # air density at 15 degC
Expand Down Expand Up @@ -197,8 +203,10 @@ def run(logfile):

# Provide parameter file path and name
parser.add_argument('logfile', help='Full ulog file path, name and extension', type=str)
parser.add_argument('--gnss', help='Use GNSS velocity instead of local velocity estimate',
action='store_true')
args = parser.parse_args()

logfile = os.path.abspath(args.logfile) # Convert to absolute path

run(logfile)
run(logfile, args.gnss)

0 comments on commit 7c6ecd9

Please sign in to comment.