Skip to content

Commit

Permalink
Include new windows files
Browse files Browse the repository at this point in the history
  • Loading branch information
JaciBrunning committed May 18, 2016
1 parent 443e8ef commit efc9bd1
Show file tree
Hide file tree
Showing 17 changed files with 93 additions and 51 deletions.
8 changes: 5 additions & 3 deletions Pathfinder-Core/include/pathfinder/fit.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#ifndef PATHFINDER_FIT_H_DEF
#define PATHFINDER_FIT_H_DEF

void pf_fit_hermite_pre(Waypoint a, Waypoint b, Spline *s);
void pf_fit_hermite_cubic(Waypoint a, Waypoint b, Spline *s);
void pf_fit_hermite_quintic(Waypoint a, Waypoint b, Spline *s);
#include "pathfinder/lib.h"

CAPI void pf_fit_hermite_pre(Waypoint a, Waypoint b, Spline *s);
CAPI void pf_fit_hermite_cubic(Waypoint a, Waypoint b, Spline *s);
CAPI void pf_fit_hermite_quintic(Waypoint a, Waypoint b, Spline *s);

#define FIT_HERMITE_CUBIC &pf_fit_hermite_cubic
#define FIT_HERMITE_QUINTIC &pf_fit_hermite_quintic
Expand Down
10 changes: 6 additions & 4 deletions Pathfinder-Core/include/pathfinder/followers/distance.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
#ifndef PATHFINDER_FOL_DISTANCE_H_DEF
#define PATHFINDER_FOL_DISTANCE_H_DEF

typedef struct {
#include "pathfinder/lib.h"

CAPI typedef struct {
double kp, ki, kd, kv, ka;
} FollowerConfig;

typedef struct {
CAPI typedef struct {
double last_error, heading, output;
int segment, finished;
} DistanceFollower;

double pathfinder_follow_distance(FollowerConfig c, DistanceFollower *follower, Segment *trajectory, int trajectory_length, double distance);
CAPI double pathfinder_follow_distance(FollowerConfig c, DistanceFollower *follower, Segment *trajectory, int trajectory_length, double distance);

double pathfinder_follow_distance2(FollowerConfig c, DistanceFollower *follower, Segment segment, int trajectory_length, double distance);
CAPI double pathfinder_follow_distance2(FollowerConfig c, DistanceFollower *follower, Segment segment, int trajectory_length, double distance);

#endif
25 changes: 13 additions & 12 deletions Pathfinder-Core/include/pathfinder/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "pathfinder/lib.h"

#define CSV_LEADING_STRING "dt,x,y,position,velocity,acceleration,jerk,heading\n"

void intToBytes(int n, char *bytes);
int bytesToInt(char *bytes);
void longToBytes(unsigned long long n, char *bytes);
unsigned long long bytesToLong(char *bytes);
double longToDouble(unsigned long long l);
unsigned long long doubleToLong(double d);
void doubleToBytes(double n, char *bytes);
double bytesToDouble(char *bytes);
CAPI void intToBytes(int n, char *bytes);
CAPI int bytesToInt(char *bytes);
CAPI void longToBytes(unsigned long long n, char *bytes);
CAPI unsigned long long bytesToLong(char *bytes);
CAPI double longToDouble(unsigned long long l);
CAPI unsigned long long doubleToLong(double d);
CAPI void doubleToBytes(double n, char *bytes);
CAPI double bytesToDouble(char *bytes);

void pathfinder_serialize(FILE *fp, Segment *trajectory, int trajectory_length);
int pathfinder_deserialize(FILE *fp, Segment *target);
CAPI void pathfinder_serialize(FILE *fp, Segment *trajectory, int trajectory_length);
CAPI int pathfinder_deserialize(FILE *fp, Segment *target);

void pathfinder_serialize_csv(FILE *fp, Segment *trajectory, int trajectory_length);
int pathfinder_deserialize_csv(FILE *fp, Segment *target);
CAPI void pathfinder_serialize_csv(FILE *fp, Segment *trajectory, int trajectory_length);
CAPI int pathfinder_deserialize_csv(FILE *fp, Segment *target);

#endif
10 changes: 10 additions & 0 deletions Pathfinder-Core/include/pathfinder/lib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef PATHFINDER_LIB_H_DEF
#define PATHFINDER_LIB_H_DEF

#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
#define CAPI __declspec(dllexport)
#else
#define CAPI
#endif

#endif
8 changes: 5 additions & 3 deletions Pathfinder-Core/include/pathfinder/mathutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
#ifndef PATHFINDER_MATH_UTIL_H_DEF
#define PATHFINDER_MATH_UTIL_H_DEF

#include "pathfinder/lib.h"

#define PI 3.14159265358979323846
#define TAU PI*2

#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))

double bound_radians(double angle);
CAPI double bound_radians(double angle);

double r2d(double angleInRads);
CAPI double r2d(double angleInRads);

double d2r(double angleInDegrees);
CAPI double d2r(double angleInDegrees);

#endif
6 changes: 4 additions & 2 deletions Pathfinder-Core/include/pathfinder/modifiers/swerve.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#ifndef PATHFINDER_MOD_SWERVE_H_DEF
#define PATHFINDER_MOD_SWERVE_H_DEF

typedef enum {
#include "pathfinder/lib.h"

CAPI typedef enum {
SWERVE_DEFAULT
} SWERVE_MODE;

void pathfinder_modify_swerve(Segment *original, int length, Segment *front_left, Segment *front_right,
CAPI void pathfinder_modify_swerve(Segment *original, int length, Segment *front_left, Segment *front_right,
Segment *back_left, Segment *back_right, double wheelbase_width, double wheelbase_depth, SWERVE_MODE mode);

#endif
4 changes: 3 additions & 1 deletion Pathfinder-Core/include/pathfinder/modifiers/tank.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef PATHFINDER_MOD_TANK_H_DEF
#define PATHFINDER_MOD_TANK_H_DEF

void pathfinder_modify_tank(Segment *original, int length, Segment *left, Segment *right, double wheelbase_width);
#include "pathfinder/lib.h"

CAPI void pathfinder_modify_tank(Segment *original, int length, Segment *left, Segment *right, double wheelbase_width);

#endif
14 changes: 8 additions & 6 deletions Pathfinder-Core/include/pathfinder/spline.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#ifndef PATHFINDER_SPLINE_H_DEF
#define PATHFINDER_SPLINE_H_DEF

#include "pathfinder/lib.h"

#define PATHFINDER_SAMPLES_FAST (int)1000
#define PATHFINDER_SAMPLES_LOW (int)PATHFINDER_SAMPLES_FAST*10
#define PATHFINDER_SAMPLES_HIGH (int)PATHFINDER_SAMPLES_LOW*10

Coord pf_spline_coords(Spline s, double percentage);
double pf_spline_deriv(Spline s, double percentage);
double pf_spline_deriv_2(double a, double b, double c, double d, double e, double k, double p);
double pf_spline_angle(Spline s, double percentage);
CAPI Coord pf_spline_coords(Spline s, double percentage);
CAPI double pf_spline_deriv(Spline s, double percentage);
CAPI double pf_spline_deriv_2(double a, double b, double c, double d, double e, double k, double p);
CAPI double pf_spline_angle(Spline s, double percentage);

double pf_spline_distance(Spline *s, int sample_count);
double pf_spline_progress_for_distance(Spline s, double distance, int sample_count);
CAPI double pf_spline_distance(Spline *s, int sample_count);
CAPI double pf_spline_progress_for_distance(Spline s, double distance, int sample_count);

#endif
16 changes: 9 additions & 7 deletions Pathfinder-Core/include/pathfinder/structs.h
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
#ifndef PATHFINDER_STRUCT_H_DEF
#define PATHFINDER_STRUCT_H_DEF

typedef struct {
#include "pathfinder/lib.h"

CAPI typedef struct {
double x, y, angle;
} Waypoint;

typedef struct {
CAPI typedef struct {
double a, b, c, d, e;
double x_offset, y_offset, angle_offset, knot_distance, arc_length;
} Spline;

typedef struct {
CAPI typedef struct {
double x, y;
} Coord;

typedef struct {
CAPI typedef struct {
double dt, x, y, position, velocity, acceleration, jerk, heading;
} Segment;

typedef struct {
CAPI typedef struct {
double dt, max_v, max_a, max_j, src_v, src_theta, dest_pos, dest_v, dest_theta;
int sample_count;
} TrajectoryConfig;

typedef struct {
CAPI typedef struct {
int filter1, filter2, length;
double dt, u, v, impulse;
} TrajectoryInfo;

typedef struct {
CAPI typedef struct {
Spline *saptr;
double *laptr;
double totalLength;
Expand Down
14 changes: 8 additions & 6 deletions Pathfinder-Core/include/pathfinder/trajectory.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#ifndef PATHFINDER_TRAJECTORY_H_DEF
#define PATHFINDER_TRAJECTORY_H_DEF

int pathfinder_prepare(Waypoint *path, int path_length, void (*fit)(Waypoint,Waypoint,Spline*), int sample_count, double dt,
#include "pathfinder/lib.h"

CAPI int pathfinder_prepare(Waypoint *path, int path_length, void (*fit)(Waypoint,Waypoint,Spline*), int sample_count, double dt,
double max_velocity, double max_acceleration, double max_jerk, TrajectoryCandidate *cand);
int pathfinder_generate(TrajectoryCandidate *c, Segment *segments);
CAPI int pathfinder_generate(TrajectoryCandidate *c, Segment *segments);

void pf_trajectory_copy(Segment *src, Segment *dest, int length);
CAPI void pf_trajectory_copy(Segment *src, Segment *dest, int length);

TrajectoryInfo pf_trajectory_prepare(TrajectoryConfig c);
int pf_trajectory_create(TrajectoryInfo info, TrajectoryConfig c, Segment *seg);
int pf_trajectory_fromSecondOrderFilter(int filter_1_l, int filter_2_l,
CAPI TrajectoryInfo pf_trajectory_prepare(TrajectoryConfig c);
CAPI int pf_trajectory_create(TrajectoryInfo info, TrajectoryConfig c, Segment *seg);
CAPI int pf_trajectory_fromSecondOrderFilter(int filter_1_l, int filter_2_l,
double dt, double u, double v, double impulse, int len, Segment *t);

#endif
25 changes: 18 additions & 7 deletions Pathfinder-Java/jni.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,24 @@ model {
dependsOn jniHeaders
def javahome = org.gradle.internal.jvm.Jvm.current().javaHome

cCompiler.args '-I', "${javahome}/include"
if (targetPlatform.operatingSystem.windows)
cCompiler.args '-I', "${javahome}/include/win32"
else if (targetPlatform.operatingSystem.macOsX)
cCompiler.args '-I', "${javahome}/include/darwin"
else if (targetPlatform.operatingSystem.linux)
cCompiler.args '-I', "${javahome}/include/linux"
if (toolChain in VisualCpp) {
cCompiler.args "-I${javahome}/include"
if (targetPlatform.operatingSystem.windows)
cCompiler.args "-I${javahome}/include/win32"
else if (targetPlatform.operatingSystem.macOsX)
cCompiler.args "-I${javahome}/include/darwin"
else if (targetPlatform.operatingSystem.linux)
cCompiler.args "-I${javahome}/include/linux"
} else {
cCompiler.args '-I', "${javahome}/include"
if (targetPlatform.operatingSystem.windows)
cCompiler.args '-I', "${javahome}/include/win32"
else if (targetPlatform.operatingSystem.macOsX)
cCompiler.args '-I', "${javahome}/include/darwin"
else if (targetPlatform.operatingSystem.linux)
cCompiler.args '-I', "${javahome}/include/linux"
}

// cCompiler.args << '-L"' + javahome + '/lib"'

if (isArm) {
Expand Down
Binary file modified Pathfinder-Java/src/main/resources/Linux/arm/libpathfinderjava.so
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Pathfinder-Java/src/main/resources/Win/x86/pathfinderjava.dll
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions native.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ subprojects {
}

toolChains {
visualCpp(VisualCpp) {

}

gcc(Gcc) {
target("arm") {
cCompiler.executable = compilerPrefix + cCompiler.executable
Expand Down

0 comments on commit efc9bd1

Please sign in to comment.