question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ros2 topic echo /odom covariance is unclear

See original GitHub issue

Bug report

Required Info:

  • Operating System: Ubuntu20.04
  • Installation type: binaries
  • Version or commit hash: ROS2 Foxy
  • DDS implementation:
  • Client library (if applicable):

Steps to reproduce issue

ros2 topic echo /odom

Expected behavior

The covariance should line up horizontally so we can see it clearer. But they’re actually arranged vertically.

Actual behavior

header:
  stamp:
    sec: 1
    nanosec: 639623972
  frame_id: /world
child_frame_id: /quadrotor
pose:
  pose:
    position:
      x: 0.0
      y: 0.0
      z: 0.0
    orientation:
      x: 0.0
      y: 0.0
      z: 0.0
      w: 1.0
  covariance:
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
twist:
  twist:
    linear:
      x: 0.0
      y: 0.0
      z: 0.0
    angular:
      x: 0.0
      y: 0.0
      z: 0.0
  covariance:
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
  - 0.0
---

Additional information


Feature request

Feature description

Implementation considerations

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
iuhilnehc-ynoscommented, Dec 17, 2021

vertically, horizontally

Just adding the default_flow_style=True to yaml.dump could work.

or with some stride

I tried to add yaml.add_representer(list, __represent_list), but it doesn’t work. After trying to add a new Ros2Dumper derived from yaml.Dumper, and overwrite the expect_node method (unmaintainable), it seems to work as expected. Using stride = 8 as following,

child_frame_id: base_footprint
pose:
  pose:
    position:
      x: -1.987142582426784
      y: -0.4948242098096342
      z: 0.008726311344861208
    orientation:
      x: -0.00029216596084799025
      y: 0.0007255788333816825
      z: 0.3837788667705221
      w: 0.9234246962231094
  covariance: [
    1.0e-05, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0e-05,
    0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1000000000000.0, 0.0,
    0.0, 0.0, 0.0, 0.0, 0.0, 1000000000000.0, 0.0, 0.0,
    0.0, 0.0, 0.0, 0.0, 1000000000000.0, 0.0, 0.0, 0.0,
    0.0, 0.0, 0.0, 0.001]
twist:
  twist:
    linear:
      x: 6.673055220339329e-05
      y: 1.066510747665083e-05
      z: 0.0
    angular:
      x: 0.0
      y: 0.0
      z: -0.00030110521608306537
  covariance: [
    1.0e-05, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0e-05,
    0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1000000000000.0, 0.0,
    0.0, 0.0, 0.0, 0.0, 0.0, 1000000000000.0, 0.0, 0.0,
    0.0, 0.0, 0.0, 0.0, 1000000000000.0, 0.0, 0.0, 0.0,
    0.0, 0.0, 0.0, 0.001]

(Updated: make sure no more extra indent)

So I think we can provide two extra options to users,

'--show-list-pretty' 
    True : it shows [item, item2, ..., itemn]
    False : it shows
         - item
         - item2
         - ...
         - itemn
'--list-stride':
   Number: effective only if '--show-list-pretty' is True.
1reaction
RENyunfancommented, Dec 17, 2021

Please refer to #680 (comment)

Thanks, I’d like to post the detailed steps below for anyone who has the same problem. In /opt/ros/foxy/lib/python3.8/site-packages/rosidl_runtime_py/convert.py, line 66-94, add a param in line 93 will work.

def message_to_yaml(
    msg: Any,
    *,
    truncate_length: int = None,
    no_arr: bool = False,
    no_str: bool = False
) -> str:
    """
    Convert a ROS message to a YAML string.

    :param msg: The ROS message to convert.
    :param truncate_length: Truncate values for all message fields to this length.
        This does not truncate the list of message fields.
    :param no_arr: Exclude array fields of the message.
    :param no_str: Exclude string fields of the message.
    :returns: A YAML string representation of the input ROS message.
    """
    global __yaml_representer_registered

    # Register our custom representer for YAML output
    if not __yaml_representer_registered:
        yaml.add_representer(OrderedDict, __represent_ordereddict)
        __yaml_representer_registered = True

    return yaml.dump( 
        message_to_ordereddict(
            msg, truncate_length=truncate_length, no_arr=no_arr, no_str=no_str),
        allow_unicode=True, width=sys.maxsize, default_flow_style=True,
    )
Read more comments on GitHub >

github_iconTop Results From Across the Web

Exercise 2.4 question - working with messages and ros1_bridge
I can see the topic if I issue: rostopic list tho. Is just the ros2 command doesnt get the whole list of topics?...
Read more >
robot_pose_ekf does not publish anything - ROS Answers
I had a similar issue the answer was to delete the "/" at the beginning of the topic name. rostopic echo robot_pose_ekf/odom_combined.
Read more >
ros2 topic echo doesn't print arrays correctly #213 - GitHub
ros2 topic echo doesn't print arrays correctly · Issue #213 · ros2/ros2cli · GitHub.
Read more >
robot_pose_ekf won't publish any messages
Hi, can you echo your IMU topic because the error is coming due to the zero covariance matrix of your IMU data. –...
Read more >
[ROS Q&A] 196 - How to Output Odometry Data - The Construct
Otherwise, it would print continuously until you press Ctrl + C. user:~$ rostopic echo /odom -n1 header: seq: 4732 stamp: secs: 236 nsecs:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found