SpectacularAI / sdk-examples

Spectacular AI SDK examples
Apache License 2.0
213 stars 34 forks source link

Is it possible to load a saved map for replay? #139

Open genkv opened 2 months ago

genkv commented 2 months ago

Hi, I run into this scenario when I have SLAM-ed and saved a map. Then, a couple other recordings are completed in the same environment of the map using recording only mode. In order to make every session's coordinate consistent, I want to load the same map for each replay of the recording.

Similar to the code here: https://github.com/SpectacularAI/sdk-examples/blob/8ef5ae723a4442a2946bf1ee117ae6a4612d2367/python/oak/mixed_reality.py#L178

I used this config for replay:

config = {
            "useSlam": True,
            "mapLoadPath": map_save_path,
            "fixedMap": True
        }

replay = spectacularAI.Replay(str(video_dir), configuration=config)
replay.setOutputCallback(onOutput)
replay.runReplay()

But the callback function onOutput was never called. If I choose not to use this config, the replay will generate poses for each recording. So I was just wondering if this is possible?

kaatrasa commented 1 month ago

Hey!

With Replay API, the best approach is to use relocalization parameter set, and I just updated the examples to use it also. Basically, with Replay API, just add

configInternal["mapLoadPath"] = args.mapLoadPath 
configInternal["extendParameterSets"] = ["relocalization"]

Note that the SLAM map relocalization mode is still somewhat experimental and might not be able to reliably relocalize in all environments. For your use case, I would consider using April Tags instead: https://github.com/SpectacularAI/sdk-examples/blob/main/python/oak/april_tag.py