Skip to content

Commit

Permalink
Merge pull request #849 from seanyen/amcl_windows_fix
Browse files Browse the repository at this point in the history
[Windows][melodic] AMCL Windows build bring up.
  • Loading branch information
mikeferguson committed Apr 28, 2019
2 parents b52e0ea + 54e770f commit 970eefe
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 7 deletions.
22 changes: 18 additions & 4 deletions amcl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ catkin_package(

include_directories(include)
include_directories(${catkin_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
include_directories(src/include)

check_include_file(unistd.h HAVE_UNISTD_H)
if (HAVE_UNISTD_H)
add_definitions(-DHAVE_UNISTD_H)
endif (HAVE_UNISTD_H)

check_symbol_exists(drand48 stdlib.h HAVE_DRAND48)
if (HAVE_DRAND48)
add_definitions(-DHAVE_DRAND48)
endif (HAVE_DRAND48)

add_library(amcl_pf
src/amcl/pf/pf.c
Expand Down Expand Up @@ -82,10 +93,13 @@ target_link_libraries(amcl
)

install( TARGETS
amcl amcl_sensors amcl_map amcl_pf
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
amcl
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

install( TARGETS
amcl_sensors amcl_map amcl_pf
DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
)

install(DIRECTORY include/amcl/
Expand Down
5 changes: 4 additions & 1 deletion amcl/src/amcl/pf/eig3.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
#define MAX(a, b) ((a)>(b)?(a):(b))
#endif

//#define n 3
#ifdef _MSC_VER
#define n 3
#else
static int n = 3;
#endif

static double hypot2(double x, double y) {
return sqrt(x*x+y*y);
Expand Down
1 change: 1 addition & 0 deletions amcl/src/amcl/pf/pf.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "amcl/pf/pf.h"
#include "amcl/pf/pf_pdf.h"
#include "amcl/pf/pf_kdtree.h"
#include "portable_utils.hpp"


// Compute the required number of samples, given that there are k bins
Expand Down
1 change: 1 addition & 0 deletions amcl/src/amcl/pf/pf_pdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
//#include <gsl/gsl_randist.h>

#include "amcl/pf/pf_pdf.h"
#include "portable_utils.hpp"

// Random number generator seed value
static unsigned int pf_pdf_seed;
Expand Down
4 changes: 2 additions & 2 deletions amcl/src/amcl/pf/pf_vector.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int pf_vector_finite(pf_vector_t a)
int i;

for (i = 0; i < 3; i++)
if (!finite(a.v[i]))
if (!isfinite(a.v[i]))
return 0;

return 1;
Expand Down Expand Up @@ -151,7 +151,7 @@ int pf_matrix_finite(pf_matrix_t a)

for (i = 0; i < 3; i++)
for (j = 0; j < 3; j++)
if (!finite(a.m[i][j]))
if (!isfinite(a.m[i][j]))
return 0;

return 1;
Expand Down
2 changes: 2 additions & 0 deletions amcl/src/amcl/sensors/amcl_laser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
#include <math.h>
#include <stdlib.h>
#include <assert.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

#include "amcl/sensors/amcl_laser.h"

Expand Down
1 change: 1 addition & 0 deletions amcl/src/amcl_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "amcl/pf/pf.h"
#include "amcl/sensors/amcl_odom.h"
#include "amcl/sensors/amcl_laser.h"
#include "portable_utils.hpp"

#include "ros/assert.h"

Expand Down
28 changes: 28 additions & 0 deletions amcl/src/include/portable_utils.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef PORTABLE_UTILS_H
#define PORTABLE_UTILS_H

#include <stdlib.h>

#ifdef __cplusplus
extern "C" {
#endif

#ifndef HAVE_DRAND48
// Some system (e.g., Windows) doesn't come with drand48(), srand48().
// Use rand, and srand for such system.
static double drand48(void)
{
return ((double)rand())/RAND_MAX;
}

static void srand48(long int seedval)
{
srand(seedval);
}
#endif

#ifdef __cplusplus
}
#endif

#endif

0 comments on commit 970eefe

Please sign in to comment.