Skip to content

Instantly share code, notes, and snippets.

@joshua-8
Created March 19, 2023 01:17
Show Gist options
  • Save joshua-8/c98bf3f63764d1c4bb490aa2446916f2 to your computer and use it in GitHub Desktop.
Save joshua-8/c98bf3f63764d1c4bb490aa2446916f2 to your computer and use it in GitHub Desktop.
subscribes to a couple ros topics and prints them.
#!/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