String formatting for ros2 topic echo
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 262
- Forks
- 228
- Avg merge
- 23h 15m
- Merged PRs (30d)
- 12
Description
Bug report
Required Info:
- Operating System:
- Ubuntu 18.04
- Installation type:
- Binaries & Source
- Version or commit hash:
- 72961082678fa3491b2cf778dc004bf820cd4c7c
- DDS implementation:
- Default
- Client library (if applicable):
- N/A
Steps to reproduce issue
Talker:
#!/usr/bin/env python3
import rclpy
import rclpy.node
import std_msgs.msg as std_msgs
class Talker(rclpy.node.Node):
def __init__(self):
super().__init__('talker')
self.pub = self.create_publisher(std_msgs.String, 'chatter')
timer_period = 1.0
self.tmr = self.create_timer(timer_period, self.timer_callback)
self.toggle = False
self.msg_with_newlines = std_msgs.String(
data="Dude\nand\nDudettes"
)
self.msg_with_escape_sequences = std_msgs.String(
data="\x1b[34mDude\x1b[0m\nand\nDudettes"
)
def timer_callback(self):
msg = std_msgs.String()
if self.toggle:
msg = self.msg_with_escape_sequences
else:
msg = self.msg_with_newlines
self.toggle = not self.toggle
print("-----------\n{}".format(msg.data))
self.pub.publish(msg)
if __name__ == '__main__':
rclpy.init()
node = Talker()
try:
rclpy.spin(node)
except KeyboardInterrupt:
pass
node.destroy_node()
rclpy.shutdown()
Execution:
# In a first shell
$ ./talker
# in a second shell
$ ros2 topic echo /chatter
data: 'Dude
and
Dudettes'
data: "\e[34mDude\e[0m\nand\nDudettes"
Expected behavior
String formatting that pays attention to newlines, tabs, console sequences etc (as per ROS1).
Actual behavior
No string formatting at all.
Additional information
This is especially useful in publishers of the std_msgs.msg.String variety which exist to describe the runtime system or to provide introspective data about a module formatted in some clean, easy to read way.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the implementation behind the ros2 topic echo command and reproduce the issue with the provided Python talker. Compare its current output with the expected ROS1-style rendering, then verify handling of newlines, tabs, and console escape sequences.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100