Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
testRealSense2_T265_imu.cpp
1
/*
2
* ViSP, open source Visual Servoing Platform software.
3
* Copyright (C) 2005 - 2024 by Inria. All rights reserved.
4
*
5
* This software is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
9
* See the file LICENSE.txt at the root directory of this source
10
* distribution for additional information about the GNU GPL.
11
*
12
* For using ViSP with software that can not be combined with the GNU
13
* GPL, please contact Inria about acquiring a ViSP Professional
14
* Edition License.
15
*
16
* See https://visp.inria.fr for more information.
17
*
18
* This software was developed at:
19
* Inria Rennes - Bretagne Atlantique
20
* Campus Universitaire de Beaulieu
21
* 35042 Rennes Cedex
22
* France
23
*
24
* If you have questions regarding the use of this file, please contact
25
* Inria at visp@inria.fr
26
*
27
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29
*
30
* Description:
31
* Acquisition of IMU data with RealSense T265 sensor and librealsense2.
32
*/
33
40
41
#include <iostream>
42
43
#include <visp3/core/vpMeterPixelConversion.h>
44
#include <visp3/gui/vpDisplayX.h>
45
#include <visp3/sensor/vpRealSense2.h>
46
47
#if defined(VISP_HAVE_REALSENSE2) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) && \
48
(defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI)) && (RS2_API_VERSION > ((2 * 10000) + (31 * 100) + 0))
49
50
int
main()
51
{
52
#ifdef ENABLE_VISP_NAMESPACE
53
using namespace
VISP_NAMESPACE_NAME
;
54
#endif
55
vpColVector
imu_acc, imu_vel;
56
57
try
{
58
vpRealSense2
rs;
59
std::string product_line = rs.
getProductLine
();
60
std::cout <<
"Product line: "
<< product_line << std::endl;
61
62
if
(product_line !=
"T200"
) {
63
std::cout <<
"This example doesn't support devices that are not part of T200 product line family !"
<< std::endl;
64
return
EXIT_SUCCESS;
65
}
66
rs2::config
config
;
67
config
.enable_stream(RS2_STREAM_ACCEL);
68
config
.enable_stream(RS2_STREAM_GYRO);
69
rs.
open
(config);
70
71
while
(
true
) {
72
73
rs.
getIMUData
(&imu_acc, &imu_vel,
nullptr
);
74
75
std::cout <<
"Gyro vel: x = "
<< std::setw(12) << imu_vel[0] <<
" y = "
<< std::setw(12) << imu_vel[1]
76
<<
" z = "
<< std::setw(12) << imu_vel[2];
77
std::cout <<
" Accel: x = "
<< std::setw(12) << imu_acc[0] <<
" y = "
<< std::setw(12) << imu_acc[1]
78
<<
" z = "
<< std::setw(12) << imu_acc[2];
79
std::cout << std::endl;
80
}
81
}
82
catch
(
const
vpException
&e) {
83
std::cerr <<
"RealSense error "
<<
e
.what() << std::endl;
84
}
85
catch
(
const
std::exception &e) {
86
std::cerr <<
e
.what() << std::endl;
87
}
88
89
return
EXIT_SUCCESS;
90
}
91
#else
92
int
main()
93
{
94
#if !defined(VISP_HAVE_REALSENSE2)
95
std::cout <<
"You do not realsense2 SDK functionality enabled..."
<< std::endl;
96
std::cout <<
"Tip:"
<< std::endl;
97
std::cout <<
"- Install librealsense2, configure again ViSP using cmake and build again this example"
<< std::endl;
98
return
EXIT_SUCCESS;
99
#elif !(defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI))
100
std::cout <<
"You don't have X11 or GDI display capabilities"
<< std::endl;
101
#elif !(RS2_API_VERSION > ((2 * 10000) + (31 * 100) + 0))
102
std::cout <<
"Install librealsense version > 2.31.0"
<< std::endl;
103
#endif
104
return
EXIT_SUCCESS;
105
}
106
#endif
vpColVector
Implementation of column vector and the associated operations.
Definition
vpColVector.h:191
vpException
error that can be emitted by ViSP classes.
Definition
vpException.h:60
vpRealSense2
Definition
vpRealSense2.h:310
vpRealSense2::open
bool open(const rs2::config &cfg=rs2::config())
Definition
vpRealSense2.cpp:1362
vpRealSense2::getProductLine
std::string getProductLine()
Definition
vpRealSense2.cpp:1426
vpRealSense2::getIMUData
void getIMUData(vpColVector *imu_vel, vpColVector *imu_acc, double *ts)
Definition
vpRealSense2.cpp:1330
VISP_NAMESPACE_NAME
Definition
vpEigenConversion.h:44
gen_java.config
config
Definition
gen_java.py:18
ibvs-four-points.e
e
Definition
ibvs-four-points.py:272
modules
sensor
test
rgb-depth
testRealSense2_T265_imu.cpp
Generated by
1.17.0