You’re reading an older version of the Slamcore SDK documenation. The latest one is 23.04.
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->spinOnce(std::chrono::seconds(1))); // cleanup SLAM slam->stop(); slam->close(); // clean up the library slamcoreDeinit();
See also
Public Functions
-
virtual ~SLAMSystemCallbackInterface() = default
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>&)
whereInterfaceT
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)
- Parameters
timeout –
positive - Timeout,
zero - Wait indefinitely,
negative - Try to invoke a registered callback if is the data available, otherwise return immediately.
- Returns
true A registered callback was invoked
- Returns
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.
- Parameters
timeout –
positive - Timeout,
zero or negative - Invokes all waiting callbacks.
- Returns
true At least one callback was invoked
- Returns
false No callback was invoked
-
inline bool spinSome()
Helper to invoke all the callbacks waiting since the last spin call.
-
virtual ~SLAMSystemCallbackInterface() = default