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

Revision history [back]

click to hide/show revision 1
initial version

Publishers and subscribers do not need to be in the same package; in fact, this is one of the strengths of ROS, because it means that you can interact with someone else's code without needing to modify it.

When you're setting up your CMakeLists and your package.xml for your subscriber, you should declare a dependency on the message package that contains the message type definition for the topic that you want to subscribe to. For some cases, this message may be in the package with the publisher (for custom messages), but in most cases the message definition will probably be in a separate package.

For example, most laser scanners publish a sensor_msgs/LaserScan, and so you should depend on the sensor_msgs package, and your code doesn't need a dependency on the specific driver for your laser, regardless of whether you're using a Hokuyo, SICK, or other brand of laser.