ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Is there a way to rebuild packages inside /opt/ros/<distro> folder?

asked 2023-04-11 07:48:14 -0600

Edvard gravatar image

Hi. Sorry for all mistakes, English is not my native language. Is there a way to recompile package inside a distro folder. I have a small problem with Foxy controller_interface, to be more specific, I need the CallbackReturn method inside it. I suppose that, it is better to change my code, that change original code of the ros packages, but still it I'd like to give it a try. Appreciate any help.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-04-11 20:04:16 -0600

shonigmann gravatar image

Please correct me if I'm wrong, but my understanding is that you want to modify and rebuild a specific package that you presumably installed as a debian binary (apt install ... or similar) since it is on /opt/ros/....

The source code is not packaged with C++ debians, only the headers. So you would need to clone the package in question to a workspace that you could then overlay on top of your binary install.

Bear in mind that this would require you to also rebuild any packages that depend on the package that you modified (e.g. I believe you would also need to rebuild the various ros2_controllers that depend on the controller_interface

Putting that into practice could look like:

# create a source workspace 
mkdir -p ~/control_ws/src

# go to your src folder and clone the repo/branch that you will be modifying
cd ~/control_ws/src
# optionally fork the repo first to track your independent changes and be able to make a pull request later on
git clone https://github.com/ros-controls/ros2_control.git -b foxy
git clone https://github.com/ros-controls/ros2_controllers.git -b foxy
# git clone ... for any other packages that depend on controller_interfaces

# make your changes to any of the files

# build the workspace
cd ~/control_ws
colcon build --symlink-install

# source the workspace - this step is crucial to make it so that you're system will actually use the modified packages rather than the original debs
# you can optionally add this step to your ~/.bashrc to "permanently" overlay this over your binary installation
source install/setup.bash

# Optional but appreciated - if you think the community would benefit from your changes, make a Pull Request to propose your changes be added upstream
edit flag offensive delete link more

Comments

1

I'm not sure what exact change OP wants to make to the code, but: If you're adding new API or breaking the ABI then yes, you will need to rebuild everything downstream. But if you just change functionality inside the library then you should be able to rebuild the single package in the overlay workspace, and if the setup paths are working correctly then the new shared library will be loaded at runtime instead of the old installed one.

Although, due to https://github.com/ros2/ros2/issues/1150 it may not be trivial to overlay the Foxy core libraries properly, not sure.

Note: one could always build the whole thing from source - it takes a little time but it's not so bad.

emersonknapp gravatar image emersonknapp  ( 2023-04-12 12:23:16 -0600 )edit

@shonigmann, thank you. Yes, you understanded me correctly and thank for your detailed answer. Sorry, that I react on your help only now.

@emersonknapp, thank you too for your comment. I'll keep that in mind.

Edvard gravatar image Edvard  ( 2023-04-26 10:42:47 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2023-04-11 07:48:14 -0600

Seen: 621 times

Last updated: Apr 11 '23