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,197 times
Last updated: Jun 09 '16
Building map (map_saver) not working with user-made bag files
Can't read bagfile containing custom messages
can "rosbag filter" create a new bag file with multiple topics within it?
simultaneous Rosbag record and playback
"rosbag record" vs "rosbag::Bag"
Error while writing from bag file to csv
human pose estimation from a bag file
How to send a complex request and save a complex response (service) in ROS?