银河麒麟v10版本OpenDDS使用教程

1. DDS安装


请参考博主的另一篇文章:https://blog.csdn.net/SuperYang_/article/details/130396183

2. IDL编写


创建Message.idl文件, 内容如下

module Messenger {
    @topic
    struct Message {
        string from;
        string subject;
        @key long subject_id;
        string text;
        long count;
    };
};

3. IDL处理


3.1 tao_idl & opendds_idl命令处理
tao_idl --idl-version 4 Message.idl
opendds --idl-version 4 Message.idl
tao_idl --idl-version 4 MessageTypeSupport.idl

[ps]:如果第三步报错找不到dds/[xxx].idl, 可以加上-I选项指定idl包含目录,如:

tao_idl -I $DDS_ROOT --idl-version 4 MessageTypeSupport.idl)

[ps]:处理过程中可能报警告error in lookup of symbol: topic, 这个不影响最终生成效果, 有强迫症的话可以加上警告忽略选项 --unknown-annotations ignore -as -Sa -St, 如:

tao_idl --idl-version 4 --unknown-annotations ignore -as -Sa Message.idl
3.2 mwc.pl命令处理(官方推荐)

1> 编写mpc文件, 如:

project(*idl): dcps {
    requires += no_opendds_safety_profile
    TypeSupport_Files {
        Messenger.idl
    }

    custom_only = 1
}

project(*publisher) : dcpsexe, dcps_tcp, dcps_rtps_udp {
    requires += no_opendds_safety_profile
    exename   = publisher
    after    += *idl

    TypeSupport_Files {
        Messenger.idl
    }

    Source_Files {
        Publisher.cpp
    }
}

project(*subscriber) : dcpsexe, dcps_tcp, dcps_rtps_udp {
    requires += no_opendds_safety_profile
    exename   = subscriber
    after    += *publisher

    TypeSupport_Files {
        Messenger.idl
    }

    Source_Files {
        DataReaderListenerImpl.cpp
        Subscriber.cpp
    }
}

2> 命令编译生成

mwc.pl -type make   # 生成MakeFile
mwc.pl -type cmake  # 生成CMakeLists.txt
mwc.pl -type gnuace # 生成GNUMakeFile

4. 编译


1> 生成的是make或GNUMake工程直接make编译即可
2> 生成的是cmake工程编译过程如下:

mkdir build
cd build
cmake ..
make

5. DCPS集中发现


1> 新建repo.ior文件
2> 配置ini, 以官方DevGuideExamples/DCPS/message为例, 可在目录下建立message.ini配置文件, 内容如下

[common]
DCPSDebugLevel = 0
DCPSInfoRepo = corbaloc::127.0.0.1:12345/DCPSInfoRepo
DCPSGlobalTransportConfig = dcpstransport

[config/config1]
transports = tcp1

[transport/tcp1]
transport_type = tcp

3> 启动DCPS仓库

DCPSInfoRepo -ORBListenEndpoints iiop://127.0.0.1:12345

4> 启动订阅端

./subscriber -DCPSConfigFile message.ini

5> 启动发布端

./publisher -DCPSConfigFile message.ini

[ps]官方文档上提供的方式为

DCPSInfoRepo -o repo.ior
./subscriber -DCPSInfoRepo file://repo.ior
./publisher -DCPSInfoRepo file://repo.ior

6. RTPS对等发现


1> 编写rtps.ini配置文件, 内容如下:

[common]
DCPSDefaultDiscovery=DEFAULT_RTPS
DCPSGlobalTransportConfig=$file

[transport/the_rtps_transport]
transport_type=rtps_udp

2> 运行发布端、订阅端

./subscriber -DCPSConfigFile rtps.ini
./publisher -DCPSConfigFile rtps.ini
  • 5
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

SuperYang_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值