-
Notifications
You must be signed in to change notification settings - Fork 194
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
ControlBoardWrapper2 ROS topic #209
Comments
@miaragao worked a lot on ROS/YARP integration on the iCub, I guess he could be interested in this enhancement, and can provide feedback on useful features for the users. @EnricoMingo @arocchi With a similar option on the ForceTorque/IMU wrappers you could get rid of your bridges. |
yes, potentially this can be used for all wrappers. The only thing is that robotInterface creates ports, and therefore also topics, for each part of the body while it seems that ROS have one topic for all the robot. This is something we have to discuss about maybe? |
Ports can publish to the same topic, if you want them to. |
Hi all! This could actually be really useful for my work. Right now, on ROS side I have the joint names hard coded, and this would solve that problem for example (although the joints names on the URDF model doesn't match the names on the iCub robot right now - this will be fixed). This is just one of the examples. Actually I would like to try this really soon in order to solve the problem with the joint names. @barbalberto about your TODO list:
I can't tell you exactly what I might need here (as a user of the YARP/ROS integration), but the joint names list is definitely useful. I hope I can help you on this as my work progresses. Cheers! |
@paulfitz: can you help me with the idl_ros generation? What am I doing wrong? The code is in the branch ControlBoardWrapper2_NewOutputPort, the device involved is the ControlBoardWrapper2. The funny things is that if I activate the TEST_yarpidl_rosmsg and TEST_yarpidl_thrift, it says that the thrift fails and rosmsg succed... |
Hi @barbalberto, looks like on that branch there is a modification to |
you mean the add of @output_dir@ ? |
Yes that's what I mean @barbalberto. Is TEST_yarpidl_thrift still failing for you? |
yes, the one failing is the idl_thrift_demo_test. For the ros part the behaviour does not change with or without the @output_dir@, the .cpp files are not generated. |
@barbalberto can you do me a favor and do |
Here it is:
|
thanks @barbalberto, that's really odd... Those usr/local/src/robot/test/yarp/build/src/idls/thrift/tests/make/demo/usr/local/src/robot/test/yarp/build/src/idls/thrift/tests/make/demo/src/DemoEnum.cpp paths look super funky, like the output path is getting included twice. |
@barbalberto I can replicate the failure in #209 (comment) by including the change you made to |
Oops, you are right. I thought I've removed it but apparently was still there, sorry about that :( if I print the variable full_headers in the YARP_IDL_TO_DIR_CORE function, I see just one header file (in my case joint.h) but Header.h and TickTime.h are missing and therefore not copied to src folder. The compilation fails jointState.h tries to include TickTime.h The joint.h is correctly copied in the right place so that's fine. |
I tried the example here http://wiki.icub.org/yarpdoc/rostypes_tutorial_portable.html and it works Could the problem come from the fact that I'm using it inside yarp itself? maybe too early? find_package(YARP REQUIRED) maybe cmake falls in some wrong loop or has some variable not correctly initialized? |
@barbalberto looks like the code for the special built-in ROS |
@barbalberto the |
Ok, now the files are correctly installed in the fodler specified in the yarp_idl_to_dir! Thank you Paul. I used CMAKE_CURRENT_SOUCE_DIR just because all the tutorials are done like this so I wanted to stick with them at first, but yes, my idea was also to have the generated files in the build folder in the final version. As a side note, if I put CMAKE_CURRENT_BINARY_DIR in the yarp_idl_to_dir function, then the build folder will have the generated files twice, Now I'm facing a last problem: if I try to compile using the thrift from a clean repository, the configure step of cmakes calls the thrift generator, which is not built yet. So right now I should first compile yarp repository telling my device to not use the ros/yarp thrift msg and then, as a second step, re-run cmake enabling the rosmsg generator and then it works. just adding "add_dependencies(YARP_dev yarpidl_rosmsg yarpidl_thrift )" to my device, doesn't help. I see in the ros/test you create several targets for generating / compiling / testing ... shall I do something similar in this case? |
No, please don't copy the test targets for generating/compiling/running, they are just there to test generating/compiling/running, not because that's a good way to structure your build. It is in fact very delicate, with is why those tests don't run by default. At some point @elen4 took a pass at making the IDL machinery easier to use, and one of the outcomes of that was to run it at configuration time, not just build time. That means that using it while compiling yarp itself is a little awkward. Fixable, but awkward. I'll poke at it. |
@paulfitz this is an interesting chicken-egg problem :) ideas on how to solve it? |
Hi @barbalberto I pushed a fix for the macro to the ControlBoardWrapper2_NewOutputPort branch on my fork, could you try it out? |
The problem is that find_program(YARPIDL_${family}_LOCATION yarpidl_${family} HINTS ${YARP_IDL_BINARY_HINT}) It should instead use the target that creates the executable. This should handle all the dependencies automatically: According to CMake 3.0.2 documentation
See: http://www.cmake.org/cmake/help/v3.0/command/add_custom_command.html For external programs using this macro, I think the target executable should be "exported" together with the libraries, so that CMake knows the target after add_executable(<name> IMPORTED [GLOBAL]) See:
I'm not sure if CMake 2.8.9 supports all of this, though, but I think it does since |
@elen4: I'm not sure to understand what the patch in the YarpIDL.cmake file should do. Is it a better error message in case yarp thrift is not found? ( I already removed the need of find_package(YARP) after the last commmit of Paul. I used the ALLOW_IDL_GENERATION just for convenience and I meant to remove it. Will this make things easier? So as far as I understand, there are 2 ways to fix this issue.
I know how to do the first solution, not the second one but I can check the links @drdanz provided if we chose this way. |
For @barbalberto's bullet point 2: it is straightforward to get the generator built before libYARP_dev builds, but it is not straightforward to get the generator built before libYARP_dev is configured. To be able to configure libYARP_dev, we need to know the list of files in it, and to complete that list, we currently need the generator (or to follow bullet point 1). There is one other option: we could have the generator produce a list of source/header files in a file, and commit that file (rather than the generated source/header files themselves). That list is all we need during configuration. The generator already produces such a file, with a bit of clean up we could do the following:
The
|
@barbalberto: sorry, I though that current code was placing generated files inside the build dir, and I didn't realize I wasn't testing properly. Anyway, the idea in my commit was actually skipping the configure-time generation, and only leave the build-time command (and related target), to add as a dependency to YARP_dev
using the "target" generator in the command, as @drdanz also pointed out.
which I think is a reasonable assumption inside Yarp (I mean, the list of generated files can be expected to always be up-to-date with the IDL generator, since they are in the same repo). |
As @elen4 says the idea was initially to implement @barbalberto's bullet point 1 solution, to avoid exposing to users the complexity of generated code. I know it is not a good practice to commit generated code but I would be inclined to consider it acceptable in this case, it seems that generating it on the fly adds a good amount of complexity. What do you guys think? If we change where the thrift generator places generated files let's not forget to update online tutorials! |
I'm in favor of keeping the generated code committed in the repo: for icub-main and wysiwyd projects is already like that and it's fine. Besides the complexity mentioned by @lornat75, I'd say that committed code represents also a sort of buffer that decouples changes made to yarp-idl components from the sister projects so that the final user can always decide whether to include or not those changes to idl code, keeping things under control and being aware of what is going on. Conversely, if for any reason the final user wants to incorporate new idl features straightaway, he can set the ALLOW_IDL_GENERATION cmake option always to ON (is it cached?). |
Well, in any case solution 1 is easy to undo. If we find a reliable way to solve the issue, we can later change the way those files are handled. In the meanwhile we have something to start with for testing and debugging. |
Yes, in this case I'd be ok with committing the generated files. It felt unnecessary since this case is in the yarp library so doesn't really need the decoupling @pattacini mentions. But we don't seem to be converging on a simple alternative. |
@paulfitz indeed I was more referring to sister projects rather than yarp, but yes it seems there is no a unique approach |
Sorry, I think I created some confusion here 😕 |
ROS message is created with the following fields name; Where name is filled with "rosNameTest" plus joint number. How do we get the joint name? From config file I guess... |
In my opinion, we should get the name of the joint (Axis) from the IAxisInfo interface. If this interface is not available, we should fallback to the current solution. In this way we will continue to decouple the wrapper and the underlying device. |
Pull request merged into master. |
Since some people uses both YARP and ROS, we tought to have the controlBoardWrapper2 optionally create a ROS topic along the usual yarp port.
I've done a first implementation of this and now it is able to create a topic publiching a sensor_msgs/JointState message which is one of the 'native' ROS messages documented here http://docs.ros.org/api/sensor_msgs/html/msg/JointState.html
I used a .msg file to generate the class that will be sent through the topic
The data sent are
For now the data is filled with dummy names and numbers just to see if it works as expected.
I pushed the code on a branch called ControlBoardWrapper2_NewOutputPort.
The CMake flag CBW2_USE_ROS_MSG has to be enabled in order to compile the needed code and generate this topic.
It has been tested with a simple subscriber create by following the tutorial on ROS webpage (http://wiki.ros.org/ROS/Tutorials/ExaminingPublisherSubscriber) so not using yarp code, btw yarp read is able to read the data back if the yarpidl_rosmsg service is running like explained in the page http://wiki.icub.org/yarpdoc/yarp_with_ros.html
TODO:
The text was updated successfully, but these errors were encountered: