Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve scale estimation calculation slightly #63

Open
wants to merge 1 commit into
base: indigo-devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/stateestimation/PTAMWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ TooN::Vector<3> PTAMWrapper::evalNavQue(unsigned int from, unsigned int to, bool
pthread_mutex_lock(&navInfoQueueCS);
int skipped=0;
int used = 0;
int firstZ = 0;
double firstZ = 0;

float sum_first=0, num_first=0, sum_last=0, num_last=0;
int pressureAverageRange = 100;
Expand Down Expand Up @@ -822,8 +822,15 @@ TooN::Vector<3> PTAMWrapper::evalNavQue(unsigned int from, unsigned int to, bool
if(firstAdded == 0)
{
firstAdded = frontStamp;
firstZ = cur->altd;
predIMUOnlyForScale->z = firstZ*0.001; // avoid height check initially!
firstZ = (cur->altd * 0.001) / sqrt(1.0 + (tan(cur->rotX * 3.14159268 / 180)*tan(cur->rotX * 3.14159268 / 180)) \
+ (tan(cur->rotY * 3.14159268 / 180)*tan(cur->rotY * 3.14159268 / 180)) );

if (! std::isfinite(firstZ))
firstZ = cur->altd * 0.001;


predIMUOnlyForScale->z = firstZ; // avoid height check initially!

}
lastAdded = frontStamp;
// add
Expand All @@ -837,7 +844,7 @@ TooN::Vector<3> PTAMWrapper::evalNavQue(unsigned int from, unsigned int to, bool

}
//printf("QueEval: before: %i; skipped: %i, used: %i, left: %i\n", totSize, skipped, used, navInfoQueue.size());
predIMUOnlyForScale->z -= firstZ*0.001; // make height to height-diff
predIMUOnlyForScale->z -= firstZ; // make height to height-diff

*zCorrupted = predIMUOnlyForScale->zCorrupted;
*allCorrupted = abs(firstAdded - (int)from) + abs(lastAdded - (int)to) > 80;
Expand Down
24 changes: 15 additions & 9 deletions src/stateestimation/Predictor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,21 @@ void Predictor::predictOneStep(ardrone_autonomy::Navdata* nfo)
x += sin(yawRad)*dxDrone+cos(yawRad)*dyDrone;
y += cos(yawRad)*dxDrone-sin(yawRad)*dyDrone;

// height
if(abs(z - (double)nfo->altd*0.001) > 0.12)
{
if(std::abs(z - (double)nfo->altd*0.001) > abs(zCorruptedJump))
zCorruptedJump = z - (double)nfo->altd*0.001;
zCorrupted = true;
}

z = nfo->altd*0.001;
double alt = (nfo->altd*0.001) / sqrt(1.0 + (tan(nfo->rotX * 3.14159268 / 180)*tan(nfo->rotX * 3.14159268 / 180)) \
+ (tan(nfo->rotY * 3.14159268 / 180)*tan(nfo->rotY * 3.14159268 / 180)) );

if (! std::isfinite(alt))
alt = nfo->altd * 0.001;

// height
if(abs(z - alt) > 0.12)
{
if(std::abs(z - alt) > abs(zCorruptedJump))
zCorruptedJump = z - alt;
zCorrupted = true;
}

z = alt;

// angles
roll = nfo->rotX/1000.0;
Expand Down