Skip to content

Commit 879a937

Browse files
authored
[master] Windows bring-up (#1704)
* Windows bringup. * nullity check. * nullity check.
1 parent 433c6ac commit 879a937

File tree

40 files changed

+206
-43
lines changed

40 files changed

+206
-43
lines changed

‎nav2_amcl/CMakeLists.txt‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ include_directories(
2222
include
2323
)
2424

25+
include(CheckSymbolExists)
26+
check_symbol_exists(drand48 stdlib.h HAVE_DRAND48)
27+
2528
add_subdirectory(src/pf)
2629
add_subdirectory(src/map)
2730
add_subdirectory(src/motion_model)
@@ -39,6 +42,11 @@ add_library(${library_name} SHARED
3942
src/amcl_node.cpp
4043
)
4144

45+
target_include_directories(${library_name} PRIVATE src/include)
46+
if(HAVE_DRAND48)
47+
target_compile_definitions(${library_name} PRIVATE "HAVE_DRAND48")
48+
endif()
49+
4250
set(dependencies
4351
rclcpp
4452
rclcpp_lifecycle
@@ -70,9 +78,13 @@ target_link_libraries(${library_name}
7078
map_lib motions_lib sensors_lib
7179
)
7280

73-
install(TARGETS ${executable_name} ${library_name}
81+
install(TARGETS ${library_name}
7482
ARCHIVE DESTINATION lib
7583
LIBRARY DESTINATION lib
84+
RUNTIME DESTINATION bin
85+
)
86+
87+
install(TARGETS ${executable_name}
7688
RUNTIME DESTINATION lib/${PROJECT_NAME}
7789
)
7890

‎nav2_amcl/src/amcl_node.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
#include "tf2/utils.h"
4949
#pragma GCC diagnostic pop
5050

51+
#include "portable_utils.h"
52+
5153
using namespace std::placeholders;
5254
using namespace std::chrono_literals;
5355

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#ifndef PORTABLE_UTILS_H
2+
#define PORTABLE_UTILS_H
3+
4+
#include <stdlib.h>
5+
6+
#ifdef __cplusplus
7+
extern "C" {
8+
#endif
9+
10+
#ifndef HAVE_DRAND48
11+
// Some system (e.g., Windows) doesn't come with drand48(), srand48().
12+
// Use rand, and srand for such system.
13+
static double drand48(void)
14+
{
15+
return ((double)rand()) / RAND_MAX;
16+
}
17+
18+
static void srand48(long int seedval)
19+
{
20+
srand(seedval);
21+
}
22+
#endif
23+
24+
#ifdef __cplusplus
25+
}
26+
#endif
27+
28+
#endif

‎nav2_amcl/src/map/CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ install(TARGETS
1010
map_lib
1111
ARCHIVE DESTINATION lib
1212
LIBRARY DESTINATION lib
13-
RUNTIME DESTINATION lib/${PROJECT_NAME}
13+
RUNTIME DESTINATION bin
1414
)

‎nav2_amcl/src/motion_model/CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ install(TARGETS
1212
motions_lib
1313
ARCHIVE DESTINATION lib
1414
LIBRARY DESTINATION lib
15-
RUNTIME DESTINATION lib/${PROJECT_NAME}
15+
RUNTIME DESTINATION bin
1616
)

‎nav2_amcl/src/pf/CMakeLists.txt‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@ add_library(pf_lib SHARED
1111
pf_draw.c
1212
)
1313

14+
target_include_directories(pf_lib PRIVATE ../include)
15+
if(HAVE_DRAND48)
16+
target_compile_definitions(pf_lib PRIVATE "HAVE_DRAND48")
17+
endif()
18+
1419
install(TARGETS
1520
pf_lib
1621
ARCHIVE DESTINATION lib
1722
LIBRARY DESTINATION lib
18-
RUNTIME DESTINATION lib/${PROJECT_NAME}
23+
RUNTIME DESTINATION bin
1924
)

‎nav2_amcl/src/pf/eig3.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77
#define MAX(a, b) ((a) > (b) ? (a) : (b))
88
#endif
99

10-
// #define n 3
11-
static const int n = 3;
10+
#ifdef _MSC_VER
11+
#define n 3
12+
#else
13+
static int n = 3;
14+
#endif
1215

1316
static double hypot2(double x, double y)
1417
{

‎nav2_amcl/src/pf/pf.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
#include "nav2_amcl/pf/pf_pdf.hpp"
3636
#include "nav2_amcl/pf/pf_kdtree.hpp"
3737

38+
#include "portable_utils.h"
39+
3840

3941
// Compute the required number of samples, given that there are k bins
4042
// with samples in them.

‎nav2_amcl/src/pf/pf_pdf.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434

3535
#include "nav2_amcl/pf/pf_pdf.hpp"
3636

37+
#include "portable_utils.h"
38+
3739
// Random number generator seed value
3840
static unsigned int pf_pdf_seed;
3941

‎nav2_amcl/src/pf/pf_vector.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ int pf_vector_finite(pf_vector_t a)
5353
int i;
5454

5555
for (i = 0; i < 3; i++) {
56-
if (!finite(a.v[i])) {
56+
if (!isfinite(a.v[i])) {
5757
return 0;
5858
}
5959
}
@@ -152,7 +152,7 @@ int pf_matrix_finite(pf_matrix_t a)
152152

153153
for (i = 0; i < 3; i++) {
154154
for (j = 0; j < 3; j++) {
155-
if (!finite(a.m[i][j])) {
155+
if (!isfinite(a.m[i][j])) {
156156
return 0;
157157
}
158158
}

0 commit comments

Comments
��(0)