You’re reading an older version of the Slamcore SDK documenation. The latest one is 23.04.

File slam_system_callback.hpp

Main SLAM API class, integrating everything.

namespace slamcore

Main namespace for the Slamcore public API

Helper conversion methods

slamcore::ImageFormat \(\leftrightarrow\) BytesPerChannel

Get information about the client library

class SLAMSystemCallbackInterface : public SLAMSystemInterface
#include <slam_system_callback.hpp>

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

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

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

// register any callbacks
 [](const slamcore::PoseInterface<slamcore::camera_clock>::CPtr& pose)
   // do something with the pose!
// ...


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


// poll for data

// cleanup SLAM

// clean up the library

See also


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


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 spinOnce(std::chrono::duration<Rep, Period> timeout)

Spin waiting for data and invoke the corresponding registered callback (in the current thread)



  • positive - Timeout,

  • zero - Wait indefinitely,

  • negative - Try to invoke a registered callback if is the data available, otherwise return immediately.


true A registered callback was invoked


false No callback was invoked before timing out

inline bool spinOnce()

Helper function to spin indefinitely.

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

Invokes all the callbacks waiting since the last spin call, up to a user-defined maximum duration.



  • positive - Timeout,

  • zero or negative - Invokes all waiting callbacks.


true At least one callback was invoked


false No callback was invoked

inline bool spinSome()

Helper to invoke all the callbacks waiting since the last spin call.

Protected Functions

virtual void registerCallbackImpl(Stream, const std::function<void(const ConstTaggedObject&)>&) = 0
virtual bool spinOnceImpl(std::chrono::nanoseconds timeout) = 0
virtual bool spinSomeImpl(std::chrono::nanoseconds duration) = 0

Private Types

template<Stream stream>
using StreamType_t = typename StreamType<stream>::type