You’re reading an older version of the Slamcore SDK documenation. The latest one is 23.04.
File slam.hpp
Introduce the SLAMSystemPollingInterface
and associated classes/enums. The former is the main object for interacting with the SLAM engine.
Helper functions for slamcore::Stream
Helper functions for slamcore::Property
Get information about the client library
Helper functions for slamcore::DataSource
-
template<class Archive>
static inline void load_minimal(const Archive&, DataSource &obj, const std::string &value)
-
template<class Archive>
static inline std::string save_minimal(const Archive&, const DataSource &obj)
-
static inline std::ostream &operator<<(std::ostream &os, const DataSource &obj)
Enums
-
enum class Stream : EnumBaseT
Supported data streams
Values:
-
enumerator Pose
Used for PoseInterface.
-
enumerator Video
Used for MultiFrameInterface.
-
enumerator IMU
Used for IMUListInterface.
-
enumerator ActiveMap
Used for SparseMapInterface.
-
enumerator Velocity
Used for VelocityInterface<camera_clock>
-
enumerator MetaData
Used for MetaDataInterface.
-
enumerator FrameSync
Used for FrameSyncInterface.
-
enumerator ErrorCode
used for ErrorCodeInterface
-
enumerator LocalPointCloud
used for PointCloudInterface
-
enumerator Count
-
enumerator Pose
-
enum class Property : EnumBaseT
Properties to query and set.
Values:
-
enumerator ModelName
std::string
, read-only, device model name
-
enumerator SerialNumber
std::string
, read-only, serial number of the device
-
enumerator SensorInfo
std::string
, read-only, misc sensor info
-
enumerator FirmwareVersion
std::string
, read-only, firmware version
-
enumerator FirmwareBuildTime
std::string
, read-only, firmware build time
-
enumerator FirmwareBuildVersion
std::string
, read-only, contains SLAM build info
-
enumerator FirmwareBuildType
std::string
, read-only, contains SLAM build type info
-
enumerator PositioningMode
PositioningMode
enum, read-only, position mode of the SLAM system
-
enumerator ConfigPresetName
std::string
, read-only, name of config preset
-
enumerator FeatureMap2DEnabled
bool
, read-only, Whether 2D mapping features are enabled
-
enumerator FeatureKinematicsEnabled
bool
, read-only, Whether we are running with kinematics enabled
-
enumerator SaveTrajectories
bool
, Whether trajectories are saved
-
enumerator Count
-
enumerator ModelName
-
template<>
struct StreamType<Stream::Pose> - #include <slam.hpp>
Public Types
-
using type = PoseInterface<camera_clock>
-
using type = PoseInterface<camera_clock>
-
template<>
struct StreamType<Stream::Video> - #include <slam.hpp>
Public Types
-
using type = MultiFrameInterface
-
using type = MultiFrameInterface
-
template<>
struct StreamType<Stream::IMU> - #include <slam.hpp>
Public Types
-
using type = IMUListInterface
-
using type = IMUListInterface
-
template<>
struct StreamType<Stream::ActiveMap> - #include <slam.hpp>
Public Types
-
using type = SparseMapInterface
-
using type = SparseMapInterface
-
template<>
struct StreamType<Stream::Velocity> - #include <slam.hpp>
Public Types
-
using type = VelocityInterface<camera_clock>
-
using type = VelocityInterface<camera_clock>
-
template<>
struct StreamType<Stream::MetaData> - #include <slam.hpp>
Public Types
-
using type = MetaDataInterface
-
using type = MetaDataInterface
-
template<>
struct StreamType<Stream::FrameSync> - #include <slam.hpp>
Public Types
-
using type = FrameSyncInterface
-
using type = FrameSyncInterface
-
template<>
struct StreamType<Stream::ErrorCode> - #include <slam.hpp>
Public Types
-
using type = ErrorCodeInterface
-
using type = ErrorCodeInterface
-
template<>
struct StreamType<Stream::LocalPointCloud> - #include <slam.hpp>
Public Types
-
using type = PointCloudInterface
-
using type = PointCloudInterface
-
namespace slamcore
Main namespace for the SLAMcore public API
Helper functions for slamcore::Stream
Helper functions for slamcore::Property
Get information about the client library
Helper functions for slamcore::DataSource
-
template<class Archive>
static inline void load_minimal(const Archive&, DataSource &obj, const std::string &value)
-
template<class Archive>
static inline std::string save_minimal(const Archive&, const DataSource &obj)
-
static inline std::ostream &operator<<(std::ostream &os, const DataSource &obj)
Helper conversion methods
slamcore::ImageFormat \(\leftrightarrow\) BytesPerPixel
Enums
-
enum class Stream : EnumBaseT
Supported data streams
Values:
-
enumerator Pose
Used for PoseInterface.
-
enumerator Video
Used for MultiFrameInterface.
-
enumerator IMU
Used for IMUListInterface.
-
enumerator ActiveMap
Used for SparseMapInterface.
-
enumerator Velocity
Used for VelocityInterface<camera_clock>
-
enumerator MetaData
Used for MetaDataInterface.
-
enumerator FrameSync
Used for FrameSyncInterface.
-
enumerator ErrorCode
used for ErrorCodeInterface
-
enumerator LocalPointCloud
used for PointCloudInterface
-
enumerator Count
-
enumerator Pose
-
enum class Property : EnumBaseT
Properties to query and set.
Values:
-
enumerator ModelName
std::string
, read-only, device model name
-
enumerator SerialNumber
std::string
, read-only, serial number of the device
-
enumerator SensorInfo
std::string
, read-only, misc sensor info
-
enumerator FirmwareVersion
std::string
, read-only, firmware version
-
enumerator FirmwareBuildTime
std::string
, read-only, firmware build time
-
enumerator FirmwareBuildVersion
std::string
, read-only, contains SLAM build info
-
enumerator FirmwareBuildType
std::string
, read-only, contains SLAM build type info
-
enumerator PositioningMode
PositioningMode
enum, read-only, position mode of the SLAM system
-
enumerator ConfigPresetName
std::string
, read-only, name of config preset
-
enumerator FeatureMap2DEnabled
bool
, read-only, Whether 2D mapping features are enabled
-
enumerator FeatureKinematicsEnabled
bool
, read-only, Whether we are running with kinematics enabled
-
enumerator SaveTrajectories
bool
, Whether trajectories are saved
-
enumerator Count
-
enumerator ModelName
-
template<typename PT>
class PropertiesInterface - #include <slam.hpp>
Helper for handling the properties.
Property-getters
Query property value.
- param pt
Property to query.
- param val
Return value.
- param idx
Optional index for array-like properties.
- return
Error code.
-
template<typename T>
inline std::enable_if<std::is_integral<T>::value, T>::type getProperty(PropertyT pt, std::size_t idx = 0) const
-
template<typename T>
inline std::enable_if<std::is_enum<T>::value, T>::type getProperty(PropertyT pt, std::size_t idx = 0) const
-
template<typename T>
inline std::enable_if<std::is_floating_point<T>::value, T>::type getProperty(PropertyT pt, std::size_t idx = 0) const
-
template<typename T>
inline std::enable_if<std::is_same<T, std::string>::value, T>::type getProperty(PropertyT pt, std::size_t idx = 0) const
-
template<typename T>
inline std::enable_if<std::is_same<T, SensorIDT>::value, T>::type getProperty(PropertyT pt, std::size_t idx = 0) const
Property-setter methods
Set a property.
- param pt
Property to set.
- param val
Value to set.
- param idx
Optional index for array-like properties.
- return
Error code.
-
template<typename T>
inline void setProperty(PropertyT pt, const T &val, std::size_t idx = 0, typename std::enable_if<std::is_integral<T>::value, T>::type* = 0)
-
template<typename T>
inline void setProperty(PropertyT pt, const T &val, std::size_t idx = 0, typename std::enable_if<std::is_enum<T>::value, T>::type* = 0)
-
template<typename T>
inline void setProperty(PropertyT pt, const T &val, std::size_t idx = 0, typename std::enable_if<std::is_floating_point<T>::value, T>::type* = 0)
-
inline void setProperty(PropertyT pt, const VectorInterface &val, std::size_t idx = 0)
-
inline void setProperty(PropertyT pt, const MatrixInterface &val, std::size_t idx = 0)
Public Types
-
using PropertyT = PT
Public Functions
-
virtual ~PropertiesInterface() = default
-
virtual bool isPropertySupported(PropertyT pt) const = 0
Check if we support a particular property.
Protected Functions
-
virtual void setPropertyImpl(PropertyT pt, const VectorInterface &val, std::size_t idx) = 0
-
virtual void setPropertyImpl(PropertyT pt, const MatrixInterface &val, std::size_t idx) = 0
-
class SLAMAsyncTasksInterface
- #include <slam.hpp>
Access to asynchronous tasks.
Subclassed by SLAMSystemInterface
Public Functions
-
virtual ~SLAMAsyncTasksInterface() = default
-
virtual IDT launchAsyncTask(TaskType task, const std::map<std::string, std::string> ¶ms) = 0
Launch asynchronous task.
Note
This is asynchronous API, the task might start after this call returns.
- Parameters
task – Type of task to launch.
params – Map of key-value pairs describing task-specific parameters.
- Returns
Returned unique identifier to distinguish tasks of the same type.
-
virtual void cancelAsyncTask(TaskType task, IDT id) = 0
Cancel an existing asynchronous task.
Note
This is asynchronous API, the task might not be cancelled immediately.
- Parameters
task – Type of task to cancel.
id – Unique identifier of the tasks to cancel.
-
virtual TaskStatusInterface::Ptr getTaskStatus(TaskType task, IDT id) = 0
Get task status.
- Parameters
task – Type of task to check.
id – Unique identifier of the tasks to check.
-
virtual ~SLAMAsyncTasksInterface() = default
-
class SLAMCoreInterface
- #include <slam.hpp>
Core SLAM system functionality.
Subclassed by SLAMSystemInterface
Public Functions
-
virtual ~SLAMCoreInterface() = default
-
virtual void open(const char *name = nullptr) = 0
Open the SLAMcore device.
- Parameters
name – Optional parameters.
-
virtual void openWithSession(const char *path, const char *name = nullptr) = 0
Open the SLAMcore device with preloaded session file.
- Parameters
path – Path to the session file.
name – Optional parameters.
-
virtual void close() = 0
Close the SLAMcore device.
-
virtual bool isOpen() const = 0
Check if the SLAMcore device is already open.
-
virtual void start() = 0
Start streaming data.
-
virtual void stop() = 0
Stop streaming data.
-
virtual bool isRunning() const = 0
Check if we are streaming.
-
virtual bool isStreamEnabled(Stream s) const = 0
Check if a stream of data is enabled.
- Parameters
s – Stream to check.
-
virtual void setStreamEnabled(Stream s, bool v) = 0
Enable/disable streaming of particular data.
- Parameters
s – slamcore::Stream to configure.
v – True/False to enable/disable respectively
-
virtual ~SLAMCoreInterface() = default
-
class SLAMSubsystemAccessInterface
- #include <slam.hpp>
Subsystem access interface.
Subclassed by SLAMSystemInterface
Check if subsystem is supported.
-
virtual bool isSubsystemSupported(const SubsystemType st) const = 0
Check if the given SubsystemType is supported
- Parameters
st – SubsystemType to check.
-
template<typename ST>
inline bool isSubsystemSupported()
Get Subsystem interface.
-
virtual SubsystemInterface::CPtr getSubsystemImpl(const SubsystemType st) const = 0
-
virtual SubsystemInterface::Ptr getSubsystemImpl(const SubsystemType st) = 0
Public Functions
-
virtual ~SLAMSubsystemAccessInterface() = default
-
virtual bool isSubsystemSupported(const SubsystemType st) const = 0
-
class SLAMSystemCallbackInterface : public SLAMSystemInterface
- #include <slam.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->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 a 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)
- 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.
Protected Functions
-
virtual void registerCallbackImpl(Stream, const std::function<void(const ObjectInterface::CPtr&)>&) = 0
Private Types
-
template<Stream stream>
using StreamType_t = typename StreamType<stream>::type
-
virtual ~SLAMSystemCallbackInterface() = default
-
class SLAMSystemInterface : public PropertiesInterface<Property>, public SLAMCoreInterface, public SLAMSubsystemAccessInterface, public SLAMAsyncTasksInterface
- #include <slam.hpp>
Subclassed by SLAMSystemCallbackInterface
- template<> ActiveMap >
- #include <slam.hpp>
Public Types
-
using type = SparseMapInterface
-
using type = SparseMapInterface
- template<> ErrorCode >
- #include <slam.hpp>
Public Types
-
using type = ErrorCodeInterface
-
using type = ErrorCodeInterface
- template<> FrameSync >
- #include <slam.hpp>
Public Types
-
using type = FrameSyncInterface
-
using type = FrameSyncInterface
- template<> IMU >
- #include <slam.hpp>
Public Types
-
using type = IMUListInterface
-
using type = IMUListInterface
- template<> LocalPointCloud >
- #include <slam.hpp>
Public Types
-
using type = PointCloudInterface
-
using type = PointCloudInterface
- template<> MetaData >
- #include <slam.hpp>
Public Types
-
using type = MetaDataInterface
-
using type = MetaDataInterface
- template<> Pose >
- #include <slam.hpp>
Public Types
-
using type = PoseInterface<camera_clock>
-
using type = PoseInterface<camera_clock>
- template<> Velocity >
- #include <slam.hpp>
Public Types
-
using type = VelocityInterface<camera_clock>
-
using type = VelocityInterface<camera_clock>
- template<> Video >
- #include <slam.hpp>
Public Types
-
using type = MultiFrameInterface
-
using type = MultiFrameInterface
-
namespace v0
-
struct SystemConfiguration
- #include <slam.hpp>
Configuration for the system.
The
Mode
member sets the positioning mode:Use
PositioningMode::SLAM
to enable relocalisation and loop-closure.Use
PositioningMode::ODOMETRY_ONLY
for visual-inertial odometry only.
Public Members
-
DataSource Source = DataSource::RealSense
Input data source for SLAM.
-
std::string DatasetPath
Path to a dataset if DataSource::Dataset is set.
-
int DeviceID = 0
Device index for a camera device.
-
bool DisableSLAM = false
Disable SLAM, just pass the data from the camera.
-
PositioningMode Mode = PositioningMode::SLAM
Positioning mode to use.
-
bool GenerateMap = false
Generate height map in the session file.
-
bool EnableWheelOdometry = false
Enable wheel odometry.
-
bool EnableDepth = true
Enable depth stream.
-
bool EnableColor = false
Enable color stream.
-
struct SystemConfiguration
-
template<class Archive>