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