Skip to content

Commit

Permalink
Wire py_listener to chatter launch (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvukov authored Sep 14, 2024
1 parent 741d722 commit 234a18c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions examples/chatter/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,16 @@ py_binary(
],
)

# Defines a launch target with talker and listener. Just run as
# `bazel run //examples/chatter:chatter`. This will build the two nodes,
# Defines a launch target with a talker and two listeners. Just run as
# `bazel run //examples/chatter:chatter`. This will build the 3 nodes,
# the deployment and start the launcher.
ros_launch(
name = "chatter",
launch_files = [":chatter.launch"],
nodes = [
":talker",
":listener",
":py_listener",
],
)

Expand Down
3 changes: 2 additions & 1 deletion examples/chatter/chatter.launch
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<launch>
<node type="chatter/talker" name="talker" />
<node type="chatter/listener" name="listener" output="screen" />
<node type="chatter/listener" name="cc_listener" output="screen" />
<node type="chatter/py_listener" name="py_listener" output="screen" />
</launch>
2 changes: 1 addition & 1 deletion examples/chatter/listener.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <ros/ros.h>

void ChatterCallback(const example_msgs::Example& msg) {
ROS_INFO_STREAM("Received: " << msg.message);
ROS_INFO_STREAM("C++ listener received: " << msg.message);
}

int main(int argc, char** argv) {
Expand Down
5 changes: 2 additions & 3 deletions examples/chatter/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@


def callback(msg):
rospy.loginfo(msg)
rospy.loginfo(f'Python listener received: {msg.message}')


def main():
rospy.init_node('listener', anonymous=True)
sub = rospy.Subscriber( # noqa
'chatter', example_msgs.msg.Example, callback)
rospy.Subscriber('chatter', example_msgs.msg.Example, callback)
rospy.spin()


Expand Down

0 comments on commit 234a18c

Please sign in to comment.