diff --git a/catkin_ws/src/ball_tracking/src/dummy_sub.py b/catkin_ws/src/ball_tracking/src/dummy_sub.py new file mode 100755 index 0000000..6b6bcf2 --- /dev/null +++ b/catkin_ws/src/ball_tracking/src/dummy_sub.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 +import rospy +from geometry_msgs.msg import Point + +def callback(data): + """Callback function that is called when a message is received on the /trigger topic.""" + rospy.loginfo(f"Received point: (x: {data.x}, y: {data.y}, z: {data.z})") + +def listener(): + """Sets up the subscriber node.""" + # Initialize the node with the name 'point_subscriber' + rospy.init_node('PONG_PADDLES', anonymous=False) + + # Subscribe to the '/trigger' topic with the callback function + rospy.Subscriber("/trigger", Point, callback) + + # Keep the program alive until it is stopped with Ctrl+C + rospy.spin() + +if __name__ == '__main__': + try: + listener() + except rospy.ROSInterruptException: + pass +