0
$\begingroup$

Rosanswers logo

I am trying to understand and modify the code for http://wiki.ros.org/tf2/Tutorials/Introduction%20to%20tf2

I have done roscd for all the packages that are named (around five of them as I follow the trail) and none of them have any source code. They have .launch, .msg, .xml files but no .cpp or .py files. So I am stumped in this case, and also curious about the general case. There must be something about package structure that I am missing. Thanks,


Originally posted by pitosalas on ROS Answers with karma: 628 on 2019-10-04

Post score: 0

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

Where can I find the actual source code for the tf2 demo?

At the bottom of the page of the tutorial you link, there is this:

Now that we have examined the turtle_tf2_demo, let's look at how to write the broadcaster (Python) (C++) for this demo.

Following that link, we come to the Writing a tf2 broadcaster (Python) page and the Create a learning_tf2 package section states (emphasis mine):

First we will create a catkin package that will be used for this tutorial and the following ones. This package called learning_tf2 will depend on tf2, tf2_ros, roscpp, rospy and turtlesim. Code for this tutorial is stored here.

I'm not entirely sure which "tf2 demo" you refer to, but it would seem there is at least a link to the turtle_tf2 package.

Note that both the Python and the C++ sources are hosted by that same package.

I have done roscd for all the packages that are named (around five of them as I follow the trail) and none of them have any source code. They have .launch, .msg, .xml files but no .cpp or .py files.

Packages you install using apt or apt-get (as instructed by the Installing the Demo section) never include source code -- or at least: it'd be rarely the case.

roscd takes you to the package directory, which is the directory which contains the manifest (ie: package.xml). For packages installed using apt, that is the directory in /opt/ros/$distro/share. Only resources are installed there, no binaries, libraries, headers or source code.

(I write "never", but in reality a package author can do whatever he wants, including installing source code in locations where you'd normally only find binaries. It would be highly irregular and undesirable though)


Originally posted by gvdhoorn with karma: 86574 on 2019-10-04

This answer was ACCEPTED on the original site

Post score: 3


Original comments

Comment by pitosalas on 2019-10-07:
Thanks... Useful tips.

$\endgroup$
0
$\begingroup$

Rosanswers logo

Two points:

  • For installed packages, roscd takes you to the share/ directory of the package which is where everything that's not source code will be residing. Things like C++ headers and python code will get installed according to linux filesystem hierarchy conventions beneath the overall ROS distribution directory (e.g, /opt/ros/melodic/include and /opt/ros/melodic/lib/python2.7/dist-packages)

  • Installed packages generally only include compiled libraries and executables, and not C++ source files (though maybe they should for tutorials). To see the source code, you need to either browse it online or clone it on to your machine. In this case, the code is available here: https://github.com/ros/geometry_tutorials


Originally posted by jdlangs with karma: 971 on 2019-10-04

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by pitosalas on 2019-10-07:
Thanks. Useful summary!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.