Skip to content

Commit

Permalink
Handle sample_app __master and __ip arguments with preprocessor defin…
Browse files Browse the repository at this point in the history
…itions

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 <[email protected]>
  • Loading branch information
nuclearmistake committed Sep 29, 2015
1 parent e9b9663 commit 00ea47f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
9 changes: 9 additions & 0 deletions files/sample_app/jni/Android.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?= 192.168.1.100 # 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)
Expand Down
10 changes: 8 additions & 2 deletions files/sample_app/jni/src/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 00ea47f

Please sign in to comment.