Skip to content

Add script to export NebulaPacket topics from ROS2 bags to PCAP#455

Draft
manato wants to merge 2 commits into
mainfrom
codex/check-access-to-previous-conversation-duujme
Draft

Add script to export NebulaPacket topics from ROS2 bags to PCAP#455
manato wants to merge 2 commits into
mainfrom
codex/check-access-to-previous-conversation-duujme

Conversation

@manato

@manato manato commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Motivation

  • Provide a standalone tool to share Nebula LiDAR packet captures with non-ROS consumers by converting nebula_msgs/msg/NebulaPacket and nebula_msgs/msg/NebulaPackets topics from ROS 2 bags into classic .pcap files.
  • Allow downstream tools to receive synthesized Ethernet/IPv4/UDP frames with configurable addresses, ports, MACs, and optional UDP checksum computation because packet payloads lack original transport metadata.

Description

  • Add scripts/nebula_rosbag_to_pcap.py, a CLI script that opens a ROS 2 bag with rosbag2_py, deserializes target topic messages, and exports each NebulaPacket.stamp as the PCAP packet timestamp.
  • Reconstruct synthetic network layers by building UDP segments, IPv4 headers (with computed IPv4 checksum), and Ethernet frames, then write a classic PCAP file with little-endian microsecond resolution and DLT_EN10MB link type via the PcapWriter class.
  • Provide CLI options including --list-topics, --src-ip, --dst-ip, --src-port, --dst-port, --src-mac, --dst-mac, and --udp-checksum (choices zero or compute), with validation for ports and MAC parsing.
  • Track conversion statistics (messages read, packets exported, empty/dropped packets, non-monotonic timestamps) and refuse to finish with zero exported packets.

Example usage

# Find candidate Nebula packet topics in a bag.
python3 scripts/nebula_rosbag_to_pcap.py \
  --bag /path/to/rosbag \
  --list-topics

# Export a selected topic to PCAP with the default LiDAR-oriented network
# profile.
python3 scripts/nebula_rosbag_to_pcap.py \
  --bag /path/to/rosbag \
  --topic /sensing/lidar/front/nebula_packets \
  --output /tmp/front_lidar.pcap

Testing

  • No automated tests were added or executed for this change.

Codex Task

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a standalone CLI tool to export Nebula LiDAR packet topics from a ROS 2 bag into a classic Ethernet (DLT_EN10MB) .pcap, synthesizing Ethernet/IPv4/UDP headers around each NebulaPacket.data payload and timestamping packets with NebulaPacket.stamp.

Changes:

  • Introduces scripts/nebula_rosbag_to_pcap.py to read a ROS 2 bag via rosbag2_py, deserialize nebula_msgs/msg/NebulaPacket(s), and emit a classic PCAP file.
  • Implements packet/frame construction (UDP, IPv4 with header checksum, Ethernet) plus optional UDP checksum computation and basic conversion statistics reporting.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +169 to +171
self._fh = path.open("wb")
# Classic PCAP little-endian, microsecond resolution, DLT_EN10MB.
self._fh.write(struct.pack("<IHHIIII", 0xA1B2C3D4, 2, 4, 0, 0, 65535, 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants