[Discourse.ros.org] [Next Generation ROS] Subscription topic not connecting to sensor output data

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[Discourse.ros.org] [Next Generation ROS] Subscription topic not connecting to sensor output data

William Woodall via ros-users

Im trying to create a python script as shown below to acquire sensor data. The sensor output data works in a cpp program, but not a Python script. No output from print statement in callback, any thoughts?

import pdb
import rclpy
from sensor_msgs.msg import Image
import time

class Test():
    def __init__(self, node):
        self.sub = node.create_subscription(Image,'image', self.callback)
    def callback(self, data):        

def main(args=None):

    node = rclpy.create_node('Test')    
    test = Test(node)
    assert test  # prevent unused variable warning  

    while rclpy.ok():

    # Destroy the node explicitly
    # (optional - otherwise it will be done automatically
    # when the garbage collector destroys the node object)

if __name__ == '__main__':

Output from pdb

> node = rclpy.create_node('Test')
(Pdb) n
> path/install/lib/python3.5/site-packages/test.py(23)main()
-> test = Test(node)
(Pdb) s
> path/install/lib/python3.5/site-packages/test.py(8)__init__()
-> def __init__(self, node):
> path/install/lib/python3.5/site-packages/test.py(10)__init__()
-> self.sub = node.create_subscription(Image,'image', self.callback)
> path/install/lib/python3.5/site-packages/rclpy/node.py(57)create_subscription()
-> def create_subscription(self, msg_type, topic, callback, qos_profile=qos_profile_default):
> path/install/lib/python3.5/site-packages/rclpy/node.py(59)create_subscription()
-> if msg_type.__class__._TYPE_SUPPORT is None:
> path/install/lib/python3.5/site-packages/rclpy/node.py(60)create_subscription()
-> msg_type.__class__.__import_type_support__()
(Pdb) r
> path/install/lib/python3.5/site-packages/rclpy/node.py(70)create_subscription()-><rclpy.subscr...x7fdc34068b70>
-> return subscription
> path/install/lib/python3.5/site-packages/test.py(12)__init__()
-> time.sleep(2)
> path/install/lib/python3.5/site-packages/test.py(12)__init__()->None
-> time.sleep(2)
> path/install/lib/python3.5/site-packages/test.py(24)main()
-> assert test  # prevent unused variable warning

[Visit Topic](https://discourse.ros.org/t/subscription-topic-not-connecting-to-sensor-output-data/1245/1) or reply to this email to respond.

If you do not want to receive messages from ros-users please use the unsubscribe link below. If you use the one above, you will stop all of ros-users from receiving updates.
ros-users mailing list
[hidden email]
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>