You should download this project on your own in section B2.
.
└── 2_hello_world
│ hello_world.idl
├─c++11
│ application.hpp
│ hello_world_publisher.cxx
│ hello_world_subscriber.cxx
│ USER_QOS_PROFILES.xml
├─c++98
├─csharp
└─python
-
OS: Windows 10/11
-
IDE: Visual Studio 2017 (with
Windows 10 SDK 10.0.17134.0
) -
Fill in the form at Try Connext for Free. Download the
.exe
file. -
Follow the instructions at Installing an Evaluation or LM Version.
- Run the
.exe
file downloaded.
- Run the
-
(Follow the instructions at 2.2. Hands-On 1: Your First DataWriter and DataReader) Open a command prompt window. Run command
<installdir>\resource\scripts\rtisetenv_<architecture>.bat
. For example:C:\Program Files\rti_connext_dds-<version>\resource\scripts\rtisetenv_x64Win64VS2017.bat
. -
Inside the repository you have cloned, there is a directory named
2_hello_world
, which contains the HelloWorld type definition in a file namedhello_world.idl
. You can run following commands:cd 2_hello_world rtiddsgen -language c++11 -platform <architecture> -create makefiles -create typefiles -d c++11 -ppDisable hello_world.idl
-
Open the
c++11
directory to review the code. -
In the
2_hello_world/c++11
directory, openhello_world_publisher.cxx
in your IDE of choice. -
Change the Topic name from “Example HelloWorld” to “HelloWorld Topic”:
// A Topic has a name and a datatype. Create a Topic named // "HelloWorld Topic" with type HelloWorld dds::topic::Topic<HelloWorld> topic(participant, "HelloWorld Topic");
-
Modify the code to send the message “Hello world!” with a count. In the for loop in the snippet, add the highlighted line, just after the comment
// Modify the data to be written here
. This will set sample.msg to “Hello world!” with a count:// Create data sample for writing HelloWorld sample; for (int count = 0; running && (count < sample_count || sample_count == 0); count++) { // Modify the data to be written here sample.msg("Hello world! " + std::to_string(count)); std::cout << "Writing HelloWorld, count " << count << std::endl; writer.write(sample); rti::util::sleep(dds::core::Duration(4)); }
-
Open
hello_world_subscriber.cxx
. Change the Topic name from “Example HelloWorld” to “HelloWorld Topic”, just as you did in the publishing application.// A Topic has a name and a datatype. Create a Topic named // "HelloWorld Topic" with type HelloWorld dds::topic::Topic<HelloWorld> topic(participant, "HelloWorld Topic");
-
Launch Visual Studio by typing hello_world-x64Win64VS2017.sln in the Command Prompt window.
-
Select Build Solution from the Build menu. (You can also right-click
hello_world_publisher
orhello_world_subscriber
and chooseBuild
; do for each.) -
Make sure you have run
rtisetenv_<architecture>
in any new command prompt window, to avoid issues with paths and licensing. From within the2_hello_world/c++11
directory, enter the following full path using the SAME command prompt window:objs\<architecture>\hello_world_publisher.exe
-
Open another command prompt window, run
rtisetenv_<architecture>
if you haven’t already in that window, and from within the2_hello_world/c++11
directory, enter the following full path:objs\<architecture>\hello_world_subscriber.exe
-
You should see this in the window:
Writing HelloWorld, count 0 ... --- HelloWorld subscriber sleeping for 4 sec... [msg: Hello world! 1] ...
Succeed!
Note: FastDDS and RTI Connext DDS use the same structure in the .idl
file to generate their own codes, and use the same topic; you can open Publisher
in one DDS and Subscriber
in another DDS (as long as the DDS of both manufacturers comply with OMG's communication specifications, they could work together under the DSCP model).