Float64 to float in python
I'm publishing Float64 type msg via rosserial python node to ros and I want to subscribe those messages. But the python code that subscribing Float64 msgs gives error and now I Float64 cannot convert to float.. Is there any way to do this? I tried with strings and convert it to float. But it failed.
import roslib; roslib.load_manifest('UWU_Bot')
import rospy
from geometry_msgs.msg import Twist
from std_msgs.msg import Float64
def callback(volt):
Distance = 16.2537*volt**4 - 129.893 * volt**3 + 382.268 * volt**2 - 512.611 * volt + 306.439
def nav():
rospy.init_node('UWU_Bot')
pub = rospy.Publisher('cmd_vel', Twist)
rospy.Subscriber("/IR_volts", Float64 , callback)
rospy.spin()
if __name__ == '__main__':
try:
nav()
except rospy.ROSInterruptException: pass
This is the python code. And I used rosserial IR_ranger example to send the Float64 data.
This is hard to debug without your code. Can you post your code?
I edited the post and added the python code
What is the exact error message?