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

ROS Serialization Values Error

$
0
0
Hi there, I am trying to do a simple ipc over ros serial using the publish subscribe module. The data is a 2D array shaped thus: `10001 x 7`. I write my poublisher like so import rospy from rospy.numpy_msg import numpy_msg from rospy_tutorials.msg import Floats import os import numpy as np from os.path import expanduser, join def talker(data): pub = rospy.Publisher('/torobo/teach_joints', numpy_msg(Floats),queue_size=1) r = rospy.Rate(10) # 10hz while not rospy.is_shutdown(): pub.publish(data) r.sleep() if __name__ == '__main__': filepath = join(expanduser('~'), 'Documents', 'LyapunovLearner', 'ToroboTakahashi', 'data') name = 'state_joint_pos_only.csv' filename = join(filepath, name) data = np.ravel(np.loadtxt(filename).astype(np.float64), order='A') np.set_printoptions(suppress=True) print(data[:70]) try: rospy.init_node('joints_pub_node') talker(data) rospy.spin() except KeyboardInterrupt: rospy.logerror("shutting down ros") And my subscriber is something like this: import rospy import numpy as np from rospy_tutorials.msg import Floats from rospy.numpy_msg import numpy_msg def callback(data): np.set_printoptions(suppress=True) print rospy.get_name(), "I heard %s"%str(data.data.shape) ret_data = data.data.astype(np.float64) print(ret_data[:70])#.reshape(10, 7)) def listener(): rospy.init_node('listener') rospy.Subscriber("/torobo/teach_joints", numpy_msg(Floats), callback) rospy.spin() if __name__ == '__main__': listener() However, I find that the data I am sending and the one I am receiving are vastly different in values. Here are printouts from both nodes: publisher (first 70 elements): [ 0. 0.001 0.016 0.002 -0.008 0.008 -0.03 0. 0. 0.015 0.019 -0.009 0.006 -0.03 -0.005 -0.053 0.009 0.60699999 -0.126 0.26300001 -0.034 -0.004 -0.185 -0.036 1.96300006 -0.396 1.59899998 -0.032 -0.001 -0.361 -0.16 3.52600002 -0.81699997 3.08800006 -0.03 -0.032 -0.57599998 -0.28200001 4.90999985 -1.23099995 4.26499987 -0.031 -0.094 -0.77700001 -0.38299999 6.48899984 -1.62300003 5.74100018 -0.03 -0.13 -0.90399998 -0.49900001 7.80299997 -1.94700003 6.85900021 -0.03 -0.168 -1.11899996 -0.55000001 9.29899979 -2.28200006 8.10599995 -0.03 -0.197 -1.29499996 -0.69 10.80900002 -2.71300006 9.59599972 -0.03 ] And subscriber equivalent: [ 0.00000000e+00 0.00000000e+00 -3.68934881e+19 8.13999951e-01 -3.68934881e+19 1.12799990e+00 -3.68934881e+19 8.76499951e-01 -3.68934881e+19 -1.00299990e+00 -3.68934881e+19 1.00299990e+00 -3.68934881e+19 -1.23999989e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 -3.68934881e+19 1.11499989e+00 3.68934881e+19 1.15199995e+00 -0.00000000e+00 -1.01899993e+00 -2.00000000e+00 9.70999956e-01 -3.68934881e+19 -1.23999989e+00 2.00000000e+00 -9.54999983e-01 -3.68934881e+19 -1.33699989e+00 -0.00000000e+00 1.01899993e+00 2.00000000e+00 1.77674997e+00 -1.08420217e-19 -1.50099993e+00 0.00000000e+00 1.63150001e+00 -2.00000000e+00 -1.26099992e+00 -3.68934881e+19 -9.38999951e-01 -0.00000000e+00 -1.55999994e+00 -0.00000000e+00 -1.26899993e+00 -2.00000000e+00 1.99537492e+00 3.68934881e+19 -1.69799995e+00 0.00000000e+00 1.94987500e+00 -3.68934881e+19 -1.25299990e+00 -3.68934881e+19 -8.13999951e-01 -2.00000000e+00 -1.68049991e+00 2.00000000e+00 -1.53499997e+00 -0.00000000e+00 2.19074988e+00 1.08420217e-19 -1.82924998e+00 3.68934881e+19 2.13599992e+00 -3.68934881e+19 -1.23999989e+00] I can't seem to figure what I am doing wrong. Would appreciate a third eye. Thank you!

Viewing all articles
Browse latest Browse all 99

Trending Articles



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