mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 17:40:23 +08:00
Added parameter Rtabmap/LoopGPS (default true) to enabled/disable the use of GPS in likelihood computation
This commit is contained in:
@@ -193,6 +193,7 @@ class RTABMAP_EXP Parameters
|
||||
// Hypotheses selection
|
||||
RTABMAP_PARAM(Rtabmap, LoopThr, float, 0.11, "Loop closing threshold.");
|
||||
RTABMAP_PARAM(Rtabmap, LoopRatio, float, 0, "The loop closure hypothesis must be over LoopRatio x lastHypothesisValue.");
|
||||
RTABMAP_PARAM(Rtabmap, LoopGPS, bool, true, uFormat("Use GPS to filter likelihood (if GPS is recorded). Only locations inside the local radius \"%s\" of the current GPS location are considered for loop closure detection.", kRGBDLocalRadius().c_str()));
|
||||
|
||||
// Memory
|
||||
RTABMAP_PARAM(Mem, RehearsalSimilarity, float, 0.6, "Rehearsal similarity.");
|
||||
|
||||
@@ -261,6 +261,7 @@ private:
|
||||
float _pathAngularVelocity;
|
||||
bool _savedLocalizationIgnored;
|
||||
bool _loopCovLimited;
|
||||
bool _loopGPS;
|
||||
|
||||
std::pair<int, float> _loopClosureHypothesis;
|
||||
std::pair<int, float> _highestHypothesis;
|
||||
|
||||
@@ -124,6 +124,7 @@ Rtabmap::Rtabmap() :
|
||||
_pathAngularVelocity(Parameters::defaultRGBDPlanAngularVelocity()),
|
||||
_savedLocalizationIgnored(Parameters::defaultRGBDSavedLocalizationIgnored()),
|
||||
_loopCovLimited(Parameters::defaultRGBDLoopCovLimited()),
|
||||
_loopGPS(Parameters::defaultRtabmapLoopGPS()),
|
||||
_loopClosureHypothesis(0,0.0f),
|
||||
_highestHypothesis(0,0.0f),
|
||||
_lastProcessTime(0.0),
|
||||
@@ -469,6 +470,7 @@ void Rtabmap::parseParameters(const ParametersMap & parameters)
|
||||
Parameters::parse(parameters, Parameters::kRGBDPlanAngularVelocity(), _pathAngularVelocity);
|
||||
Parameters::parse(parameters, Parameters::kRGBDSavedLocalizationIgnored(), _savedLocalizationIgnored);
|
||||
Parameters::parse(parameters, Parameters::kRGBDLoopCovLimited(), _loopCovLimited);
|
||||
Parameters::parse(parameters, Parameters::kRtabmapLoopGPS(), _loopGPS);
|
||||
|
||||
UASSERT(_rgbdLinearUpdate >= 0.0f);
|
||||
UASSERT(_rgbdAngularUpdate >= 0.0f);
|
||||
@@ -1399,37 +1401,41 @@ bool Rtabmap::process(
|
||||
ULOGGER_INFO("computing likelihood...");
|
||||
|
||||
std::list<int> signaturesToCompare;
|
||||
GPS originGPS = signature->sensorData().gps();
|
||||
GPS originGPS;
|
||||
Transform originOffsetENU = Transform::getIdentity();
|
||||
if(originGPS.stamp() == 0.0 && _currentSessionHasGPS)
|
||||
if(_loopGPS)
|
||||
{
|
||||
UTimer tmpT;
|
||||
if(_optimizedPoses.size() && _memory->isIncremental())
|
||||
originGPS = signature->sensorData().gps();
|
||||
if(originGPS.stamp() == 0.0 && _currentSessionHasGPS)
|
||||
{
|
||||
//Search for latest node having GPS linked to current signature not too far.
|
||||
std::map<int, float> nearestIds = graph::getNodesInRadius(signature->id(), _optimizedPoses, _localRadius);
|
||||
for(std::map<int, float>::reverse_iterator iter=nearestIds.rbegin(); iter!=nearestIds.rend(); ++iter)
|
||||
UTimer tmpT;
|
||||
if(_optimizedPoses.size() && _memory->isIncremental())
|
||||
{
|
||||
const Signature * s = _memory->getSignature(iter->first);
|
||||
UASSERT(s!=0);
|
||||
if(s->sensorData().gps().stamp() > 0.0)
|
||||
//Search for latest node having GPS linked to current signature not too far.
|
||||
std::map<int, float> nearestIds = graph::getNodesInRadius(signature->id(), _optimizedPoses, _localRadius);
|
||||
for(std::map<int, float>::reverse_iterator iter=nearestIds.rbegin(); iter!=nearestIds.rend(); ++iter)
|
||||
{
|
||||
originGPS = s->sensorData().gps();
|
||||
const Transform & sPose = _optimizedPoses.at(s->id());
|
||||
Transform localToENU(0,0,(float)((-(originGPS.bearing()-90))*M_PI/180.0) - sPose.theta());
|
||||
originOffsetENU = localToENU * (sPose.rotation()*(sPose.inverse()*_optimizedPoses.at(signature->id())));
|
||||
break;
|
||||
const Signature * s = _memory->getSignature(iter->first);
|
||||
UASSERT(s!=0);
|
||||
if(s->sensorData().gps().stamp() > 0.0)
|
||||
{
|
||||
originGPS = s->sensorData().gps();
|
||||
const Transform & sPose = _optimizedPoses.at(s->id());
|
||||
Transform localToENU(0,0,(float)((-(originGPS.bearing()-90))*M_PI/180.0) - sPose.theta());
|
||||
originOffsetENU = localToENU * (sPose.rotation()*(sPose.inverse()*_optimizedPoses.at(signature->id())));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//else if(!_memory->isIncremental()) // TODO, how can we estimate current GPS position in localization?
|
||||
//{
|
||||
//}
|
||||
}
|
||||
if(originGPS.stamp() > 0.0)
|
||||
{
|
||||
// no need to save it if it is in localization mode
|
||||
_gpsGeocentricCache.insert(std::make_pair(signature->id(), std::make_pair(originGPS.toGeodeticCoords().toGeocentric_WGS84(), originOffsetENU)));
|
||||
}
|
||||
//else if(!_memory->isIncremental()) // TODO, how can we estimate current GPS position in localization?
|
||||
//{
|
||||
//}
|
||||
}
|
||||
if(originGPS.stamp() > 0.0)
|
||||
{
|
||||
// no need to save it if it is in localization mode
|
||||
_gpsGeocentricCache.insert(std::make_pair(signature->id(), std::make_pair(originGPS.toGeodeticCoords().toGeocentric_WGS84(), originOffsetENU)));
|
||||
}
|
||||
|
||||
for(std::map<int, double>::const_iterator iter=_memory->getWorkingMem().begin();
|
||||
|
||||
Reference in New Issue
Block a user