Class slamcore::SLAMSystemCallbackInterface

class SLAMSystemCallbackInterface : public SLAMSystemInterface

Main object for creating, executing and interacting with the SLAM procedure. Use it as a standard device (open \(\rightarrow\) start streaming \(\rightarrow\) grab data \(\rightarrow\) close).

A standard way of getting SLAM up ‘n running would be the following. To simplify the procedure, error handling is not shown, see hello_world_all_streams.cpp for a minimal working example of this:

// Initialise the library
slamcoreInit()

// Create a system configuration
v0::SystemConfiguration cfg;

// create a SLAM System
slamcore::SLAMSystemCallbackInterface::Ptr slam = slamcore::createSLAMSystem(cfg);

// register any callbacks
slam->registerCallback<slamcore::Stream::Pose>(
 [](const slamcore::PoseInterface<slamcore::camera_clock>::CPtr& pose)
 {
   // do something with the pose!
 });
// ...

slam->open();

// enable the streams you need
slam->setStreamEnabled(slamcore::Stream::Pose, true);
// ...

slam->start();

// poll for data
while(slam->spin(std::chrono::seconds(1)));

// cleanup SLAM
slam->stop();
slam->close();

// clean up the library
slamcoreDeinit();

See also

createSLAMSystem

Public Functions

virtual ~SLAMSystemCallbackInterface() = default
template<Stream stream>
inline void registerCallback(const std::function<void(const std::shared_ptr<const StreamType_t<stream>>&)> &fn)

Register a callback.

   Can register one callback per stream, repeated calls with the same stream will overwrite
   the previously registered callback.

If the callback is empty then any registered callback on that stream will be removed.

Template Parameters

stream – The stream to register the callback on

Parameters

fn – The function to register, must have the signature void(const std::shared_ptr<const InterfaceT>&) where InterfaceT is the corresponding type to the stream.

template<typename Rep, typename Period>
inline bool spin(std::chrono::duration<Rep, Period> timeout)

Spin waiting for next frame and invoke the corresponding registered callbacks (in the current thread)

Parameters

timeout

  • positive - Wait for the next frame up to the given duration

  • zero - Wait indefinitely for the next frame

  • negative - Try to invoke registered callbacks if the next frame is available, otherwise return immediately.

Returns

true The next frame was available

Returns

false No new frame available

inline bool spin()

Helper function to spin indefinitely.