Skip to content
This repository has been archived by the owner on Jan 14, 2023. It is now read-only.

generate java code for actions in same source workspace #71

Closed
fmessmer opened this issue Sep 1, 2018 · 8 comments
Closed

generate java code for actions in same source workspace #71

fmessmer opened this issue Sep 1, 2018 · 8 comments

Comments

@fmessmer
Copy link

fmessmer commented Sep 1, 2018

I'm very happy to see the PRs provided by @exo-core wrt. code generation for action files...
we've recently been hacking around this, too, without finding a satisfying solution

the current kinetic branch works with actions which are already released (although, I think this is because the msg files generated for each action can be found in the msg folder within the respective pkg under /opt/ros - thus the java classes get generated by the same MessageGeneration doing the topic msg files)

still, I'm having trouble generating code for actions which are defined in packages which are located in the same source workspace as rosjava_bootstrap, genjava & co

we also need this to work for our CI (travis)...using ros-industrial/industrial_ci where everything is compiled in a single workspace (in which src is read-only)
I'm still playing around with it a bit more and try to provide a rosinstall file to reproduce my usecase.

@exo-core @jubeira
what is your experience? have you used it this way?

@exo-core
Copy link
Contributor

exo-core commented Sep 1, 2018

Hi @fmessmer ,

I sometimes had issuies because the generated *.jar files were empty for some packages when building them with catkin_make, but I never really looked much into it... I was also playing around with quite some VM's and older ROS versions because I was trying to compile a version of my messages that I could use on our KUKA Sunrise Cabinet (Windows + Java 1.6 😒), so I'm not sure in what environment I experienced that error...

However I can tell that message generation works fine in kinetic when building them with
genjava_message_artifacts --verbose or genjava_message_artifacts --verbose -p <PACKAGE_NAME> as suggested in this tutorial.

I'll take a closer look at this when I'm back in the office on Monday...

@fmessmer
Copy link
Author

fmessmer commented Sep 1, 2018

Thanks for your reply @exo-core
So, you are saying that the build is not 100% reliable? - could be some dependency/race condition...

I've prepared a small demo repo that we could use for discussion:
https://github.com/fmessmer/helloworld_rosjava_messages

Some details about my setup:

  • uname -v: # 36~16.04.1-Ubuntu SMP Wed Aug 15 17:21:05 UTC 2018
  • ROS Kinetic (I don't have anything installed related to rosjava, i.e. apt purge ros-kinetic-rosjava*)
  • I'm using python-catkin-tools, i.e. catkin build instead of catkin_make

What I'm trying to do:

  • generate Maven artifacts (*.jar files) to be used in my rosjava project implementing ActionServers, i.e. the message artifacts will be added as dependencies in my project's pom.xml`)
  • the Maven artifacts need to be installed to my local Maven repository in ~/.m2
  • I must not generate code in source space (this is enforced by industrial_ci)
    👉 to achieved this, I will use a modified branch of rosjava_build_tools

@fmessmer
Copy link
Author

fmessmer commented Sep 1, 2018

Experimenting some more:
(to reproduce set up a workspace based on the .travis.rosinstall file included in https://github.com/fmessmer/helloworld_rosjava_messages)

Test1: https://github.com/fmessmer/helloworld_rosjava_messages/tree/a45530618642966b327a0e36608a7328a4023a51:
using catkin build, all java files (6 files per action) are nicely generated for HelloWorld.action (they can be found in build/helloworld_rosjava_messages/helloworld_msgs/src/main/java/helloworĺd_msgs)
also, the maven artifact can be redirected from devel/share/maven/org/ros/rosjava_messages/helloworld_msgs to ~/.m2/repository/org/ros/rosjava_messages/helloworld_msgs by setting export ROS_MAVEN_DEPLOYMENT_REPOSITORY=~/.m2/repository

Test2: fmessmer/helloworld_rosjava_messages@26a4b31
adding a sub_msgs package and using it within HelloWorldSub.action in fmessmer/helloworld_rosjava_messages@26a4b31, no java files (not even for HelloWorld.action - which worked in Test1) are generated for helloworld_msgs anymore, i.e. there is no src folder in build/helloworld_rosjava_messages/helloworld_msgs...
the java classes for sub_msgs are generated successfully

So it seems, it's not the messages/actions being located in the same workspace as rosjava_bootstrap etc. but the dependencies not being considered correctly (?)

@exo-core
Copy link
Contributor

exo-core commented Sep 3, 2018

Hi @fmessmer,

I've tried to reproduce your example. What I did:

  1. Created a new workspace called test_ws
  2. cd test_ws
  3. Ran rosinstall src https://raw.githubusercontent.com/fmessmer/helloworld_rosjava_messages/master/.travis.rosinstall
  4. Cloned your repository to test_ws/src/helloworld_rosjava_messages
  5. Executed catkin build

After that I checked test_ws/devel/share/maven/org/ros/rosjava_messages for the generated *.jar files and it looks fine for both packages. Also the content of test_ws/devel/share/maven/org/ros/rosjava_messages/helloworld_msgs/0.0.0/helloworld_msgs-0.0.0.jar looks fine to me:

helloworld_msgs

What am I missing? Do we need to have a copy of that file in another directory?

@fmessmer
Copy link
Author

fmessmer commented Sep 3, 2018

@exo-core
you are right...it seems to work as long as `ROS_MAVEN_DEPLOYMENT_REPOSITORY``is not set...
(maybe the location is hard-coded at some lines of code so this feature cannot be used correctly to freely specify the maven target destination)

let me have another look at this...but it won't be before Wednesday

@fmessmer
Copy link
Author

fmessmer commented Sep 4, 2018

hmm, I can't get it to work...but I don't think it's (just) the message generation for actions...

here is what I found out:
as long as ROS_MAVEN_DEPLOYMENT_REPOSITORY is not set (or set to .../devel/share/maven both the jar and the pom files are generated correctly under .../devel/share/maven/...
I also managed to redirect my local maven repository (default: ~/.m2/repository) to the same .../devel/share/maven/... by adding the following ~/.m2/settings.xml

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      https://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository>${env.ROS_MAVEN_DEPLOYMENT_REPOSITORY}</localRepository>
  <offline>false</offline>
</settings>

by doing so, everything happens in .../devel/share/maven/... and I can compile my project locally
however, I'm having problems to get this set up in TravisCI using industrial_ci

I just can't figure out why it is so difficult to tell rosjava to deploy/install to ~/.m2/repository?
apparently, setting ROS_MAVEN_DEPLOYMENT_REPOSITORY does not work...
@exo-core @jubeira: can you confirm this?
I also found this, so there seems to be a gradle task that deploys/installs to ~/.m2/repository (i.e. default maven local repository)
but I don't know where I have to add this install task so that it gets executed when running catkin build
instead, installDist seems to be the default task which deploys/installs to .../devel/share/maven...

one more thing:
having compiled my workspace as described above, i.e. all in .../devel/share/maven/..., I can go to .../build/<one_of_my_msg_packages> and execute .gradlew install there afterwards to get the jar and the pom installed to ~/.m2/repository....but I need this to be done thrughout catkin build already...

I appreciate any help/pointer!

@fmessmer
Copy link
Author

I think I found a solution for my problem....

@fmessmer
Copy link
Author

in case anyone is interested...
these are the changes I did on our forks:
rosjava/genjava#18
rosjava/rosjava_build_tools#37

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants