使用天准TADC-D52在TROS.A中读取速腾M1激光雷达的点云数据

前言

使用RJ45读取激光雷达的点云数据不是一件难事,但是为了确保项目硬件连接的可靠性,我们选择使用T口进行车规级的连接。

速腾M1

速腾M1的T口使用的连接器是安费诺的口
在这里插入图片描述

天准TADC-D52

域控这边的口用的是泰科的口
在这里插入图片描述

将雷达和域控连接起来

首先我们需要明确,与普通标准以太网不同,车载以太网是分主从的。由于在默认情况下,域控和雷达的ETH口都是master模式,所以我们选择把雷达的网口改成slave。
在连接上雷达后,使用ucode修改雷达模式
在这里插入图片描述
安费诺的口和泰科的口不能直接连接,故需要转接线
在这里插入图片描述
硬件连接如下
在这里插入图片描述

读取点云数据

硬件连接好后,先试试能不能ping通
这里雷达的源ip为192.168.55.200,目的ip为192.168.55.100
在这里插入图片描述
确认网络正常后,使用天准提供的SDK在TROS.A中读取并发布数据
天准的雷达sdk
在这里插入图片描述
自己写个小demo订阅雷达数据
在这里插入图片描述
订阅代码如下

#include <iostream>
#include <thread>
#include <chrono>
#include <protocol/lidar.pb.h>
#include "communication/subscriber.h"


using hobot::communication::CommAttr;
using hobot::communication::ParticipantAttr;
using hobot::communication::Subscriber;
using hobot::communication::PROTOCOL_ZMQ_TCP;
using hobot::communication::PROTOCOL_COMPOSITE;
using hobot::communication::ProtoMsg;
using hobot::communication::ProtobufSerializer;

using LidarProtoMsg = ProtoMsg<LidarProto::LidarFrame>;

using LidarProtoSerializer = ProtobufSerializer<LidarProto::LidarFrame>;

struct VPoint {
  float x;
  float y;
  float z;          // quad-word XYZ
  uint8_t intensity;  // laser intensity reading
  uint16_t ring;  // laser ring
  int32_t timestamp;  // point timestamp
};


static void LidarSubCallback(
    const std::shared_ptr<LidarProtoMsg> &msg) {
  std::cout << "received lidar msg info:" << std::endl;
  std::cout << "header_stamp =  " << msg->proto.header().stamp()<< std::endl;
//   std::cout << "data = " << msg->GetData()->GetData() << std::endl;
    uint32_t pcl_cnt = msg->GetData()->GetDataSize() / sizeof(VPoint);
    const VPoint* data = reinterpret_cast<VPoint*>
    (msg->GetData()->GetData());
    if (data == nullptr) {
        std::cout << "data is nullptr" << std::endl;
        return;
    }
    for (uint32_t i = 0; i < pcl_cnt; ++i) {
    std::cout << "x: "<< data[i].x<< std::endl;
    std::cout << "y: "<< data[i].y<< std::endl;
    std::cout << "z: "<< data[i].z<< std::endl;
    }
  
}

int main() {

    hobot::communication::Init("communication.json");
    CommAttr comm_attr;
    comm_attr.participant_attrs_.push_back(ParticipantAttr{2});
    std::string topic = "lidar_3";
    std::shared_ptr<Subscriber<LidarProtoSerializer>> subscriber;

    subscriber = Subscriber<LidarProtoSerializer>::New(
        comm_attr, topic, 0, LidarSubCallback, PROTOCOL_ZMQ_TCP);
        
    while (1) {
        std::this_thread::sleep_for(std::chrono::milliseconds(1000));
        std::cout << "subscriber is running ..." << std::endl;
    }

    return 0;
}

  • 10
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值