mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-01 17:10:26 +08:00
Fixed PnP camera matrix empty when computing loop closure. Updated odometry nonholomic motion estimation (using arc around ICR).
This commit is contained in:
@@ -127,7 +127,9 @@ void CameraThread::mainLoop()
|
||||
if(_cameraRGBD)
|
||||
{
|
||||
SensorData data;
|
||||
if(dynamic_cast<CameraStereoDC1394*>(_cameraRGBD) || dynamic_cast<CameraStereoDC1394*>(_cameraRGBD))
|
||||
if(dynamic_cast<CameraStereoFlyCapture2*>(_cameraRGBD) ||
|
||||
dynamic_cast<CameraStereoDC1394*>(_cameraRGBD) ||
|
||||
dynamic_cast<CameraStereoImages*>(_cameraRGBD))
|
||||
{
|
||||
//stereo
|
||||
data = SensorData(rgb, depth, StereoCameraModel(fx, fx, cx, cy, fyOrBaseline, _cameraRGBD->getLocalTransform()), ++_seq, stamp);
|
||||
|
||||
@@ -1975,20 +1975,29 @@ Transform Memory::computeVisualTransform(
|
||||
UWARN("PnP estimation and Epipolar geometry estimation are set, only PnP is used.");
|
||||
}
|
||||
|
||||
if(!newS.sensorData().rightRaw().empty() && !newS.sensorData().stereoCameraModel().isValid())
|
||||
{
|
||||
UERROR("Calibrated stereo camera required");
|
||||
}
|
||||
else if(!newS.sensorData().depthRaw().empty() &&
|
||||
(newS.sensorData().cameraModels().size() != 1 || !newS.sensorData().cameraModels()[0].isValid()))
|
||||
if((!newS.sensorData().rightRaw().empty() ||
|
||||
!newS.sensorData().stereoCameraModel().isValid()) &&
|
||||
(!newS.sensorData().depthRaw().empty() ||
|
||||
newS.sensorData().cameraModels().size() != 1 ||
|
||||
!newS.sensorData().cameraModels()[0].isValid()))
|
||||
{
|
||||
UERROR("Calibrated camera required (multi-cameras not supported).");
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat K = newS.sensorData().cameraModels().size()?newS.sensorData().cameraModels()[0].K():newS.sensorData().stereoCameraModel().left().K();
|
||||
Transform localTransform = newS.sensorData().cameraModels().size()?newS.sensorData().cameraModels()[0].localTransform():newS.sensorData().stereoCameraModel().left().localTransform();
|
||||
|
||||
cv::Mat K;
|
||||
Transform localTransform;
|
||||
if(newS.sensorData().cameraModels().size())
|
||||
{
|
||||
K = newS.sensorData().cameraModels()[0].K();
|
||||
localTransform = newS.sensorData().cameraModels()[0].localTransform();
|
||||
}
|
||||
else
|
||||
{
|
||||
K = newS.sensorData().stereoCameraModel().left().K();
|
||||
localTransform = newS.sensorData().stereoCameraModel().left().localTransform();
|
||||
}
|
||||
UASSERT(!K.empty() && !localTransform.isNull());
|
||||
// 2D -> 3D
|
||||
if(!oldS.getWords3().empty() && !newS.getWords().empty())
|
||||
{
|
||||
@@ -4268,11 +4277,22 @@ Signature * Memory::createSignature(const SensorData & data, const Transform & p
|
||||
data.stamp(),
|
||||
"",
|
||||
pose,
|
||||
data.userData(),
|
||||
SensorData(
|
||||
rtabmap::compressData2(laserScan),
|
||||
data.laserScanMaxPts(),
|
||||
cv::Mat(), cv::Mat(), CameraModel(), id));
|
||||
data.userData(),
|
||||
stereoCameraModel.isValid()?
|
||||
SensorData(
|
||||
rtabmap::compressData2(laserScan),
|
||||
data.laserScanMaxPts(),
|
||||
cv::Mat(),
|
||||
cv::Mat(),
|
||||
stereoCameraModel,
|
||||
id):
|
||||
SensorData(
|
||||
rtabmap::compressData2(laserScan),
|
||||
data.laserScanMaxPts(),
|
||||
cv::Mat(),
|
||||
cv::Mat(),
|
||||
cameraModels,
|
||||
id));
|
||||
}
|
||||
s->setWords(words);
|
||||
s->setWords3(words3D);
|
||||
|
||||
@@ -218,14 +218,15 @@ Transform Odometry::process(const SensorData & data, OdometryInfo * info)
|
||||
|
||||
if(!_holonomic)
|
||||
{
|
||||
float tmpY = x * tan(yaw);
|
||||
// arc trajectory around ICR
|
||||
float tmpY = yaw!=0.0f ? x / tan((CV_PI-yaw)/2.0f) : 0.0f;
|
||||
if(fabs(tmpY) < fabs(y) || (tmpY<=0 && y >=0) || (tmpY>=0 && y<=0))
|
||||
{
|
||||
y = tmpY;
|
||||
}
|
||||
else
|
||||
{
|
||||
yaw = atan(y/x);
|
||||
yaw = (atan(x/y)*2.0f-CV_PI)*-1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,14 +245,15 @@ Transform Odometry::process(const SensorData & data, OdometryInfo * info)
|
||||
}
|
||||
else if(!_holonomic)
|
||||
{
|
||||
float tmpY = x * tan(yaw);
|
||||
// arc trajectory around ICR
|
||||
float tmpY = yaw!=0.0f ? x / tan((CV_PI-yaw)/2.0f) : 0.0f;
|
||||
if(fabs(tmpY) < fabs(y) || (tmpY<=0 && y >=0) || (tmpY>=0 && y<=0))
|
||||
{
|
||||
y = tmpY;
|
||||
}
|
||||
else
|
||||
{
|
||||
yaw = atan(y/x);
|
||||
yaw = (atan(x/y)*2.0f-CV_PI)*-1;
|
||||
}
|
||||
}
|
||||
UASSERT_MSG(uIsFinite(x) && uIsFinite(y) && uIsFinite(z) &&
|
||||
|
||||
Reference in New Issue
Block a user