Re: RTABMAP standalone for localization in xyz (Kinect Xbox 360)
Posted by
matlabbe on
URL: http://official-rtab-map-forum.206.s1.nabble.com/RTABMAP-standalone-for-localization-in-xyz-Kinect-Xbox-360-tp2706p2753.html
Hi,
RTAB-Map doesn't do motion estimation using only RGB, it requires also depth images (or stereo images). Without going deep in all options that can be done for motion estimation, here is a simple example using
RegistrationVis class:
#include <rtabmap/core/RegistrationVis.h>
#include <rtabmap/core/CameraRGBD.h>
using namespace rtabmap;
int main(int argc, char * argv[])
{
CameraFreenect camera; // Assume Kinect for XBOX 360
camera.setImageRate(1); // capture at 1 Hz
Transform opticalRotation(0,0,1,0, -1,0,0,0, 0,-1,0,0);
camera.setLocalTransform(opticalRotation); // from camera frame to rtabmap/ros frame
if(!camera.init())
{
printf("Failed to initialize the camera!\n");
return -1;
}
RegistrationVis registration;
SensorData frame = camera.takeImage();
SensorData previousFrame = frame;
while(frame.isValid())
{
Transform t = registration.computeTransformation(previousFrame, frame);
if(t.isNull())
{
printf("Could not compute motion\n");
}
else
{
printf("Motion: %s\n", t.prettyPrint().c_str());
}
previousFrame = frame;
frame = camera.takeImage();
}
return 0;
}
Well, the RegistrationVis class may be a little complicated at first look, it is because it can handle the case where visual features have to be computed and matched. The actual transformation computation is done by functions in
util3d_motion_estimation.h. For a more general usage of RegistrationVis, you can look at the
OdometryF2F class.
cheers,
Mathieu