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

how to read a text file and publish the data

asked 2016-06-05 14:14:11 -0500

naqi.nick gravatar image

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

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-06-09 21:13:50 -0500

janindu gravatar image

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.

edit flag offensive delete link more

Comments

thank you for your reply can u plz explain how can i read a file too?

naqi.nick gravatar image naqi.nick  ( 2016-06-10 05:07:28 -0500 )edit

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.

janindu gravatar image janindu  ( 2016-06-13 18:47:32 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2016-06-05 14:14:11 -0500

Seen: 2,197 times

Last updated: Jun 09 '16