import rospy
from std_msgs.msg import Empty
#from bebop_msgs.msg import Ardrone3PilotingStateFlyingStateChanged
def callback(data):
time2 = float(rospy.Time.now().secs) rospy.loginfo('received: %.2f' % time2-time1)
def latencyTest():
# Create a node rospy.init_node('latency_tester', anonymous=True) # Set up topics to publish pub_takeoff = rospy.Publisher("bebop/takeoff", Empty, queue_size=10) pub_land = rospy.Publisher("bebop/land", Empty, queue_size=10) # Need to check topic name and data type for changed flight # syntax: rospy.Subscriber(Topic name, Data/msg type, Callback fcn) #rospy.Subscriber("states/ARDrone3/PilotingState/FlyingStateChanged", Ardrone3PilotingStateFlyingStateChanged, callback) #rospy.Subscriber("states/ARDrone3/PilotingState/FlyingStateChanged", bebop_msgs/Ardrone3PilotingStateFlyingStateChanged, callback) #rospy.spin() rospy.sleep(1) # NOTE: We must let the subscriber initialize pub_takeoff.publish(Empty()) rospy.loginfo('Takeoff sent!') rospy.sleep(3) pub_land.publish(Empty()) rospy.loginfo('Land sent!') #time1 = float(rospy.Time.now().secs)
if __name__ == _main_:
try:
latencyTest() except rospy.ROSInterruptException: pass
Page last modified on August 03, 2018, at 02:35 PM