33 for (
int i = 0;
i <= 8;
i++)
50 gluPerspective(60.0, 4.0 / 3.0, 1, 40);
56 gluLookAt(1, 0, 5, 1, 0, 0, 0, -1, 0);
95 for (
auto&
i : indexes)
120 bool firstGyro =
true;
121 bool firstAccel =
true;
123 double last_ts_gyro = 0;
138 gyro_angle.
x = gyro_data.
x;
139 gyro_angle.
y = gyro_data.
y;
140 gyro_angle.
z = gyro_data.
z;
143 double dt_gyro = (ts - last_ts_gyro) / 1000.0;
147 gyro_angle = gyro_angle *
static_cast<float>(dt_gyro);
150 std::lock_guard<std::mutex>
lock(theta_mtx);
151 theta.
add(-gyro_angle.
z, -gyro_angle.
y, gyro_angle.
x);
160 accel_angle.
z = atan2(accel_data.
y, accel_data.
z);
161 accel_angle.
x = atan2(accel_data.
x, sqrt(accel_data.
y * accel_data.
y + accel_data.
z * accel_data.
z));
164 std::lock_guard<std::mutex>
lock(theta_mtx);
180 theta.
x = theta.
x * alpha + accel_angle.
x * (1 -
alpha);
181 theta.
z = theta.
z * alpha + accel_angle.
z * (1 -
alpha);
188 std::lock_guard<std::mutex>
lock(theta_mtx);
196 bool found_gyro =
false;
197 bool found_accel =
false;
215 if (found_gyro && found_accel)
218 return found_gyro && found_accel;
221 int main(
int argc,
char * argv[])
try 226 std::cerr <<
"Device supporting IMU not found";
231 window app(1280, 720,
"RealSense Motion Example");
263 rs2_vector gyro_data = motion.get_motion_data();
271 rs2_vector accel_data = motion.get_motion_data();
295 catch (
const std::exception& e)
static const textual_icon lock
std::vector< float3 > positions
device_list query_devices() const
int main(int argc, char *argv[])
void uncompress_d435_obj(std::vector< float3 > &vertex_data, std::vector< float3 > &normals, std::vector< short3 > &index_data)
std::vector< short3 > indexes
void add(float t1, float t2, float t3)
const std::string & get_failed_args() const
GLfloat GLfloat GLfloat alpha
#define GL_COLOR_BUFFER_BIT
double get_timestamp() const
void enable_stream(rs2_stream stream_type, int stream_index, int width, int height, rs2_format format=RS2_FORMAT_ANY, int framerate=0)
void render_camera(float3 theta)
3D vector in Euclidean coordinate space
void process_accel(rs2_vector accel_data)
static const textual_icon camera
void render_scene(glfw_state app_state)
void process_gyro(rs2_vector gyro_data, double ts)
void register_glfw_callbacks(window &app, glfw_state &app_state)
const std::string & get_failed_function() const
bool check_imu_is_supported()