Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 50

how I convert string to float?

$
0
0
I'm using arduino to send values from 0.00 to 5.00 and I'm trying to read them but I get this error raise ROSSerializationException(str(e)) rospy.exceptions.ROSSerializationException: : 'required argument is not a float' when writing 'x: "0.92" this is the code, how can I convert the value to float? def __init__(self): rospy.init_node('my_tf_broadcaster') self.ser = serial.Serial('/dev/ttyACM0', 115200) self.get_odometry() def get_odometry(self): self.pub_tf = rospy.Publisher("/tf", tf.msg.tfMessage) change = 0.0 while not rospy.is_shutdown(): # Run this loop at about 10Hz rospy.sleep(0.1) message = self.ser.readline() t = geometry_msgs.msg.TransformStamped() t.header.stamp = rospy.Time.now() t.header.frame_id = "odom" t.child_frame_id = "base_link" t.transform.translation.x = message.rstrip() #trying to read this value t.transform.translation.y = 1.0 t.transform.translation.z = 0.0 t.transform.rotation.x = 0.0 t.transform.rotation.y = 0.0 t.transform.rotation.z = 0.0 t.transform.rotation.w = 1.0 tfm = tf.msg.tfMessage([t]) self.pub_tf.publish(tfm)

Viewing all articles
Browse latest Browse all 50

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>