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

Why ROS cannot find my executable when it is at the right place?

asked 2021-05-31 03:09:14 -0600

shiraz_baig gravatar image

updated 2021-05-31 03:10:31 -0600

Why ROS cannot find my executable when it is at the right place?

I am using melodic, ubuntu-18.04.

I have a file in /opt/ros/melodic/lib/tf/static_transform_publisher which is executable. I checked it and found it to be binary executable with execute permission for all.
My package can be correctly located by ros.
$ rospack find tf
The output is: /opt/ros/melodic/share/tf

Now if I try to run the executable
$ rosrun tf static_transform_publisher
The output is:
[rosrun] Couldn't find executable named static_transform_publisher below /opt/ros/melodic/share/tf

I do not understand why it cannot find the desired file? I understand all executables of a package are located in /opt/ros/melodic/lib folder while the package itself is located in corresponding shared folder.
I also tried: $ rosrun tf2 static_transform_publisher
But in that package, no executables exist.
There is another executable under package tf2_ros with same name. I can run it with rosrun command and tf2_ros as package name?
The documenttion tells me that tf2 has superceeded tf. But then what is tf2_ros?

So, pleae help me answer the question, why I cannot locate the executable either under tf or tf2.

Note: I had accidentally deleted ~/.ros folder. If that is the problem, How can I reconstruct it. I do not find any other abnormality in ros behavior due to deletion of this file, which has been created again.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-05-31 14:35:24 -0600

tryan gravatar image

I'm not certain why you can't run the static_transform_publisher from tf (wiki). Since rospack can find the package, I'm assuming you sourced /opt/ros/melodic/setup.bash, but a double-check couldn't hurt. Something else may be wrong with the installation.

In any case, tf has been deprecated in favor of tf2 (wiki) as you noted. As mentioned in the tf wiki, that package now just wraps tf2 but still exists for maintaining legacy code. New code should use tf2. Further, tf2_ros (wiki) contains the ROS bindings (C++ and Python) for the tf2 package and includes things like tf2_ros::TransformBroadcaster and tf2_ros::Buffer (see wiki for more information). The main thing is that tf2 is independent of ROS, so tf2_ros provides an API for ROS coders. tf2_ros also includes a static_transform_publisher, which replaces the one from tf. There is no such executable in tf2.

In summary, if the static_transform_publisher from tf2_ros works for you, you can use that one. For example:

rosrun tf2_ros static_transform_publisher 1 0 0 0 0 0 /frame_1 /frame_2

Lastly, deleting the .ros directory shouldn't affect the installed packages/executables.

If I've misinterpreted any of your questions or failed to clarify something, please let me know :).

edit flag offensive delete link more

Comments

Thank you very much for a prompt and detailed reply. I wish I had been content with your suggestion. But I did some foolishly daring moves.

I tried to uninstall tf2 for reinstalling it. It played havoc with my system. It uninstalled rviz and also robot_state_publisher and I do not know what else? :-( I reinstalled tf2 and rviz.

for reinstalling robot_state_publisher, I git cloned the package from github and tried to compile it under /opt/ros/melodic/share. It does not compile as it cannot find "src" folder. Under my own workspace/src folder it complains that it Could not find a package configuration file provided by "tf2_kdl" with any of the following names:

tf2_kdlConfig.cmake
tf2_kdl-config.cmake

I think I am struck badly. :-( If you have any suggestions, plz let me know, otherwise, I think I shall have to reinstall ros? I have umpteen packages in my workspace, I ...(more)

shiraz_baig gravatar image shiraz_baig  ( 2021-05-31 23:23:58 -0600 )edit

I reinstalled tf2_kdl. Then I compiled "robot_state_publisher" with "catkin_make" under myworkspace/src folder. I could not use "catkin build" as it gives some inexplicable error which I could never understand like undefined symbol reference' _ZN3ros4spinEvto' symbol/ /'opt_ZN3ros4spinEv/'ros....

After that I copied robot_state_publisher package (with all files and subfolders) to /opt/ros/melodic/share. Then I copied the executable robot_state_publisher to folder /opt/ros/melodic/lib/robot_state_publisher. But rosrun could not find it. rosrun was pointing to my workspace/lib folder. So, I copied the executable directly under /opt/ros/melodic/share/robot_state_publisher folder. Now if I run

$ rosrun robot_state_publisher robot_state_publisher

it is successful. My rviz is also working. I displayed a model in rviz and moved its joints with joint_stat_publisher. So, hopefully, things look alright. :-)

shiraz_baig gravatar image shiraz_baig  ( 2021-06-01 01:03:44 -0600 )edit

I'm glad you got it working. In general, you should not build packages from source unless you have a specific reason for doing so. It's usually best to use apt (see #q320046) as indicated in the ROS installation instructions:

sudo apt install ros-melodic-PACKAGE

It's easier to let the package manager take care of installing packages and dependencies for you. Another benefit is that you won't have those packages cluttering your workspace. In your case, I would have recommended reinstalling ROS (desktop or desktop-full) just to keep the installation clean, but it's up to you since you have things working.

tryan gravatar image tryan  ( 2021-06-01 09:16:01 -0600 )edit

Thank you very much tryan for all the help and support. You are so prompt and thorough in your remarks.

I am always shy of re-installing, because none of operating systems including (linux) cleanly removes everything of the previous installation, before the re-installation. Some of the things linger on from previous installation and do not get deleted and create a mess, unless I remove them painstakingly, manually. But of course "reinstallation" is always my last resort when things do not work.

shiraz_baig gravatar image shiraz_baig  ( 2021-06-01 19:51:01 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2021-05-31 03:09:14 -0600

Seen: 555 times

Last updated: May 31 '21