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

How to extract and save the position information from nav_msgs to a text file

asked 2019-03-22 14:59:30 -0500

manuelmelvin gravatar image

updated 2019-03-22 16:51:24 -0500

I have a topic published named "cmd_local_waypoints" with two waypoints where the robot to go. I need to extract the X and Y position information from the topic and need to save it to a text file. The terminal response is shown below. You can see two position information available in the topic. I need to save it to a text file

Thanks in advance

header: 
  seq: 2219
  stamp: 
    secs: 17116
    nsecs: 995000000
  frame_id: ''
poses: []
---
header: 
  seq: 2220
  stamp: 
    secs: 17117
    nsecs:  14000000
  frame_id: base_link
poses: 
  - 
    header: 
      seq: 0
      stamp: 
        secs: 17117
        nsecs:  14000000
      frame_id: base_link
    pose: 
      position: 
        x: -2.32830643654e-05
        y: -2.32830643654e-05
        z: -2.32830643654e-05
      orientation: 
        x: 3.4668537268e-310
        y: 3.46685372677e-310
        z: 0.0
        w: 1.0
  - 
    header: 
      seq: 0
      stamp: 
        secs: 17117
        nsecs:  14000000
      frame_id: base_link
    pose: 
      position: 
        x: -2.32830643654e-05
        y: -2.32830643654e-05
        z: -2.32830643654e-05
      orientation: 
        x: 3.46686898944e-310
        y: 3.46688499512e-310
        z: 0.0
        w: 1.0
edit retag flag offensive close merge delete

Comments

Please don't use an image to display text. Copy and paste the text from the image to your question instead.

jayess gravatar image jayess  ( 2019-03-22 15:51:46 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-03-22 17:43:46 -0500

The same way you would in any other situation with a set of numbers you'd like to save to a file, how would you go about that? You could serialize the ROS message, but that doesn't sound like what you really want, you just want numbers. You can stream them to a file and save the file. Just access what you want from the message class and write to file in whatever way makes sense to you.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-03-22 14:59:30 -0500

Seen: 477 times

Last updated: Mar 22 '19