raspi_temperature.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 '''raspi_temperature ROS Node'''
3 import os
4 import rospy
5 import tf
6 from sensor_msgs.msg import Temperature
7 
8 def talker():
9  '''raspi_temperature Publisher'''
10  pub = rospy.Publisher('raspi_temperature', Temperature, queue_size=10)
11  rospy.init_node('raspi_temperature', anonymous=True)
12  br = tf.TransformBroadcaster()
13  rate = rospy.Rate(1) # 1hz
14  while not rospy.is_shutdown():
15  br.sendTransform((-0.05, 0.0, 0.10),
16  (0.0, 0.0, 0.0, 1.0),
17  rospy.Time.now(), "raspberrypi", "base_link")
18  temp = os.popen("vcgencmd measure_temp").readline()
19  temp = temp.replace("temp=", "")
20  temp = temp[:-3]
21  temperature = Temperature()
22  temperature.header.stamp = rospy.Time.now()
23  temperature.header.frame_id = 'raspberrypi'
24  temperature.temperature = float(temp)
25  temperature.variance = 0
26  pub.publish(temperature)
27  rate.sleep()
28 
29 
30 if __name__ == '__main__':
31  try:
32  talker()
33  except rospy.ROSInterruptException:
34  pass


raspi_temperature
Author(s): B.N.Berrevoets
autogenerated on Mon Jun 10 2019 14:26:00