How to recieve information from a subscriber withouth executing a callback
I have the following code:
#!/usr/bin/env python
import rospy
from std_msgs.msg import Float64
from random import randint
from time import sleep
from std_msgs.msg import Int64
def counter(msg):
print msg.data
rospy.init_node('Arduino_hear_my_whispers')
pub = rospy.Publisher('your_topic', Float64, queue_size=10)
while not rospy.is_shutdown():
rnd = 1.0
print "the number is " + str(rnd)
message=Float64(rnd)
pub.publish(message)
sleep(0.01)
rnd = 2.0
print "the number is " + str(rnd)
message=Float64(rnd)
pub.publish(message)
sleep(0.01)
sub = rospy.Subscriber('I_know', Int64, counter, queue_size=100)
rospy.spin()
I am using this code to receive some signals from Arduino. The signals are sended to the topic "I_know". Although the code is running properly, I wonder if there is a way to get the signals from the topic without executing the callback? Just assigning the values from the topic to a variable from the main program.
Why do you want to do this?
I am trying to make a LED blink and to count the number of times that it does. If the number of blinks reaches a determine value, I want the blinking to stop.
Also, I am wondering if it is possible.