YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
realsense2Tracking.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3 * All rights reserved.
4 *
5 * This software may be modified and distributed under the terms of the
6 * BSD-3-Clause license. See the accompanying LICENSE file for details.
7 */
8
9#ifndef REALSENSE2TRACKING_H
10#define REALSENSE2TRACKING_H
11
13
17
18#include "realsense2Driver.h"
19#include <cstring>
20#include <iostream>
21#include <librealsense2/rs.hpp>
22#include <map>
23#include <mutex>
24
25 /**********************************************************************************************************/
26 // This software module is experimental.
27 // It is provided with uncomplete documentation and it may be modified/renamed/removed without any notice.
28 /**********************************************************************************************************/
29
38{
39private:
40 typedef yarp::os::Stamp Stamp;
42
43public:
45 ~realsense2Tracking() override = default;
46
47 // DeviceDriver
48 bool open(yarp::os::Searchable& config) override;
49 bool close() override;
50
51private:
52 //method
53 inline bool initializeRealsenseDevice();
54 inline bool setParams();
55
56 bool pipelineStartup();
57 bool pipelineShutdown();
58 bool pipelineRestart();
59
60public:
61 /* IThreeAxisGyroscopes methods */
62 size_t getNrOfThreeAxisGyroscopes() const override;
63 yarp::dev::MAS_status getThreeAxisGyroscopeStatus(size_t sens_index) const override;
64 bool getThreeAxisGyroscopeName(size_t sens_index, std::string& name) const override;
65 bool getThreeAxisGyroscopeFrameName(size_t sens_index, std::string& frameName) const override;
66 bool getThreeAxisGyroscopeMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
67
68 /* IThreeAxisLinearAccelerometers methods */
69 size_t getNrOfThreeAxisLinearAccelerometers() const override;
70 yarp::dev::MAS_status getThreeAxisLinearAccelerometerStatus(size_t sens_index) const override;
71 bool getThreeAxisLinearAccelerometerName(size_t sens_index, std::string& name) const override;
72 bool getThreeAxisLinearAccelerometerFrameName(size_t sens_index, std::string& frameName) const override;
73 bool getThreeAxisLinearAccelerometerMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
74
75 /* IThreeAxisAngularAccelerometers methods */
76 size_t getNrOfThreeAxisAngularAccelerometers() const override;
77 yarp::dev::MAS_status getThreeAxisAngularAccelerometerStatus(size_t sens_index) const override;
78 bool getThreeAxisAngularAccelerometerName(size_t sens_index, std::string& name) const override;
79 bool getThreeAxisAngularAccelerometerFrameName(size_t sens_index, std::string& frameName) const override;
80 bool getThreeAxisAngularAccelerometerMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
81
82 /* IOrientationSensors methods */
83 size_t getNrOfOrientationSensors() const override;
84 yarp::dev::MAS_status getOrientationSensorStatus(size_t sens_index) const override;
85 bool getOrientationSensorName(size_t sens_index, std::string& name) const override;
86 bool getOrientationSensorFrameName(size_t sens_index, std::string& frameName) const override;
87 bool getOrientationSensorMeasureAsRollPitchYaw(size_t sens_index, yarp::sig::Vector& rpy, double& timestamp) const override;
88
89 /* IPositionSensors methods */
90 size_t getNrOfPositionSensors() const override;
91 yarp::dev::MAS_status getPositionSensorStatus(size_t sens_index) const override;
92 bool getPositionSensorName(size_t sens_index, std::string& name) const override;
93 bool getPositionSensorFrameName(size_t sens_index, std::string& frameName) const override;
94 bool getPositionSensorMeasure(size_t sens_index, yarp::sig::Vector& xyz, double& timestamp) const override;
95
96 /* ILinearVelocitySensors methods */
97 size_t getNrOfLinearVelocitySensors() const override;
98 yarp::dev::MAS_status getLinearVelocitySensorStatus(size_t sens_index) const override;
99 bool getLinearVelocitySensorName(size_t sens_index, std::string& name) const override;
100 bool getLinearVelocitySensorFrameName(size_t sens_index, std::string& frameName) const override;
101 bool getLinearVelocitySensorMeasure(size_t sens_index, yarp::sig::Vector& xyz, double& timestamp) const override;
102
103
104#if 0
105 /* IPoseSensors methods */
106 size_t getNrOfPoseSensors() const ;
107 yarp::dev::MAS_status getPoseSensorStatus(size_t sens_index) const;
108 bool getPoseSensorName(size_t sens_index, std::string& name) const;
109 bool getPoseSensorFrameName(size_t sens_index, std::string& frameName) const;
110 bool getPoseSensorMeasureAsXYZRPY(size_t sens_index, yarp::sig::Vector& xyzrpy, double& timestamp) const;
111#endif
112
113protected:
114 // realsense classes
115 mutable rs2_vector m_last_gyro;
116 mutable rs2_vector m_last_accel;
117 mutable rs2_pose m_last_pose;
118
119 //strings
121 const std::string m_accel_sensor_tag = "accelerations_sensor";
122 const std::string m_gyro_sensor_tag = "gyro_sensor";
123 const std::string m_orientation_sensor_tag = "orientation_sensor";
124 const std::string m_position_sensor_tag = "position_sensor";
125 const std::string m_pose_sensor_tag = "pose_sensor";
126 std::string m_gyroFrameName;
127 std::string m_accelFrameName;
130 std::string m_poseFrameName;
131
132 rs2::config m_cfg;
133 mutable std::mutex m_mutex;
134 rs2::pipeline m_pipeline;
135 rs2::pipeline_profile m_profile;
136 mutable std::string m_lastError;
139
140 /*
141 rs2::context m_ctx;
142
143 rs2::device m_device;
144 std::vector<rs2::sensor> m_sensors;
145
146 bool m_verbose;
147 bool m_initialized;
148 std::vector<cameraFeature_id_t> m_supportedFeatures;*/
149};
150#endif
analog sensor interface
const std::string m_position_sensor_tag
yarp::dev::MAS_status getThreeAxisGyroscopeStatus(size_t sens_index) const override
Get the status of the specified sensor.
bool getLinearVelocitySensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
std::string m_orientationFrameName
timestamp_enumtype m_timestamp_type
bool getThreeAxisLinearAccelerometerName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
bool getThreeAxisLinearAccelerometerFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
size_t getNrOfPositionSensors() const override
Get the number of position sensors exposed by this device.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
bool getPositionSensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
const std::string m_accel_sensor_tag
size_t getNrOfThreeAxisLinearAccelerometers() const override
Get the number of three axis linear accelerometers exposed by this device.
size_t getNrOfOrientationSensors() const override
Get the number of orientation sensors exposed by this device.
bool getThreeAxisAngularAccelerometerFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
yarp::dev::MAS_status getOrientationSensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
const std::string m_pose_sensor_tag
bool getThreeAxisLinearAccelerometerMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last reading of the specified sensor.
std::string m_inertial_sensor_name_prefix
bool getLinearVelocitySensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
const std::string m_gyro_sensor_tag
bool close() override
Close the DeviceDriver.
const std::string m_orientation_sensor_tag
bool getPositionSensorMeasure(size_t sens_index, yarp::sig::Vector &xyz, double &timestamp) const override
Get the last reading of the position sensor as x y z.
bool getThreeAxisGyroscopeName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
size_t getNrOfThreeAxisAngularAccelerometers() const override
Get the number of three axis angular accelerometers exposed by this device.
bool getOrientationSensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
bool getThreeAxisGyroscopeFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
bool getThreeAxisAngularAccelerometerName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
std::string m_positionFrameName
bool getPositionSensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
~realsense2Tracking() override=default
rs2::pipeline_profile m_profile
bool getOrientationSensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
yarp::dev::MAS_status getLinearVelocitySensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
size_t getNrOfLinearVelocitySensors() const override
Get the number of linear velocity sensors exposed by this device.
bool getOrientationSensorMeasureAsRollPitchYaw(size_t sens_index, yarp::sig::Vector &rpy, double &timestamp) const override
Get the last reading of the orientation sensor as roll pitch yaw.
bool getLinearVelocitySensorMeasure(size_t sens_index, yarp::sig::Vector &xyz, double &timestamp) const override
Get the last reading of the linear velocity sensor as x y z.
yarp::dev::MAS_status getThreeAxisAngularAccelerometerStatus(size_t sens_index) const override
Get the status of the specified sensor.
yarp::dev::MAS_status getThreeAxisLinearAccelerometerStatus(size_t sens_index) const override
Get the status of the specified sensor.
bool getThreeAxisGyroscopeMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last reading of the gyroscope.
bool getThreeAxisAngularAccelerometerMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last reading of the specified sensor.
yarp::dev::MAS_status getPositionSensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
size_t getNrOfThreeAxisGyroscopes() const override
Get the number of three axis gyroscopes exposed by this sensor.
Interface implemented by all device drivers.
Device interface to one or multiple orientation sensors, such as IMUs with on board estimation algori...
Device interface to one or multiple position sensors, such as UWB localization sensors.
Device interface to one or multiple three axis gyroscopes.
Device interface to one or multiple three axis linear accelerometers.
A class for storing options and configuration information.
Definition Property.h:33
A base class for nested structures that can be searched.
Definition Searchable.h:31
An abstraction for a time stamp and/or sequence number.
Definition Stamp.h:21
MAS_status
Status of a given analog sensor exposed by a multiple analog sensors interface.