monitoring tool for raspberry pi ?

asked 2019-11-09 04:54:18 -0600

kallivalli gravatar image

updated 2019-11-10 05:49:43 -0600

hey guys

how to publish rpi basic hardware details like ram , temperature and memory etc through node

i have already checked below packages

https://github.com/ethz-asl/ros-syste... http://wiki.ros.org/libsensors_monitor http://wiki.ros.org/robot_monitor http://wiki.ros.org/rosmon

advance Thank you

update: i have created but i dont get output in ros same im getting in python

import os
import sys
import rospy
from std_msgs.msg import String

def talker():
    pub = rospy.Publisher('chatter', String, queue_size=10)
    rospy.init_node('talker', anonymous=True)
    rate = rospy.Rate(10) # 10hz
    while not rospy.is_shutdown():
        mycmd = 'vcgencmd measure_temp'
        mycm5 = 'vcgencmd measure_volts'
        mycm2 = 'free -m'
        mycm3 = 'df -h'
        mycm4 = 'ifconfig'
        a = str(os.system(mycm2))
        hi = "%s" %a
        pub.publish(hi)
        #pub.publish(os.system(mycmd))
        #pub.publish(os.system(mycm3))
        #pub.publish(os.system(mycm5))
        #pub.publish(os.system(mycm4))
        #hello_str = "hello world %s" % rospy.get_time()
        #rospy.loginfo(hello_str)
        #pub.publish(hello_str)
        rate.sleep()

if __name__ == '__main__':
    try:
        talker()
    except rospy.ROSInterruptException:
        pass
edit retag flag offensive close merge delete

Comments

This is not a ROS problem but python wise.

os.system will run a command in a subprocess and wait for it to finish before running. You may want to run it in parallel with the parent process, then you should look at the subprocess module -- in particular, you'll want to create a subprocess.Popen object.

Furthermore, take into account the node runs in a particular rate, so the info you are obtaining with the publisher may not be in "real time".

Weasfas gravatar imageWeasfas ( 2019-11-14 09:26:14 -0600 )edit