Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(hw_interface): write packet data directly into the message #102

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,9 @@ void HesaiHwInterface::ReceiveCloudPacketCallback(const std::vector<uint8_t> & b
PrintDebug("Invalid Packet: " + std::to_string(buffer.size()));
return;
}
uint32_t buffer_size = buffer.size();
std::array<uint8_t, MTU_SIZE> packet_data{};
std::copy_n(std::make_move_iterator(buffer.begin()), buffer_size, packet_data.begin());
const uint32_t buffer_size = buffer.size();
pandar_msgs::msg::PandarPacket pandar_packet;
pandar_packet.data = packet_data;
std::copy_n(std::make_move_iterator(buffer.begin()), buffer_size, pandar_packet.data.begin());
pandar_packet.size = buffer_size;
auto now = std::chrono::system_clock::now();
auto now_secs = std::chrono::duration_cast<std::chrono::seconds>(now.time_since_epoch()).count();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,13 @@ Status VelodyneHwInterface::RegisterScanCallback(
void VelodyneHwInterface::ReceiveCloudPacketCallback(const std::vector<uint8_t> & buffer)
{
// Process current packet
uint32_t buffer_size = buffer.size();
std::array<uint8_t, 1206> packet_data{};
std::copy_n(std::make_move_iterator(buffer.begin()), buffer_size, packet_data.begin());
const uint32_t buffer_size = buffer.size();
velodyne_msgs::msg::VelodynePacket velodyne_packet;
std::copy_n(std::make_move_iterator(buffer.begin()), buffer_size, velodyne_packet.data.begin());
auto now = std::chrono::system_clock::now();
auto now_secs = std::chrono::duration_cast<std::chrono::seconds>(now.time_since_epoch()).count();
auto now_nanosecs =
std::chrono::duration_cast<std::chrono::nanoseconds>(now.time_since_epoch()).count();
velodyne_packet.data = packet_data;
velodyne_packet.stamp.sec = static_cast<int>(now_secs);
velodyne_packet.stamp.nanosec = static_cast<std::uint32_t>(now_nanosecs % 1'000'000'000);
scan_cloud_ptr_->packets.emplace_back(velodyne_packet);
Expand Down
Loading