The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

d/rs: Rename 6dof to ddev

This commit introduces the term `ddev` for a "Device-SLAM tracked device",
it will be useful to differentiate itself from the `hdev`
("Host-SLAM tracked device") that will be introduced in next commits.

Note that "config_realsense" json field was renamed to "config_realsense_device"
and the device's serial (used for tracking overrides) changed from
"Intel RealSense 6-DOF" to "Intel RealSense Device-SLAM".

+53 -48
+2 -2
doc/example_configs/config_v0.northstar_lonestar.json
··· 5 5 "tracking_overrides": [ 6 6 { 7 7 "target_device_serial": "North Star", 8 - "tracker_device_serial": "Intel RealSense 6-DOF", 8 + "tracker_device_serial": "Intel RealSense Device-SLAM", 9 9 "type": "direct", 10 10 "offset": { 11 11 "orientation": { ··· 24 24 }, 25 25 { 26 26 "target_device_serial": "Leap Motion v2 driver", 27 - "tracker_device_serial": "Intel RealSense 6-DOF", 27 + "tracker_device_serial": "Intel RealSense Device-SLAM", 28 28 "type": "attached", 29 29 "offset": { 30 30 "orientation": {
+2 -1
src/xrt/drivers/CMakeLists.txt
··· 178 178 179 179 if(XRT_BUILD_DRIVER_RS) 180 180 set(RS_SOURCE_FILES 181 - realsense/rs_6dof.c 181 + realsense/rs_ddev.c 182 182 realsense/rs_prober.c 183 + realsense/rs_interface.h 183 184 ) 184 185 185 186 add_library(drv_rs STATIC ${RS_SOURCE_FILES})
+1 -1
src/xrt/drivers/meson.build
··· 142 142 lib_drv_rs = static_library( 143 143 'drv_rs', 144 144 files( 145 - 'realsense/rs_6dof.c', 145 + 'realsense/rs_ddev.c', 146 146 'realsense/rs_interface.h', 147 147 'realsense/rs_prober.c', 148 148 ),
+45 -41
src/xrt/drivers/realsense/rs_6dof.c src/xrt/drivers/realsense/rs_ddev.c
··· 3 3 // SPDX-License-Identifier: BSL-1.0 4 4 /*! 5 5 * @file 6 - * @brief RealSense helper driver for 6DOF tracking. 6 + * @brief RealSense helper driver for in-device SLAM 6DOF tracking. 7 7 * @author Moses Turner <mosesturner@protonmail.com> 8 8 * @author Nova King <technobaboo@gmail.com> 9 9 * @author Jakob Bornecrantz <jakob@collabora.com> ··· 15 15 #include "math/m_api.h" 16 16 #include "math/m_space.h" 17 17 #include "math/m_predict.h" 18 + #include "math/m_relation_history.h" 18 19 19 20 #include "os/os_time.h" 20 21 #include "os/os_threading.h" ··· 26 27 #include "util/u_json.h" 27 28 #include "util/u_config_json.h" 28 29 29 - #include "math/m_relation_history.h" 30 - 31 30 #include <librealsense2/rs.h> 32 31 #include <librealsense2/h/rs_pipeline.h> 33 32 #include <librealsense2/h/rs_option.h> ··· 47 46 pose.orientation.y, pose.orientation.z, pose.orientation.w) 48 47 49 48 /*! 49 + * Device-SLAM tracked RealSense device (T26X series). 50 + * 50 51 * @implements xrt_device 51 52 */ 52 - struct rs_6dof 53 + struct rs_ddev 53 54 { 54 55 struct xrt_device base; 55 56 ··· 61 62 bool enable_pose_jumping; 62 63 bool enable_relocalization; 63 64 bool enable_pose_prediction; 64 - bool enable_pose_filtering; // Forward compatibility for when that 1-euro filter is working 65 + bool enable_pose_filtering; //!< Forward compatibility for when that 1-euro filter is working 65 66 66 67 rs2_context *ctx; 67 68 rs2_pipeline *pipe; ··· 71 72 72 73 73 74 /*! 74 - * Helper to convert a xdev to a @ref rs_6dof. 75 + * Helper to convert a xdev to a @ref rs_ddev. 75 76 */ 76 - static inline struct rs_6dof * 77 - rs_6dof(struct xrt_device *xdev) 77 + static inline struct rs_ddev * 78 + rs_ddev(struct xrt_device *xdev) 78 79 { 79 - return (struct rs_6dof *)xdev; 80 + return (struct rs_ddev *)xdev; 80 81 } 81 82 82 83 /*! 83 84 * Simple helper to check and print error messages. 84 85 */ 85 86 static int 86 - check_error(struct rs_6dof *rs, rs2_error *e) 87 + check_error(struct rs_ddev *rs, rs2_error *e) 87 88 { 88 89 if (e == NULL) { 89 90 return 0; ··· 99 100 * Frees all RealSense resources. 100 101 */ 101 102 static void 102 - close_6dof(struct rs_6dof *rs) 103 + close_ddev(struct rs_ddev *rs) 103 104 { 104 105 if (rs->config) { 105 106 rs2_delete_config(rs->config); ··· 126 127 #define CHECK_RS2() \ 127 128 do { \ 128 129 if (check_error(rs, e) != 0) { \ 129 - close_6dof(rs); \ 130 + close_ddev(rs); \ 130 131 return 1; \ 131 132 } \ 132 133 } while (0) ··· 136 137 * Create all RealSense resources needed for 6DOF tracking. 137 138 */ 138 139 static int 139 - create_6dof(struct rs_6dof *rs) 140 + create_ddev(struct rs_ddev *rs) 140 141 { 141 142 assert(rs != NULL); 142 143 rs2_error *e = NULL; ··· 154 155 155 156 U_LOG_D("There are %d connected RealSense devices.", dev_count); 156 157 if (0 == dev_count) { 157 - close_6dof(rs); 158 + close_ddev(rs); 158 159 return 1; 159 160 } 160 161 ··· 183 184 rs2_sensor_list *sensors = rs2_query_sensors(cameras, &e); 184 185 CHECK_RS2(); 185 186 187 + //! @todo 0 index hardcoded, check device with RS2_EXTENSION_POSE_SENSOR or similar instead 186 188 rs2_sensor *sensor = rs2_create_sensor(sensors, 0, &e); 187 189 CHECK_RS2(); 188 190 ··· 190 192 CHECK_RS2(); 191 193 192 194 if (rs->enable_mapping) { 193 - // Neither of these options mean anything if mapping is off; in fact it errors out 194 - // if we mess with these 195 - // with mapping off 195 + // Neither of these options mean anything if mapping is off; in fact it 196 + // errors out if we mess with these with mapping off 196 197 rs2_set_option((rs2_options *)sensor, RS2_OPTION_ENABLE_RELOCALIZATION, 197 198 rs->enable_relocalization ? 1.0f : 0.0f, &e); 198 199 CHECK_RS2(); ··· 205 206 rs->profile = rs2_pipeline_start_with_config(rs->pipe, rs->config, &e); 206 207 CHECK_RS2(); 207 208 209 + rs2_delete_sensor(sensor); 210 + rs2_delete_sensor_list(sensors); 211 + 208 212 return 0; 209 213 } 210 214 ··· 212 216 * Process a frame as 6DOF data, does not assume ownership of the frame. 213 217 */ 214 218 static void 215 - process_frame(struct rs_6dof *rs, rs2_frame *frame) 219 + process_frame(struct rs_ddev *rs, rs2_frame *frame) 216 220 { 217 221 rs2_error *e = NULL; 218 222 int ret = 0; ··· 288 292 } 289 293 290 294 static int 291 - update(struct rs_6dof *rs) 295 + update(struct rs_ddev *rs) 292 296 { 293 297 rs2_frame *frames; 294 298 rs2_error *e = NULL; ··· 323 327 static void * 324 328 rs_run_thread(void *ptr) 325 329 { 326 - struct rs_6dof *rs = (struct rs_6dof *)ptr; 330 + struct rs_ddev *rs = (struct rs_ddev *)ptr; 327 331 328 332 os_thread_helper_lock(&rs->oth); 329 333 ··· 341 345 } 342 346 343 347 static bool 344 - load_config(struct rs_6dof *rs) 348 + load_config(struct rs_ddev *rs) 345 349 { 346 350 struct u_config_json config_json = {0}; 347 351 ··· 350 354 return false; 351 355 } 352 356 353 - const cJSON *realsense_config_json = u_json_get(config_json.root, "config_realsense"); 357 + const cJSON *realsense_config_json = u_json_get(config_json.root, "config_realsense_ddev"); 354 358 if (realsense_config_json == NULL) { 355 359 return false; 356 360 } ··· 391 395 */ 392 396 393 397 static void 394 - rs_6dof_update_inputs(struct xrt_device *xdev) 398 + rs_ddev_update_inputs(struct xrt_device *xdev) 395 399 { 396 400 // Empty 397 401 } 398 402 399 403 static void 400 - rs_6dof_get_tracked_pose(struct xrt_device *xdev, 404 + rs_ddev_get_tracked_pose(struct xrt_device *xdev, 401 405 enum xrt_input_name name, 402 406 uint64_t at_timestamp_ns, 403 407 struct xrt_space_relation *out_relation) 404 408 { 405 - struct rs_6dof *rs = rs_6dof(xdev); 409 + struct rs_ddev *rs = rs_ddev(xdev); 406 410 407 411 if (name != XRT_INPUT_GENERIC_TRACKER_POSE) { 408 412 U_LOG_E("unknown input name"); ··· 413 417 } 414 418 415 419 static void 416 - rs_6dof_get_view_pose(struct xrt_device *xdev, 420 + rs_ddev_get_view_pose(struct xrt_device *xdev, 417 421 const struct xrt_vec3 *eye_relation, 418 422 uint32_t view_index, 419 423 struct xrt_pose *out_pose) ··· 422 426 } 423 427 424 428 static void 425 - rs_6dof_destroy(struct xrt_device *xdev) 429 + rs_ddev_destroy(struct xrt_device *xdev) 426 430 { 427 - struct rs_6dof *rs = rs_6dof(xdev); 431 + struct rs_ddev *rs = rs_ddev(xdev); 428 432 429 433 // Destroy the thread object. 430 434 os_thread_helper_destroy(&rs->oth); 431 435 432 - close_6dof(rs); 436 + close_ddev(rs); 433 437 434 438 free(rs); 435 439 } ··· 442 446 */ 443 447 444 448 struct xrt_device * 445 - rs_6dof_create(void) 449 + rs_ddev_create(void) 446 450 { 447 - struct rs_6dof *rs = U_DEVICE_ALLOCATE(struct rs_6dof, U_DEVICE_ALLOC_TRACKING_NONE, 1, 0); 451 + struct rs_ddev *rs = U_DEVICE_ALLOCATE(struct rs_ddev, U_DEVICE_ALLOC_TRACKING_NONE, 1, 0); 448 452 449 453 m_relation_history_create(&rs->relation_hist); 450 454 ··· 462 466 463 467 U_LOG_D("Realsense opts are %i %i %i %i %i\n", rs->enable_mapping, rs->enable_pose_jumping, 464 468 rs->enable_relocalization, rs->enable_pose_prediction, rs->enable_pose_filtering); 465 - rs->base.update_inputs = rs_6dof_update_inputs; 466 - rs->base.get_tracked_pose = rs_6dof_get_tracked_pose; 467 - rs->base.get_view_pose = rs_6dof_get_view_pose; 468 - rs->base.destroy = rs_6dof_destroy; 469 + rs->base.update_inputs = rs_ddev_update_inputs; 470 + rs->base.get_tracked_pose = rs_ddev_get_tracked_pose; 471 + rs->base.get_view_pose = rs_ddev_get_view_pose; 472 + rs->base.destroy = rs_ddev_destroy; 469 473 rs->base.name = XRT_DEVICE_REALSENSE; 470 474 rs->base.tracking_origin->type = XRT_TRACKING_TYPE_EXTERNAL_SLAM; 471 475 472 476 // Print name. 473 - snprintf(rs->base.str, XRT_DEVICE_NAME_LEN, "Intel RealSense 6-DOF"); 474 - snprintf(rs->base.serial, XRT_DEVICE_NAME_LEN, "Intel RealSense 6-DOF"); 477 + snprintf(rs->base.str, XRT_DEVICE_NAME_LEN, "Intel RealSense Device-SLAM"); 478 + snprintf(rs->base.serial, XRT_DEVICE_NAME_LEN, "Intel RealSense Device-SLAM"); 475 479 476 480 rs->base.inputs[0].name = XRT_INPUT_GENERIC_TRACKER_POSE; 477 481 ··· 483 487 ret = os_thread_helper_init(&rs->oth); 484 488 if (ret != 0) { 485 489 U_LOG_E("Failed to init threading!"); 486 - rs_6dof_destroy(&rs->base); 490 + rs_ddev_destroy(&rs->base); 487 491 return NULL; 488 492 } 489 493 490 - ret = create_6dof(rs); 494 + ret = create_ddev(rs); 491 495 if (ret != 0) { 492 - rs_6dof_destroy(&rs->base); 496 + rs_ddev_destroy(&rs->base); 493 497 return NULL; 494 498 } 495 499 496 500 ret = os_thread_helper_start(&rs->oth, rs_run_thread, rs); 497 501 if (ret != 0) { 498 502 U_LOG_E("Failed to start thread!"); 499 - rs_6dof_destroy(&rs->base); 503 + rs_ddev_destroy(&rs->base); 500 504 return NULL; 501 505 } 502 506
+2 -2
src/xrt/drivers/realsense/rs_interface.h
··· 22 22 */ 23 23 24 24 /*! 25 - * Create a RelaseSense 6DOF tracker device. 25 + * Create a RealSense device tracked with device-SLAM (T26x). 26 26 * 27 27 * @ingroup drv_rs 28 28 */ 29 29 struct xrt_device * 30 - rs_6dof_create(void); 30 + rs_ddev_create(void); 31 31 32 32 /*! 33 33 * Create a auto prober for rs devices.
+1 -1
src/xrt/drivers/realsense/rs_prober.c
··· 53 53 struct rs_prober *dp = rs_prober(xap); 54 54 (void)dp; 55 55 56 - struct xrt_device *dev = rs_6dof_create(); 56 + struct xrt_device *dev = rs_ddev_create(); 57 57 if (!dev) { 58 58 return 0; 59 59 }