ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I solved this problem importing FLoat 64 from std_msg.msg. I still do not know why ROS is not recognizing the float64 type from the Arduino_message file. The final code is presented below:

!/usr/bin/env python

import rospy from std_msgs.msg import Float64 from random import randint from time import sleep

rospy.init_node('Arduino_hear_my_whispers') pub = rospy.Publisher('your_topic', Float64, queue_size=10) while not rospy.is_shutdown(): rnd = randint(0,2) print "the number is " + str(rnd) message=Float64(rnd) pub.publish(message) rate = rospy.Rate(100) sleep(3) rate.sleep()

click to hide/show revision 2
No.2 Revision

I solved this problem importing FLoat 64 from std_msg.msg. I still do not know why ROS is not recognizing the float64 type from the Arduino_message file. The final code is presented below:

!/usr/bin/env python

#!/usr/bin/env python
import rospy
from std_msgs.msg import  Float64
from random import randint
from time import sleep

sleep

rospy.init_node('Arduino_hear_my_whispers') pub = rospy.Publisher('your_topic', Float64, queue_size=10) while not rospy.is_shutdown(): rnd = randint(0,2) print "the number is " + str(rnd) message=Float64(rnd) pub.publish(message) rate = rospy.Rate(100) sleep(3) rate.sleep()

rate.sleep()