how to read a text file and publish the data
i am trying to read a file.txt in my home directory and publish the integer value extracted from the file how can i do that can someone help plz
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
i am trying to read a file.txt in my home directory and publish the integer value extracted from the file how can i do that can someone help plz
Follow the tutorial in Publishers and Subscribers to learn how to publish a message.
After that, follow these simple steps.
Step 1 : Read integers from file and store them in an array / vector
Step 2 : Advertise a publisher to a topic of your preference with message type std_msgs/Int64.msg
ros::Publisher pub = nh.advertise<std_msgs::Int64>("topic_name", 5);
Step 3 : Iterate through your integer array/vector and publish them.
Reading from a file depends on the programming language and perhaps the platform.
Clear examples are included here : http://www.cplusplus.com/doc/tutorial...
Good luck! And sorry it took me 4 days to reply. It was a long weekend here in Aus and I took some time away from all my gadgets.
Asked: 2016-06-05 14:14:11 -0500
Seen: 2,377 times
Last updated: Jun 09 '16