Publish messages from a .csv file the appropriate way
Hello all,
I extracted data from the GPS topic in my recorded bag file into a .csv file. I then modified the lat,lon values to create fake data as desire. Now I want to write a node to publish that modified data to mapviz.
What I expect to do is (with Python API):
- Parse the .csv file into a junk of NavSatFix data object
- Loop through that object to publish each messages (similar to each row in the .csv at first)
But I haven't found any tutorial with similar idea. Most of them performs something like
def talker():
print('in talker')
pub = rospy.Publisher('GPS', NavSatFix, queue_size=10)
rospy.init_node('GPStalker', anonymous=True)
while not rospy.is_shutdown():
#Assuming that parse will return these values
time.sleep(1)
# build navsat message
fake_gps = NavSatFix()
fake_gps.header.frame_id = ''
fake_gps.header.stamp = rospy.Time.now()
fake_gps.status.status = 1
fake_gps.status.service = 2
fake_gps.latitude = 3
fake_gps.longitude = 4
fake_gps.altitude = 5
pub.publish(fake_gps)
My question is, is there a way to implement my idea? Is it efficient? Can you give me some documents or tutorials?
Hello,
Can you please! tell me the columns and how many rows of your CSV file?
Hi @Ranjit,
My csv file has 15 columns:
rosbagTimestamp,header,seq,stamp,secs,nsecs,frame_id,status,status,service,latitude,longitude,altitude,position_covariance,position_covariance_type
and 352 rows, including the headers.