ros-industrial / ros_qtc_plugin

ROS Qt Creator Plug-in (https://ros-qtc-plugin.readthedocs.io)
396 stars 213 forks source link

Support ROS-independent builds #492

Closed marip8 closed 5 months ago

marip8 commented 7 months ago

Problem

There are now quite a few tools in the ROS-I ecosystem that are independent of ROS such that they can support both ROS1 and ROS2 layers simultaneously. As of version 12.0.0, it appears that part of the plugin build process (at least for colcon) forces the sourcing of the selected distribution's setup.bash file. This is a problem for me because I want to build a ROS-independent project in Qt Creator and then build both the ROS1 and ROS2 layers as separate projects in Qt, using the ROS-independent project as an underlay.

Currently, my ROS-independent build (using colcon) is being forced to source ROS2 (I had to choose a distro, so I chose a ROS2 one), and my chained ROS1 workspace build (using colcon) fails because sourcing the upstream workspace only lets it know about ROS2 things.

What I tried to get around this issue

Desired solution

I think the ideal solution would be to add an empty string or "None" option in the Distribution drop down box in the ROS project configuration menu and make the sourcing of /opt/ros/<distro>/setup.bash optional based on the value of this field.

christian-rauch commented 7 months ago

When I create a new "ROS Project", the Distribution: drop-down menu does not list a ROS distribution initially: qt_creator_ros_workspace and the .workspace file also contains no distribution:

<?xml version="1.0"?>
<Workspace>
    <Distribution path=""/>
    <DefaultBuildSystem value="2"/>
</Workspace>

Does this not work in your case?

marip8 commented 6 months ago

I should have clarified that I did not have this issue when I was using the snap distributed version of Qt Creator and this plugin. What you described above is also what I would see when I used the snap version.

I recently switched from the snap version to the nominal Qt installer version (i.e., from their website); the problems I described above occur in the Qt installer version of Qt Creator. It does find both distributions of ROS by default (maybe the snap version can't find them because it can't access /opt from its sandbox directory?), so I'm forced to choose one or the other.

When I set <Distribution path="">, I get the following message: [ROS Error] Project file distribution [] is not installed. Setting to [/opt/ros/foxy], if incorrect modify project file [calibration_ws.workspace]. Then I think the plugin sources the setup.bash file of the "default" version of ROS every time it builds because I see ROS environment variables in the build dialog and in a terminal after I source the workspace

marip8 commented 6 months ago

I think this might be the code to change to get around this issue:

https://github.com/ros-industrial/ros_qtc_plugin/blob/0381f884ae615b117574623b2a06b1ec117b1df7/src/project_manager/ros_utils.cpp#L379-L384

christian-rauch commented 6 months ago

Can you send a PR that implements the feature you need?

I also noticed that when I change the entry in the Distribution: drop-down list to something with a path, then I cannot change back to an empty entry. To make this explicit and more robust, the list should contain an explicit empty entry.

marip8 commented 6 months ago

Can you send a PR that implements the feature you need?

Sure. I opened the issue without a PR mostly because I wasn't sure what all files needed to be changed and thought you or @Levi-Armstrong might know of a better solution.

christian-rauch commented 6 months ago

I added that feature to the upcoming Qt Creator 13 plugin: https://github.com/ros-industrial/ros_qtc_plugin/pull/495. Please test and let me know if this works or you.