Open throni3git opened 2 months ago
i found that the GlobalSceneSolver had old data (i called it garbage SurviveObject instances in the original post). As a solution, is implemted a refreshing of the cache in src/driver_global_scene_solver.c
in the function add_scenes
. I modified it like this:
static size_t add_scenes(struct global_scene_solver *gss, SurviveObject *so) {
size_t rtn = 0;
SurviveContext *ctx = so->ctx;
survive_long_timecode sensor_time_window = SurviveSensorActivations_stationary_time(&so->activations) / 2;
SurviveSensorActivations *activations = &so->activations;
// begin of insertion
unsigned int free_idx = 0;
for (int i = 0; i < GSS_NUM_STORED_SCENES; i++) {
if (gss->scenes[i].so == NULL) {
continue;
}
bool is_still_valid = false;
if (gss->scenes[i].so == so) {
is_still_valid = true;
}
for (int j = 0; j < ctx->objs_ct; j++) {
if (gss->scenes[i].so == ctx->objs[j]) {
is_still_valid = true;
}
}
if (is_still_valid) {
gss->scenes[free_idx].so = gss->scenes[i].so;
free_idx++;
} else {
// printf("in GLobalSceneSolver: deleted scene %d with SurviveObject at adress &%p", i, (void* )so);
}
}
gss->scenes_cnt = free_idx;
// end of insertion
struct PoserDataGlobalScene *scene = &gss->scenes[gss->scenes_cnt % GSS_NUM_STORED_SCENES];
I am not sure if this is the correct place to do this, but it helped.
Describe the bug I am trying to find a way to reestablish a communication from a Vive Controller (or Vive Tracker) after it was turned off and on again. In the current state of libsurvive with libusb, the according
SurviveObject
is not reopened for communication again.My approach My investigation led me to
driver_vive.libusb.h
to functionhandle_transfer
. There is a flag calledrequest_reopen
which is evaluated indriver_vive.c::survive_handle_close_request_flag
. This flag will not be set in my case of a Vive Controller connected over a Watchman Dongle, since in the functionhandle_transfer
,iface->consecutive_timeouts
will never be increased more than once for wireless connections. It will be increased often when i connect the Controller via cable - this is why @jdavidberger eventually came up with a threshold of 3 consecutive_timeouts to set therequest_reopen
flag (commit d939c24f4ea43aa82366ca55e35ce064f7450c17). My approach is to modify this section indriver_vive.libusb.h::handle_transfer
like the following:Now this seems to work for me although i am sure the issue is related to some different part of the software. Then i came across a different issue: The
SurviveObject
is destroyed in this case and after reopening the device and creating a newSurviveObject
, some seconds laterdriver_global_scene_solver.c
needs torun_optimization
. Later in the chain,survive_create_device
is run with garbageSurviveObject
instances. I assume that this is a synchronisation issue between the threads.Data
Hardware setup
Desktop (please complete the following information):