Area file path in positional tracking parameter is not working in ubuntu

Hi, I try to add area file path into positional tracking parameters so I can saveAreaMap at the end. however, I got error “[Positional Tracking] Unable to load area file, [PositionalTracking][ERROR] INVALID ARE FILE”.
I tried so may way but cannot solve this error.

Hi @nctran
can you share you code to verify it?
Are you using a full path for the Area Memory file or are you using a relative path?

I think I found why, my camera is static so the area memory will not save until my camea is moving. however, if I initialize the camera transform and set static to true then I cannot save the area memory. also, when I try to set floor as origin, the spatial mapping will get error and not work.

Please send more information about your code and the errors that you are retrieving, otherwise it’s impossible to understand what’s causing your issues.

here is where is initialize the positional tracking parameters.

Pose pose;
Transform initial_position;
PositionalTrackingParameters positional_tracking_params;
positional_tracking_params.initial_world_transform = initial_position;
positional_tracking_params.enable_area_memory = true;
positional_tracking_params.enable_pose_smoothing = true;
positional_tracking_params.set_as_static = true;
//positional_tracking_params.set_floor_as_origin = true;
//positional_tracking_params.area_file_path = "zedArea.area";
state = zeds[id].camera.enablePositionalTracking(positional_tracking_params);
if (state != ERROR_CODE::SUCCESS) {
    cout << "[PositionTracking][ERROR] " << state << endl;
    return EXIT_FAILURE;

and here is where I initialize the mapping.

SpatialMappingParameters mapping_params;
mapping_params.map_type = SpatialMappingParameters::SPATIAL_MAP_TYPE::FUSED_POINT_CLOUD;
mapping_params.use_chunk_only = true;

I use this to save my mapping and area at the end.

if ("zed0mapping.ply",sl::MESH_FILE_FORMAT::PLY)) {
    cout << "Stored map" << endl;


And what is the error message that you get?

if I uncomment

positional_tracking_params.set_floor_as_origin = true;

then I will get:

[Spatial mapping] [ERROR] this feature requires the spatial mapping to be enabled


Firstly, as you said, if the camera is not moving, the saveAreaMap() function will fail. You can find more information in the API Reference (see the Warning).

Secondly, for set_floor_as_origin, you should check that the positional tracking is enabled before enabling the spatial mapping it this attribute is set to true. Sorry, that is not clear in this sample.

Something like:

            // [while (viewer.isAvailable()) loop
            if (tracking_state == POSITIONAL_TRACKING_STATE::OK) { 

                if (!mappingEnabled) {
                    std::cout << "enabling spatial mapping..." << std::endl;
                    ERROR_CODE s = zed.enableSpatialMapping(spatial_mapping_parameters);

                    if (s != ERROR_CODE::SUCCESS)
                        std::cout << "Error starting spatial mapping: " << s << std::endl;
                        mappingEnabled = true;
            [Rest of while loop...]

And before, instead of directly calling zed.enableSpatialMapping, declare the bool mappingEnabled and set it to false.

Don’t hesitate if you have more questions.