ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

Any lazy way to put your own local ros package under /opt/ros?

asked 2022-05-13 08:12:27 -0500

aarsh_t gravatar image

updated 2022-05-13 08:13:52 -0500

Hello everyone,

I have modified package for a real robot which requires access of the ports bellow 1024.

When I put my catkin_ws under the root, it is able to access the ports below 1024 to communicate with the real robots easily but when I put it under /home/user/catkin_ws it fails to access the port below 1024 even after giving the access rights to the built node binary file.

I am not sure if this is possible or not, But I am looking to do something similar that happens when we do sudo apt install ros-noetic-pkg-name but locally. Is there any (lazy) way such that I can redirect the build of the package to the /opt/ros/noetic. May be with running some script? Or may be something else?


edit retag flag offensive close merge delete


What do you mean by "When I put my catkin_ws under the root"?

You have made a mistake somewhere, because under linux, installing a ros package in /opt/ros/ does not give it permission to create a socket with a port number less than 1024.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2022-05-13 10:55:25 -0500 )edit

Perhaps the implication is that "putting it under the root" would require actual super user privileges. And if those privileges are then also used to start the binary, you'd essentially run that binary as root.

gvdhoorn gravatar image gvdhoorn  ( 2022-05-13 12:02:53 -0500 )edit

I am not sure if it gives the access to the ports under 1024 or not. may be because I am running it after sudo su is giving access rights. I trid to run the rosnode with sudo using launch prefix but it didn't helped. I also tried the suggested way of using setcap but it didn't went well. I also tried authbind and also to set the unprivileged port number start to zero. Nothing worked for me so far. Any other suggested way to do it?

I couldn't find any way so i tried running it under sudo su and putting it under /opt/catkin_ws and it worked.

aarsh_t gravatar image aarsh_t  ( 2022-05-13 16:59:07 -0500 )edit

sudo su essentially starts a shell as the root user. So, yes, that would allow your application to open up ports in the system reserved range.

gvdhoorn gravatar image gvdhoorn  ( 2022-05-14 01:16:33 -0500 )edit

Yes, I think I will have to continue with that, Although not a good practice.

aarsh_t gravatar image aarsh_t  ( 2022-05-15 10:05:58 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2022-05-13 15:31:55 -0500

Alex-SSoM gravatar image

Here's one way to do it.

  1. Elevate the privileges to superuser and source the setup.bash of the workspace

    sudo su then source devel/setup.bash.

  2. Install the package catkin_make -DCMAKE_INSTALL_PREFIX=/opt/ros/$ROS_DISTRO install

edit flag offensive delete link more


hey, thanks for your answer. I will definitely give it a shot.

Do you know if I can find any documentation of your suggested method?

aarsh_t gravatar image aarsh_t  ( 2022-05-13 17:01:30 -0500 )edit
Alex-SSoM gravatar image Alex-SSoM  ( 2022-05-16 06:46:37 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2022-05-13 08:12:27 -0500

Seen: 53 times

Last updated: May 13