Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ int main(int argc, char **argv) {
const struct SurviveSimplePoseUpdatedEvent *pose_event = survive_simple_get_pose_updated_event(&event);
SurvivePose pose = pose_event->pose;
FLT timecode = pose_event->time;
/*printf("%s %s (%7.3f): %f %f %f %f %f %f %f\n", survive_simple_object_name(pose_event->object),
printf("%s %s (%7.3f): %f %f %f %f %f %f %f\n", survive_simple_object_name(pose_event->object),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this not commented out?

survive_simple_serial_number(pose_event->object), timecode, pose.Pos[0], pose.Pos[1], pose.Pos[2],
pose.Rot[0], pose.Rot[1], pose.Rot[2], pose.Rot[3]);*/
pose.Rot[0], pose.Rot[1], pose.Rot[2], pose.Rot[3]);
break;
}
case SurviveSimpleEventType_ButtonEvent: {
Expand Down
4 changes: 4 additions & 0 deletions libs/cnmatrix/include/cnmatrix/cn_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@

#include <stdbool.h>

#ifdef __APPLE__
#include <stdlib.h>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably include stdlib.h directly on all platforms rather than just malloc.h on everything else.

#else
#include <malloc.h>
#endif
#include "cnmatrix/cn_flt.h"
#include "math.h"
#include "string.h"
Expand Down
6 changes: 6 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ if(USE_HIDAPI)
add_definitions (-DHIDAPI)
IF(WIN32)
SET(SURVIVE_SRCS ${SURVIVE_SRCS} ../redist/hid-windows.c)
elseif(APPLE)
find_library(HIDAPI_LIBRARY hidapi PATHS /opt/homebrew/lib /usr/local/lib)
if(HIDAPI_LIBRARY)
list(APPEND ADDITIONAL_LIBRARIES ${HIDAPI_LIBRARY})
include_directories(/opt/homebrew/include /usr/local/include)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm that seems a bit too wide, there's no target available from CMake ?

endif()
else()
list(APPEND ADDITIONAL_LIBRARIES udev hidapi-libusb)
endif()
Expand Down
1 change: 1 addition & 0 deletions src/survive_kalman_lighthouses.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ void error_fn(void *user, const struct CnMat *x0, const struct CnMat *x1, struct
}
}
void survive_kalman_lighthouse_ootx(SurviveKalmanLighthouse *tracker) {
if (tracker == NULL) return;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it often NULL ?

tracker->state.BSD0 = tracker->ctx->bsd[tracker->lh].fcal[0];
tracker->state.BSD1 = tracker->ctx->bsd[tracker->lh].fcal[1];
}
Expand Down
22 changes: 20 additions & 2 deletions src/survive_plugins.unix.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,19 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#ifdef __APPLE__
#include <mach-o/dyld.h>
#endif

#include "assert.h"

#pragma GCC diagnostic ignored "-Wpedantic"

#ifdef __APPLE__
static const char* plugin_ext() { return ".dylib"; }
#else
static const char* plugin_ext() { return ".so"; }
#endif

#ifndef PATH_MAX
#define PATH_MAX 4096
Expand All @@ -37,8 +44,19 @@ static const char *get_so_filename() {
static const char *get_exe_filename() {
static char exe_path[PATH_MAX] = { 0 };
if (exe_path[0] == 0) {
size_t len = readlink("/proc/self/exe", exe_path, sizeof(exe_path));
exe_path[len] = 0;
#ifdef __APPLE__
uint32_t size = sizeof(exe_path);
if (_NSGetExecutablePath(exe_path, &size) != 0) {
exe_path[0] = 0;
}
#else
ssize_t len = readlink("/proc/self/exe", exe_path, sizeof(exe_path) - 1);
if (len > 0) {
exe_path[len] = 0;
} else {
exe_path[0] = 0;
}
#endif
}
return exe_path;
}
Expand Down