debug

Β 
#include <iostream> #include <boost/asio.hpp> #include "livox_lidar_api.h" #include "livox_lidar_def.h" using boost::asio::ip::udp; const std::string SERVER_IP = "192.168.0.102"; // 쀑앙 μ„œλ²„ IP const int SERVER_PORT = 12345; // 쀑앙 μ„œλ²„ 포트 // UDP μ†ŒμΌ“ μ„€μ • boost::asio::io_context io_context; udp::socket socket(io_context, udp::endpoint(udp::v4(), 0)); udp::endpoint server_endpoint(boost::asio::ip::address::from_string(SERVER_IP), SERVER_PORT); // LiDAR 데이터 콜백 ν•¨μˆ˜ void PointCloudCallback(uint32_t handle, const uint8_t dev_type, LivoxLidarEthernetPacket* data, void* client_data) { if (data == nullptr || data->data_type != kLivoxLidarCartesianCoordinateHighData) { return; } auto* points = reinterpret_cast<const LivoxLidarCartesianHighRawPoint*>(data->data); size_t point_count = data->length / sizeof(LivoxLidarCartesianHighRawPoint); // 데이터λ₯Ό μ§λ ¬ν™”ν•˜μ—¬ 전솑 std::vector<uint8_t> serialized_data(reinterpret_cast<const uint8_t*>(points), reinterpret_cast<const uint8_t*>(points) + data->length); try { socket.send_to(boost::asio::buffer(serialized_data), server_endpoint); std::cout << "Sent " << serialized_data.size() << " bytes to server." << std::endl; } catch (std::exception& e) { std::cerr << "Error sending data: " << e.what() << std::endl; } } int main(int argc, const char* argv[]) { if (argc != 2) { std::cerr << "Usage: " << argv[0] << " <config_path>" << std::endl; return -1; } const std::string config_path = argv[1]; if (!LivoxLidarSdkInit(config_path.c_str())) { std::cerr << "Failed to initialize Livox SDK." << std::endl; return -1; } SetLivoxLidarPointCloudCallBack(PointCloudCallback, nullptr); std::this_thread::sleep_for(std::chrono::seconds(30)); LivoxLidarSdkUninit(); return 0; }
Β