Visual SLAM
| Related documentations |
|---|
| Map Manager |
| Tracker Coordinate System |
| Visual SLAM Learning Guide |
The Visual SLAM(Simultaneous Localization and Mapping) creates a map by scanning 3D space.
Please refer Visual SLAM Learning Guide to create a map more precisely while scanning 3D space.
Create Instants
Start / Stop Tracker
Start / Stop Map Creation & Map Saving
Set Rendering Options
Create Instants
>SlamViewController.mm
- (void)viewDidLoad
{
...
trackingManager = [[MasTrackerManager alloc] init];
cameraDevice = [[MasCameraDevice alloc] init];
sensorDevice = [[MasSensorDevice alloc] init];
}
Start / Stop Tracker
To start / stop Tracker, refer to the following code.
>SlamViewController.mm
- (void)resumeAR
{
...
[trackingManager startTracker:TRACKER_TYPE_SLAM];
}
- (void)pauseAR
{
[trackingManager stopTracker];
...
}
Start / Stop Map Creation & Map Saving
- To start a map generation, refer to the following code.
[trackingManager findSurface];
- To stop generating a map, refer to the following code.
[trackingManager quitFindingSurface];
- Saving map is only possible while tracking. Refer to the following code for the file storage location when you save the generated map data as a file.
>SlamViewController.mm
- (NSString *) getFilePath
{
NSArray *documentPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *contentsPath = [[NSString alloc] initWithFormat:@"%@/3DMap", [documentPath objectAtIndex:0]];
NSFileManager *filemanager = [NSFileManager defaultManager];
BOOL isDir;
BOOL exists = [filemanager fileExistsAtPath:contentsPath isDirectory:&isDir];
if(exists == NO)
{
[filemanager createDirectoryAtPath:contentsPath withIntermediateDirectories:YES attributes:nil error:NULL];
}
NSString *filePath = [NSString stringWithFormat:@"%@/%@", contentsPath,[self GetDateForFileName]];
return filePath;
}
Set Rendering Options
Feature points, SLAM initialization progress, and axis can be created with 'FeaturePoint', 'Axis' class. Refer to the following code.
>SlamViewController.mm
- (void)viewDidLoad {
...
featurePoint = [[FeaturePointCPU alloc] init];
axis = [[Axis alloc] init];
...
}
- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
{
...
[featurePoint draw:trackingManager projectionMatrix:projectionMatrix TrackingState:true];
glEnable(GL_DEPTH_TEST);
if([result getCount] > 0)
{
isTracked = true;
MasTrackable *trackable = [result getTrackable:0];
[axis setProjectionMatrix:projectionMatrix];
[axis setPoseMatrix:[trackable getPose]];
[axis setTranslation:0.0f y:0.0f z:0.0f];
[axis setScale:0.5f y:0.5f z:0.5f];
[axis draw];
}
}
Preferably, use landscape left mode (screen orientation) for Visual SLAM.
