From 509098e8e3cf52a6e0876400d9cb75bb73f3d2d3 Mon Sep 17 00:00:00 2001 From: nuclearmistake Date: Tue, 29 Sep 2015 16:23:28 -0400 Subject: [PATCH 1/2] Handle sample_app __master and __ip arguments with preprocessor definitions this allows the ROS_MASTER_URI to be inferred from the compiling computer's env. this commit also bumps a TODO to stop hardcoding up to actual runtime configurability. Signed-off-by: Eric McCann --- files/sample_app/jni/Android.mk.in | 9 +++++++++ files/sample_app/jni/src/test.cpp | 10 ++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/files/sample_app/jni/Android.mk.in b/files/sample_app/jni/Android.mk.in index b6f7ac9..b99c4c9 100644 --- a/files/sample_app/jni/Android.mk.in +++ b/files/sample_app/jni/Android.mk.in @@ -8,6 +8,15 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_LDLIBS := -landroid LOCAL_STATIC_LIBRARIES := android_native_app_glue roscpp_android_ndk +### Please customize these values appropriately for your ROS ecosystem + +ROS_MASTER_URI ?= http://192.168.1.100:11311 # defaults to environment variable if defined +ROS_ANDROID_IP := 192.168.1.101 # MUST be device IP + +### End customization region + +LOCAL_CFLAGS := -DROS_MASTER_URI="__master:=$(ROS_MASTER_URI)" -DROS_ANDROID_IP="__ip:=$(ROS_ANDROID_IP)" + include $(BUILD_SHARED_LIBRARY) $(call import-module,android/native_app_glue) diff --git a/files/sample_app/jni/src/test.cpp b/files/sample_app/jni/src/test.cpp index 0431bf6..3c5397a 100644 --- a/files/sample_app/jni/src/test.cpp +++ b/files/sample_app/jni/src/test.cpp @@ -61,9 +61,15 @@ void android_main(android_app *papp) { app_dummy(); int argc = 3; - // TODO: don't hardcode ip addresses + // TODO: handle the master uri and device IP at runtime +#ifndef ROS_MASTER_URI +#error ROS_MASTER_URI MUST be set in files/sample_app/jni/Android.mk.in +#endif +#ifndef ROS_ANDROID_IP +#error ROS_ANDROID_IP MUST be set in files/sample_app/jni/Android.mk.in +#endif // %Tag(CONF_ARGS)% - char *argv[] = {"nothing_important" , "__master:=http://192.168.1.100:11311", "__ip:=192.168.1.101"}; + char *argv[] = {"nothing_important" , ROS_MASTER_URI, ROS_ANDROID_IP}; // %EndTag(CONF_ARGS)% //strcpy(argv[0], 'nothing_important'); //argv[1] = '__master:=http://10.52.90.103:11311'; From 7a0f624409938a9951d668ac3c5f68e1668c23cb Mon Sep 17 00:00:00 2001 From: Eric McCann Date: Tue, 29 Sep 2015 16:31:16 -0400 Subject: [PATCH 2/2] Handle move_base_app __master and __ip arguments with preprocessor definitions this allows the ROS_MASTER_URI to be inferred from the compiling computer's env. this commit also bumps a TODO to stop hardcoding up to actual runtime configurability. Signed-off-by: Eric McCann --- files/move_base_app/jni/Android.mk.in | 9 +++++++++ files/move_base_app/jni/src/test_move_base.cpp | 12 +++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/files/move_base_app/jni/Android.mk.in b/files/move_base_app/jni/Android.mk.in index 780e4e3..ed5ba76 100644 --- a/files/move_base_app/jni/Android.mk.in +++ b/files/move_base_app/jni/Android.mk.in @@ -8,6 +8,15 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_LDLIBS := -landroid LOCAL_STATIC_LIBRARIES := android_native_app_glue roscpp_android_ndk +### Please customize these values appropriately for your ROS ecosystem + +ROS_MASTER_URI ?= http://192.168.1.100:11311 # defaults to environment variable if defined +ROS_ANDROID_IP := 192.168.1.101 # MUST be device IP + +### End customization region + +LOCAL_CFLAGS := -DROS_MASTER_URI="__master:=$(ROS_MASTER_URI)" -DROS_ANDROID_IP="__ip:=$(ROS_ANDROID_IP)" + include $(BUILD_SHARED_LIBRARY) $(call import-module,android/native_app_glue) diff --git a/files/move_base_app/jni/src/test_move_base.cpp b/files/move_base_app/jni/src/test_move_base.cpp index 4ff67ac..40a08a5 100644 --- a/files/move_base_app/jni/src/test_move_base.cpp +++ b/files/move_base_app/jni/src/test_move_base.cpp @@ -16,9 +16,15 @@ void android_main(android_app *papp) { app_dummy(); int argc = 4; - // TODO: don't hardcode ip addresses - char *argv[] = {"nothing_important" , "__master:=http://192.168.1.100:11311", - "__ip:=192.168.1.101", "cmd_vel:=navigation_velocity_smoother/raw_cmd_vel"}; + + // TODO: handle the master uri and device IP at runtime +#ifndef ROS_MASTER_URI +#error ROS_MASTER_URI MUST be set in files/move_base_app/jni/Android.mk.in +#endif +#ifndef ROS_ANDROID_IP +#error ROS_ANDROID_IP MUST be set in files/move_base_app/jni/Android.mk.in +#endif + char *argv[] = {"nothing_important" , ROS_MASTER_URI, ROS_ANDROID_IP, "cmd_vel:=navigation_velocity_smoother/raw_cmd_vel"}; for(int i = 0; i < argc; i++){ log(argv[i]);