-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #705 from rticommunity/merge-master-into-develop
Merge master into develop
- Loading branch information
Showing
12 changed files
with
671 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.