Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace hardcoded __master and __ip arguments with makefile variables and preprocessor variables #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions files/move_base_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 ?= 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)"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing single quotes to retain the double quotes on the literal string:
LOCAL_CFLAGS := -DROS_MASTER_URI='"__master:=$(ROS_MASTER_URI)"' -DROS_ANDROID_IP='"__ip:=$(ROS_ANDROID_IP)"'
Please fix this and submit it again so it can be merged.


include $(BUILD_SHARED_LIBRARY)

$(call import-module,android/native_app_glue)
Expand Down
12 changes: 9 additions & 3 deletions files/move_base_app/jni/src/test_move_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
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 ?= 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)"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Single quotes needed here too.


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