In [9]:
# importing the ROS Python API
import rospy
# importing all the message types we are going to use
from std_msgs.msg import String
from geometry_msgs.msg import Pose
from sensor_msgs.msg import LaserScan
In [10]:
# jupyros is a library solely for use in Jupyter Notebooks, This is used for dedactic purposes only here
# to illustrate ROS concepts. It's for interactive use only, not in a stand-along program
import jupyros as jr
In [11]:
# Initialise your node
rospy.init_node('testnode')
In [12]:
# define you callbacks
def pose_cb(msg):
print('pose')
print(msg)
def str_cb(msg):
print(type(msg))
print(msg)
def scan_cb(msg):
print('scan')
print(msg)
In [13]:
# correct rospy way:
s = rospy.Subscriber('/msg', String, str_cb)
s.unregister()
In [14]:
#jr.subscribe('/pose_stream', Pose, pose_cb)
jr.subscribe('/msg', String, str_cb)
#jr.subscribe('/scan', LaserScan, scan_cb)
In [7]:
jr.publish('/msg', String)
In [ ]: