## page was renamed from rosjava_build_tools/Tutorials/indigo/RosJava Message Artifacts ## For instruction on writing tutorials ## http://www.ros.org/wiki/WritingTutorials #################################### ##FILL ME IN #################################### ## for a custom note with links: ## note = ## for the canned note of "This tutorial assumes that you have completed the previous tutorials:" just add the links ## note.0=[[rosjava_build_tools/Tutorials/indigo/Creating Rosjava Packages|Creating Rosjava Packages]] ## note.1=[[rosjava_build_tools/Tutorials/indigo/WritingPublisherSubscriber(Java)|Writing a Publisher and Subscriber]] ## note.2=[[rosjava_build_tools/Tutorials/indigo/Building RosJava Libraries|Building RosJava Libraries]] ## descriptive title for the tutorial ## title = Generating RosJava Message Artifacts (Catkin Style) ## multi-line description to be displayed in search ## description = Generating ros-java message jars and artifacts ## the next tutorial description (optional) ## next = ## links to next tutorial (optional) ## next.0.link=[[rosjava/Tutorials/indigo/Surviving RosJava Workspaces|Surviving RosJava Workspaces]] ## next.1.link= ## what level user is this tutorial for ## level= BeginnerCategory ## keywords = rosjava #################################### <> ||Rosjava message creation has gone a semi-overhaul since hydro (some history [[rosjava/Messages|here]]). We now support several convenience methods for generating artifacts as well as one which takes a step closer to being an official message generator. || <
> <> == About == Many of the awkward tricks from hydro are now no longer necessary and the biggest step forward is an implicit message generator that embeds inside the ros message generating infrastructure. So if you have a message package, and genjava installed, it will now magically generate the required java artifacts. The only drawback right now is that this is not an official generator, so they are not available to you when downloading the corresponding msg deb. This is being worked on, but right now the message generation is just too slow (compare with python and c++ where no compile step is needed). This is not a huge drawback though - we will endeavour to host pre-built artifacts on the rosjava maven repository for as many 'official' message types as possible as well as provide a script that will let you generate them locally from what is already installed. == Prerequisites == You will need `genjava`, either from source: {{{ > wstool set genjava --git https://github.com/rosjava/genjava --version=indigo }}} or from debs: {{{ > sudo apt-get install ros-indigo-genjava }}} == Usage == There are three ways you can ensure your message artifacts are created: * Command Line : generate for all installed messages in your local environment, in one shot. * Genjava : generate from your source workspaces via genjava and message_generation. * Meta Msg Pkgs : does message generation for a strict subset of packages. ||Type ||Pros ||Cons || ||Command Line ||Easy ||Manual, have to do every time you build your env. || ||Genjava ||Close to official style ||Have to have every msg dependency in maven or the source workspace. || ||Meta Msg Pkgs ||Structured ||Integrates with rosdep and can go on the build farm (debs). || === Command Line === The following commands build artifacts in the current directory under a `build` subfolder (use -o to change) and puts them in your current workspace's `devel/share/maven` folder. 1) Build all message artifacts discoverable in your current source workspace or its underlays: {{{ # Make sure you have the latest message packages installed > sudo apt-get install --only-upgrade ros-indigo-* # Build them all! > genjava_message_artifacts --verbose }}} 2) Build a specific message artifact along with all its dependencies: {{{ > genjava_message_artifacts --verbose -p std_msgs }}} 3) Build a specific set of message artifacts along with their dependencies: {{{ > genjava_message_artifacts --verbose -p std_msgs geometry_msgs }}} === Genjava === Simply make sure `genjava` has been installed and then it will automatically generate artifacts for any source message package it finds alongside python/c++ interfaces. These artifacts will be deployed in your `devel/share/maven/org/rosjava/messages` folder. ||'''Warning''' : A big constraint right now is that genjava is not yet official. This means deb installed packages wont have message artifacts lying around - these will have to either come from versions in your source workspace, or various pre-built message artifacts that have been uploaded to the [[https://github.com/rosjava/rosjava_mvn_repo/tree/master/org/ros/rosjava_messages|rosjava maven repo]]. || <
> ||'''Tip''' : If you want to build message artifacts for newer versions of message packages or your own non-deb message packages, just install genjava and drop those message package in your source workspace. Message artifacts will get created on the fly. || <
> ||'''Tip''' : To avoid having genjava run in your non-java source workspaces, use the [[http://wiki.ros.org/ROS/EnvironmentVariables#ROS_LANG_DISABLE|ROS_LANG_DISABLE]] environment variable. || <
> === Meta Msg Pkgs === It's nice to be able to structure your packages so that everything can be installed via a wstool rosinstall, and a rosdep install command. That is, you'd like your java message artifacts available as a deb. Neither of the above methods facilitate this, so this method is a stopgap to make that happen until the message generator is considered official. An example of this kind is the [[https://github.com/rosjava/rosjava_messages/tree/indigo|rosjava_messages]] package. This is a strictly zero-code catkin package that depends on genjava and whatever message packages you choose and includes a cmake instruction to generate artifacts for those dependencies. {{{ > mkdir -p ~/rosjava_messages > wstool init -j4 ~/rosjava_messages/src https://raw.githubusercontent.com/rosjava/rosjava/indigo/rosjava_messages.rosinstall > source /opt/ros/indigo/setup.bash > cd ~/rosjava_messages # Make sure we've got all rosdeps and the latest msg packages. > rosdep update > rosdep install --from-paths src -i -y > sudo apt-get install --only-upgrade ros-indigo-* > catkin_make }}} The `package.xml` dependencies: {{{ catkin rosjava_build_tools genjava python-rosdistro roslib std_msgs ros_comm_msgs # ros/ros_comm_msgs rosjava_test_msgs # rosjava/rosjava_test_msgs actionlib_msgs # ros/common_msgs diagnostic_msgs ... }}} And CMakeLists.txt excerpts: {{{ find_package(catkin REQUIRED genjava) generate_rosjava_messages( PACKAGES std_msgs ros_comm_msgs # ros/ros_comm_msgs rosjava_test_msgs # rosjava/rosjava_test_msgs actionlib_msgs # ros/common_msgs common_msgs diagnostic_msgs ... ) }}} On subsequent calls to catkin_make, this will not rebuild the artifacts. You can ensure a rebuild by cleaning the package: {{{ > catkin_make --pkg=rosjava_messages --make-args clean OR > cd build/rosjava_messages; make clean; cd ../.. # Rebuild > catkin_make }}} Since this has a full rosdep list of dependencies, you can now depend on this package when rosinstalling sources, or even get this package rolling on the build farm as an installable deb. It's also a nice easy way to generate a subset of artifacts ready for pushing them to maven. ||'''Tip''' : Use a workspace like this to generate artifacts for all the packages your require for your own custom development and use it as an underlay to all your other builds. || <
> ||'''Tip''' : Put this package on the ROS build farm to have a deb built! || <
> ||'''Warning''' : Since this is just an external call to artifact generation (not an officially integrated genjava as in method 2)) it is not particularly smart. That is, it won't rebuild when an underlying message file changes. You'll have to resort to manually cleaning and rebuilding in this case. || <
> ## AUTOGENERATED DO NOT DELETE ## TutorialCategory ## FILL IN THE STACK TUTORIAL CATEGORY HERE