forked from andybarry/simflight
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes verifyTvlqrController for estimator-centric controllers. Note: …
…TV controllers still not supported.
- Loading branch information
Showing
8 changed files
with
174 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
% Finds stereo and trajectory reports nearby each other | ||
|
||
% search through log time | ||
|
||
clear paired_times | ||
threshold = 1; | ||
counter = 1; | ||
for i = 1 : length(stereo.logtime) | ||
|
||
this_t = stereo.logtime(i); | ||
|
||
[val, idx] = min(abs(tvlqr.logtime - this_t)); | ||
|
||
if abs(val) < threshold | ||
|
||
tvlqr_t = tvlqr.logtime(idx); | ||
|
||
pair = struct(); | ||
pair.tvlqr_t = tvlqr_t; | ||
pair.stereo_t = this_t; | ||
pair.delta_t = tvlqr_t - this_t; | ||
|
||
paired_times(counter) = pair; | ||
|
||
counter = counter + 1; | ||
end | ||
end | ||
|
||
|
||
val = 0; | ||
for i = 1 : length(paired_times) | ||
val = val + paired_times(i).delta_t; | ||
end | ||
average_delay = val/length(paired_times); | ||
|
||
disp(['Average delay over ' num2str(length(paired_times)) ' is ' num2str(average_delay) ' sec or ' num2str(average_delay*1000) ' ms']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
function state = PoseToStateEstimatorVector(est, index, substract_positions, Mz) | ||
% This mirrors RealtimeUtils.cpp's PoseMsgToStateEstimatorVector | ||
|
||
state = zeros(12,1); | ||
|
||
pos(1) = est.pos.x(index) - substract_positions(1); | ||
pos(2) = est.pos.y(index) - substract_positions(2); | ||
pos(3) = est.pos.z(index) - substract_positions(3); | ||
|
||
% // x, y, and z are always in global frame (add in any custom rotation) | ||
pos_global = Mz * pos'; | ||
|
||
state(1) = pos_global(1); | ||
state(2) = pos_global(2); | ||
state(3) = pos_global(3); | ||
|
||
% // roll, pitch, and yaw come from the quats in the message | ||
|
||
q(1) = est.orientation.q0(index); | ||
q(2) = est.orientation.q1(index); | ||
q(3) = est.orientation.q2(index); | ||
q(4) = est.orientation.q3(index); | ||
|
||
rot_mat = quat2rotmat(q'); | ||
|
||
rpy = rotmat2rpy(Mz * rot_mat); | ||
|
||
state(4) = rpy(1); | ||
state(5) = rpy(2); | ||
state(6) = rpy(3); | ||
|
||
% // velocities are in body frame | ||
state(7) = est.vel.x(index); | ||
state(8) = est.vel.y(index); | ||
state(9) = est.vel.z(index); | ||
|
||
% // rotation rates are given in body frame | ||
% // as angular velocities | ||
|
||
state(10) = est.rotation_rate.x(index); | ||
state(11) = est.rotation_rate.y(index); | ||
state(12) = est.rotation_rate.z(index); | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.