LCM中C++的API介绍

LCM支持多种语言,也有很多版本,这里只介绍C++的几个类以及方法。

类型简介

C++的API,LC提供了三个类以及两个结构体来封装LCM,他们分别是:

    class   lcm::LCM
    struct  lcm::ReceiveBuffer
    class   lcm::Subscription
    struct  lcm::LogEvent
    class   lcm::LogFile

两个struct是配合类来使用的。前三个可以看成一组,后面两个是配合使用的。

lcm::ReceiveBuffer

这个结构体很眼熟,就是我们需要写的回调函数的第一个参数的指针类型,先看一下其定义:

/**
 * @brief Stores the raw bytes and timestamp of a received message.
 *
 * @headerfile lcm/lcm-cpp.hpp
 */
struct ReceiveBuffer {
    /**
     * Message payload data, represented as a raw byte buffer.
     */
    void *data;
    /**
     * Length of message payload, in bytes.
     */
    uint32_t data_size;
    /**
     * Timestamp identifying when the message was received.  Specified in
     * microseconds since the UNIX epoch.
     */
    int64_t recv_utime;
};

只有三个成员,data是我们的接收到的数据转换成字节流后的指针,也就是recvfrom调用收到的原始数据,第二个成员是数据大小,第三个是接收到数据时的时间戳。(LCM内部使用,我们一般不会用到)

lcm::Subscription

这个类其实是一个与文件描述符类似的东西,先看定义:

class Subscription {
    public:
        virtual ~Subscription() {}

        /**
         * @brief Adjusts the maximum number of received messages that can be
         * queued up for this subscription.
         *
         * @param num_messages the maximum queue size, in messa
  • 4
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值