Created
March 19, 2023 01:17
-
-
Save joshua-8/c98bf3f63764d1c4bb490aa2446916f2 to your computer and use it in GitHub Desktop.
subscribes to a couple ros topics and prints them.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import rospy | |
import time | |
from pidrone_pkg.msg import State | |
from sensor_msgs.msg import Range, Imu | |
def callbackRange(data): | |
import datetime | |
dt = datetime.datetime.now() | |
print("range",data.range,dt.second+dt.microsecond/1000000.0," "," "," ") | |
def callbackHeightEMA(data): | |
import datetime | |
dt = datetime.datetime.now() | |
print(" "," "," ","ema",data.pose_with_covariance.pose.position.z,dt.second+dt.microsecond/1000000.0) | |
def listener(): | |
rospy.init_node('subscribe', anonymous=True) | |
rospy.Subscriber("/pidrone/state/ema", State, callbackHeightEMA) | |
rospy.Subscriber("/pidrone/range",Range,callbackRange) | |
rospy.spin() | |
if __name__ == '__main__': | |
listener() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment