Git Product home page Git Product logo

opensplice_boilerplate's Introduction

opensplice_boilerplate Build Status

This package allows a user to create multiple instances of publisher and subscriber within one node. The API supports instances of different message types defined in an IDL file.

Adding new IDL file:

  1. Add your own idl file in the idl folder.

  2. Generate the codes:

    $ ./gencode

This script will auto:

  • Generate the DDS codes for the idl files you have created.
  • Generate boilerplates specific to the message type so you can use the API.
  • Generate a CMakeLists.txt for the boilerplates. This must be included in the main CMakeLists.txt so you can use it in the API. See No.3 .
  1. Add the generated codes and boilerplates in the main CMakeLists.txt:

     include(lib/boilerplate/types/Template/CMakeLists.txt)
     include(lib/boilerplate/types/Sensor/CMakeLists.txt)
    
     ADD_LIBRARY (MGR_SRC
             lib/boilerplate/template/CheckStatus.cpp
             lib/boilerplate/template/Participant.cpp
             ${Sensor}
             ${Template}
     )
    

Using the API:

  1. Include your new message type's header files:

     #include "Template.h"
     #include "Sensor.h"
    
  2. Create participant:

     Participant par("Node Name", DOMAIN_ID);
    
  3. Creating a Publisher. Remember to add "Msg" when calling the namespace ie. Msg:

     SensorMsg::Publisher pub(par, (char*)"HelloWorldData_Msg2");
    

TemplateMsg can be any message based on the idl file you have created.

  1. Publish:

     //create message object
     Sensor testmsg;
     
     //populate the data
     testmsg.userID = 1;
     testmsg.message = DDS::string_dup("Hello World");
     
     //publish testmsg
     pub.publish(testmsg);
    
  2. Creating a Subscriber. Remember to add "Msg" when calling the namespace ie. Msg:

     SensorMsg::Subscriber sub(par, (char*)"HelloWorldData_Msg2");
    

TemplateMsg can be any message based on the idl file you have created.

  1. Subscribing and receiving data:

     sub.read();        
     for (DDS::ULong j = 0; j < sub.msg_list.length(); j++)
     {
         cout << "=== [Subscriber] message received :" << endl;
         cout << "    userID  : " << sub.msg_list[j].userID << endl;
         cout << "    Message : \"" << sub.msg_list[j].message << "\"" << endl;
     }    
    

opensplice_boilerplate's People

Contributors

grassjelly avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.