Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge master into develop #704

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/connext_dds/remote_procedure_call/py/Inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# damages arising out of the use or inability to use the software.
#

from abc import ABC
from dataclasses import field
from typing import Sequence
import rti.idl as idl
Expand All @@ -32,7 +33,7 @@ class UnknownItemError(Exception):


@rpc.service
class InventoryService:
class InventoryService(ABC):
@rpc.operation
def get_inventory(self) -> InventoryContents:
"""Get the current inventory inventory"""
Expand Down
85 changes: 38 additions & 47 deletions tutorials/application_design/VehicleModeling.xml
Original file line number Diff line number Diff line change
@@ -1,76 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="https://community.rti.com/schema/7.3.0/rti_dds_profiles.xsd" type="application/xml" schematypens="http://www.w3.org/2001/XMLSchema"?>
<dds>
<dds xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://community.rti.com/schema/current/rti_dds_profiles.xsd">
<types>
<const name="VIN_LENGTH" type="uint8" value="17"/>
<typedef name="VIN" type="string" stringMaxLength="VIN_LENGTH"/>

<const name="VIN_LENGTH" type="uint8" value="17" />
<typedef name="VIN" type="string" stringMaxLength="VIN_LENGTH" />
<struct name="Coord" extensibility="final" nested="true">
<member name="lat" type="float64"/>
<member name="lon" type="float64"/>
<member name="lat" type="float64" />
<member name="lon" type="float64" />
</struct>
<const name="VehicleTransitTopic" type="string" value="&quot;VehicleTransit&quot;" />
<struct name="VehicleTransit" extensibility="appendable">
<member name="vehicle_vin"
type="nonBasic"
nonBasicTypeName="VIN"
key="true" />
<member name="current_position"
type="nonBasic"
nonBasicTypeName="Coord" />
<member name="current_route"
type="nonBasic"
nonBasicTypeName="Coord"
sequenceMaxLength="-1"
optional="true" /> <!-- 'no route' == standby -->
<member name="vehicle_vin" type="nonBasic" nonBasicTypeName="VIN" key="true" />
<member name="current_position" type="nonBasic" nonBasicTypeName="Coord" />
<member name="current_route" type="nonBasic" nonBasicTypeName="Coord"
sequenceMaxLength="-1" optional="true" />
</struct>

<typedef name="Percentage" type="float64" min="0.0" max="100.0"/>
<typedef name="Percentage" type="float64" min="0.0" max="100.0" />
<const name="VehicleMetricsTopic" type="string" value="&quot;VehicleMetrics&quot;" />
<struct name="VehicleMetrics" extensibility="appendable">
<member name="vehicle_vin"
type="nonBasic"
nonBasicTypeName="VIN"
key="true"/>
<member name="fuel_level"
type="nonBasic"
nonBasicTypeName="Percentage"/>
<member name="vehicle_vin" type="nonBasic" nonBasicTypeName="VIN" key="true" />
<member name="fuel_level" type="nonBasic" nonBasicTypeName="Percentage" />
</struct>
</types>

<qos_library name="VehicleModeling_Library">
<qos_profile name="VehicleMetrics_Profile">
<datawriter_qos base_name="BuiltinQosLib::Generic.BestEffort">
<datareader_qos base_name="BuiltinQosLib::Generic.BestEffort">
<deadline>
<period>
<sec>10</sec>
<sec>15</sec>
<nanosec>0</nanosec>
</period>
</deadline>
</datawriter_qos>
<datareader_qos base_name="BuiltinQosLib::Generic.BestEffort">
</datareader_qos>
<datawriter_qos base_name="BuiltinQosLib::Generic.BestEffort">
<deadline>
<period>
<sec>15</sec>
<sec>10</sec>
<nanosec>0</nanosec>
</period>
</deadline>
</datareader_qos>
</datawriter_qos>
</qos_profile>
<qos_profile name="VehicleTransit_Profile">
<datawriter_qos base_name="BuiltinQosLib::Generic.StrictReliable">
<datareader_qos base_name="BuiltinQosLib::Generic.KeepLastReliable">
<durability>
<kind>TRANSIENT_LOCAL_DURABILITY_QOS</kind>
</durability>
</datawriter_qos>
<datareader_qos base_name="BuiltinQosLib::Generic.KeepLastReliable">
</datareader_qos>
<datawriter_qos base_name="BuiltinQosLib::Generic.StrictReliable">
<durability>
<kind>TRANSIENT_LOCAL_DURABILITY_QOS</kind>
</durability>
</datareader_qos>
</datawriter_qos>
</qos_profile>
</qos_library>

<domain_library name="DomainLibrary">
<domain name="VehicleDomain" domain_id="0">
<register_type name="VehicleMetrics" />
<register_type name="VehicleTransit" />
<topic name="VehicleMetricsTopic" register_type_ref="VehicleMetrics" />
<topic name="VehicleTransitTopic" register_type_ref="VehicleTransit" />
</domain>
Expand All @@ -80,24 +69,26 @@
<domain_participant name="PublisherApp" domain_ref="DomainLibrary::VehicleDomain">
<publisher name="Publisher">
<data_writer name="MetricsWriter" topic_ref="VehicleMetricsTopic">
<datawriter_qos base_name="VehicleModeling_Library::VehicleMetrics_Profile" />
<datawriter_qos base_name="VehicleModeling_Library::VehicleMetrics_Profile">
</datawriter_qos>
</data_writer>

<data_writer name="TransitWriter" topic_ref="VehicleTransitTopic">
<datawriter_qos base_name="VehicleModeling_Library::VehicleTransit_Profile" />
</data_writer>
</publisher>
<datawriter_qos base_name="VehicleModeling_Library::VehicleTransit_Profile">
</datawriter_qos>
</data_writer>
</publisher>
</domain_participant>

<domain_participant name="SubscriberApp" domain_ref="DomainLibrary::VehicleDomain">
<subscriber name="Subscriber">
<data_reader name="MetricsReader" topic_ref="VehicleMetricsTopic">
<datareader_qos base_name="VehicleModeling_Library::VehicleMetrics_Profile" />
<datareader_qos base_name="VehicleModeling_Library::VehicleMetrics_Profile">
</datareader_qos>
</data_reader>
<data_reader name="TransitReader" topic_ref="VehicleTransitTopic">
<datareader_qos base_name="VehicleModeling_Library::VehicleTransit_Profile" />
<datareader_qos base_name="VehicleModeling_Library::VehicleTransit_Profile">
</datareader_qos>
</data_reader>
</subscriber>
</subscriber>
</domain_participant>
</domain_participant_library>
</dds>
52 changes: 52 additions & 0 deletions tutorials/application_design/c++11/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#
# (c) 2024 Copyright, Real-Time Innovations, Inc. All rights reserved.
#
# RTI grants Licensee a license to use, modify, compile, and create derivative
# works of the Software. Licensee has the right to distribute object form
# only for use with RTI products. The Software is provided "as is", with no
# warranty of any type, including any warranty for fitness for any purpose.
# RTI is under no obligation to maintain or support the Software. RTI shall
# not be liable for any incidental or consequential damages arising out of the
# use or inability to use the software.
#

cmake_minimum_required(VERSION 3.11)
project(connext-tutorial-application-design)
list(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/../../../resources/cmake/Modules"
)
include(ConnextDdsConfigureCmakeUtils)
connextdds_configure_cmake_utils()

# Include ConnextDdsAddExample.cmake from resources/cmake
include(ConnextDdsAddExample)

connextdds_call_codegen(
TYPE_PATH "../VehicleModeling.xml"
LANG "C++11"
PREFIX "VehicleModeling"
)

connextdds_add_application(
TARGET VehicleModeling_publisher
LANG "C++11"
OUTPUT_NAME "publisher"
SOURCES
$<TARGET_OBJECTS:VehicleModeling_CXX11_obj>
"${CMAKE_CURRENT_SOURCE_DIR}/publisher.cxx"
DEPENDENCIES
NO_REQUIRE_QOS
${_CONNEXT_DEPENDENCIES}
)

connextdds_add_application(
TARGET VehicleModeling_subscriber
LANG "C++11"
OUTPUT_NAME "subscriber"
SOURCES
$<TARGET_OBJECTS:VehicleModeling_CXX11_obj>
"${CMAKE_CURRENT_SOURCE_DIR}/subscriber.cxx"
DEPENDENCIES
NO_REQUIRE_QOS
${_CONNEXT_DEPENDENCIES}
)
48 changes: 48 additions & 0 deletions tutorials/application_design/c++11/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Tutorial: Application Design

This code is part of the Connext Application Design tutorial.

## Building the Example :wrench:

You can build the example following the instructions in the tutorial, or you can
build it using CMake as follows.

1. Generate the build files:

```sh
mkdir build
cd build
cmake ..
```

This command will try to find the location of your Connext installation. If it
can't find it, specify it with the ``-DCONNEXTDDS_DIR`` option, for example:

```sh
cmake -DCONNEXTDDS_DIR=/home/rti/rti_connext_dds-x.y.z ..
```

If you are compiling for windows you may also need to specify the
[generator](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html),
and platform.

```sh
cmake .. -G "Visual Studio 17 2022" -A x64
```

2. Build the applications:

```sh
cmake --build .
```

If you are using a multi-configuration generator, such as Visual Studio
solutions, you can specify the configuration mode to build as follows:

```sh
cmake --build . --config Release|Debug
```

## Running the Example :rocket:

See the tutorial for instructions.
103 changes: 103 additions & 0 deletions tutorials/application_design/c++11/common.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
//
// (c) 2024 Copyright, Real-Time Innovations, Inc. All rights reserved.
//
// RTI grants Licensee a license to use, modify, compile, and create derivative
// works of the Software. Licensee has the right to distribute object form
// only for use with RTI products. The Software is provided "as is", with no
// warranty of any type, including any warranty for fitness for any purpose.
// RTI is under no obligation to maintain or support the Software. RTI shall
// not be liable for any incidental or consequential damages arising out of the
// use or inability to use the software.

#ifndef COMMON_HPP
#define COMMON_HPP

#include <vector>
#include <sstream>
#include <random>

#include "VehicleModeling.hpp"

using CoordSequence = rti::core::bounded_sequence<Coord, 100>;

namespace { // Coord namespace

std::string to_string(const Coord &coord)
{
std::ostringstream ss;
ss << "Coord(lat: " << coord.lat() << ", lon: " << coord.lon() << ")";
return ss.str();
}

} // namespace

namespace rti::core { // bounded_sequence namespace

std::string to_string(const CoordSequence &route)
{
using ::to_string;

std::ostringstream ss;
ss << "Route(";
for (auto it = route.begin(); it != route.end();) {
ss << to_string(*it);
if (++it != route.end()) {
ss << ", ";
}
}
ss << ")";
return ss.str();
}

} // namespace rti::core

namespace utils {

namespace details {

static std::random_device rd;
static std::mt19937 gen { rd() };

}; // namespace details

void set_random_seed(unsigned seed)
{
details::gen.seed(seed);
}

double random_range(double min, double max)
{
return std::uniform_real_distribution<>(min, max)(details::gen);
}

double random_stduniform()
{
return random_range(0.0, 1.0);
}

std::string new_vin()
{
static const std::string choices("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");

std::ostringstream ss;
for (int i = 0; i < VIN_LENGTH; ++i) {
ss << choices[random_range(0, choices.size())];
}
return ss.str();
}


CoordSequence new_route(int n = 5)
{
CoordSequence route;
for (int i = 0; i < n; ++i) {
double r1 = random_stduniform() * 100.0;
double r2 = random_stduniform() * 100.0;
route.push_back(Coord { r1, r2 });
}
return route;
}

} // namespace utils

#endif
Loading
Loading