-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add debug_publisher to let user to echo value for training(LiDAR data, reward...)
- Loading branch information
1 parent
be8983a
commit 5153955
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import rclpy | ||
from rclpy.node import Node | ||
from std_msgs.msg import String | ||
|
||
class DebugPublisher(Node): | ||
def __init__(self): | ||
super().__init__('debug_publisher') | ||
self.debug_pub = self.create_publisher(String, 'debug_info', 10) | ||
|
||
def publish_debug_info(self, scan_data, action, reward, done): | ||
# Truncate scan data for display and round for clarity | ||
scan_str = ', '.join([f'{x:.2f}' for x in scan_data[:10]]) | ||
action_str = ', '.join([f'{x:.2f}' for x in action]) | ||
|
||
# Format the message | ||
debug_msg = String() | ||
debug_msg.data = ( | ||
f"Scan Data: [{scan_str}]...\n" | ||
f"Action: [{action_str}]\n" | ||
f"Reward: {reward:.2f}\n" | ||
f"Done: {done}\n" | ||
"==============================" | ||
) | ||
|
||
self.debug_pub.publish(debug_msg) |