File slam_system_callback.hpp
Main SLAM API class, integrating everything.
-
namespace slamcore
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 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
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 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.
Protected Functions
-
virtual void registerCallbackImpl(Stream, const std::function<void(const ConstTaggedObject&)>&) = 0
Private Types
-
template<Stream stream>
using StreamType_t = typename StreamType<stream>::type
-
virtual ~SLAMSystemCallbackInterface() = default
-
class SLAMSystemCallbackInterface : public SLAMSystemInterface