-
Notifications
You must be signed in to change notification settings - Fork 5
Examples updated in catkin workspace #84
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
Conversation
|
This is the error output when building move_base_app: In file included from /opt/ros_android/example_workspace/src/move_base_app/jni/src/main/cpp/test_move_base.cpp:2: |
jubeira
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a quick review and overall it looks good.
The errors are probably because of the CMAKE_CXX_FLAGS we are using; we don't need to use -Wall -Werror for these examples.
I just left a few questions. Please save the apk files for later; I'd like to include them in a release.
|
|
||
| # Set the gradle targets you want catkin's make to run by default, e.g. | ||
| # catkin_rosjava_setup(installDist) | ||
| # catkin_android_setup(assembleDebug) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm don't we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it was commented out because move_base example had problems to build before.
Now it is corrected.
...le_workspace/src/image_transport_sample_app/jni/src/main/cpp/image_transport_plugin_test.cpp
Show resolved
Hide resolved
meyerj
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example look good and seem to be useful, but in my opinion requires some more tweaking:
-
Avoid using
$ENV{TARGET_DIR}in the innerCMakeLists.txtfiles. SettingCMAKE_FIND_ROOT_PATHonce viabuild.gradleshould be sufficient. -
Fix busy waiting (?) in some examples and use an
ros::AsyncSpinnerinstead? -
Lots or repetitive code, but there is nothing to do about it, I guess:
- I stopped copying or referencing comments at some points. Many comments also apply to similar cases in other packages.
- For plugin linking we could add a cmake helper to the patched
pluginlibpackage to avoid having to use the same tedious and error-prone cmake code in each package. - Fix copied package descriptions in
package.xmlfiles...
-
Nice-to-have: Replace the hard-coded
__ipand__masterstrings with a minimal settings UI or a configuration file.
|
|
||
| # Set the gradle targets you want catkin's make to run by default, e.g. | ||
| # catkin_rosjava_setup(installDist) | ||
| catkin_android_setup(assembleDebug) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #83 (comment).
| include_directories(${catkin_INCLUDE_DIRS}) | ||
|
|
||
| # build native_app_glue as a static lib | ||
| set(${CMAKE_C_FLAGS}, "${CMAKE_C_FLAGS}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #83 (comment).
| cmake { | ||
| arguments '-DANDROID_STL=c++_shared', | ||
| '-DCMAKE_FIND_ROOT_PATH=' + System.getenv('TARGET_DIR'), | ||
| '-DCMAKE_PREFIX_PATH=' + System.getenv('TARGET_DIR'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #83 (comment) and #83 (comment).
| <!-- One license tag required, multiple allowed, one license per tag --> | ||
| <!-- Commonly used license strings: --> | ||
| <!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 --> | ||
| <license>TODO</license> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a license?
| native_app_glue | ||
| log | ||
| ${WHOLE_ARCHIVE_LIBRARIES} | ||
| ${catkin_LIBRARIES} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Important to note that the exact order matters here: Because most libraries in ${catkin_LIBRARIES} are static and we do not know which other libraries ${WHOLE_ARCHIVE_LIBRARIES} depend on, the linker would not necessarily add the symbols required by one of the plugins while going over ${catkin_LIBRARIES} if it would be linked in before ${WHOLE_ARCHIVE_LIBRARIES}.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, here link order is important. Maybe another solutions is to patch all the plugins to export also the flags (-Wl,--whole-static library_name -Wl,--no-whole-archive) for android in catkin_package LIBRARIES option (I think this is possible with #68). Maybe is more difficult to maintain (I don't think it will be accepted upstream), but easier to use for the user.
@meyerj WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Patching plugin packages only works for the packages in the
catkin_ws, but is not a general solution for packages providing plugins in other workspace(s) listed in--extends-workspace. -
catkin_LIBRARIESdeduplicates libraries found in all packages and does not preserve the order of listed libraries: catkinConfig.cmake.in:97-102What might work is to add the string
"-Wl,--whole-static library_name -Wl,--no-whole-archive"tocatkin_LIBRARIES, with spaces and not as three separate list entries. Should check whethertarget_link_libraries(foo ${catkin_LIBRARIES})would accept this.
We were thinking about adding a CMake macro pluginlib_export_plugins() in a catkin CFG_EXTRAS script provided by pluginlib, or a separate package. The macro needs to be called before catkin_package() in packages providing plugins and generates another cmake script which appends to a list of plugins and sets another variable, e.g. pluginlib_EXPORTED_PLUGIN_LINKER_FLAGS, which then in turn is added to ${PROJECT_NAME}_CFG_EXTRAS again. Like that, each package can statically link to all plugins provided by all its dependencies by adding those flags to target_link_libraries(...), without being affected by catkin internals. It is similar to the mechanics of genmsg and friends.
On the downside, linking to all plugins with --whole-archive might blow up binary sizes.
Maybe it is not even necessary to patch packages that provide macros if the cmake script provided by pluginlib already parses package.xml and the exported plugin declarations and finds plugins on it own.
On the long term exporting plugins like this might even replace the pluginlib_helper in ros_android, because the same set of CMake scripts could also generate a source file with the descriptions of all listed plugins on the fly - similar to pluginlib_helper.cpp - and compile and link it to the target with a single pluginlib_link_plugins(target [plugin1 [plugin2 ...]) call that needs to be added by the user in the Android-specific CMakeLists.txt for his application.
|
|
||
| # Set the gradle targets you want catkin's make to run by default, e.g. | ||
| # catkin_rosjava_setup(installDist) | ||
| catkin_android_setup(assembleDebug) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #83 (comment).
| if (ros::ok()) { | ||
| ros::spinOnce(); | ||
| loop_rate.sleep(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't all native activities invoke ros::spinOnce() or launch an ros::AsyncSpinner?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably an AsyncSpinner is better because now sleeping with loop_rate.sleep() blocks Looper events from being processed.
| return; | ||
| } | ||
|
|
||
| if (ros::ok()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exit loop and terminate activity if ros::ok() == false?
| LOGD("APP DESTROYED BYE BYE"); | ||
| return; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No timeout and no ros::Rate. Busy-wait?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I will change for a locking looper version (ALooper_pollAll(-1, ...)), as nothing more is done.
| struct android_poll_source* source; | ||
|
|
||
| // Poll android events, without locking | ||
| while (ALooper_pollAll(0, NULL, &events, (void**)&source) >= 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Busy-wait?
Building ok and tested:
Building fine, not tested:
I think we can already merge this with #83 in kinetic.
Solves #78