Skip to content

Commit

Permalink
v2x hub Integration: Implement telematic plugin to subscribe to all T…
Browse files Browse the repository at this point in the history
…MX messages from V2xHub (#565)

<!-- Thanks for the contribution, this is awesome. -->

# PR Details
## Description
In order to publish data from V2xHub to cloud a telematics bridge is
needed. This story is the implementation story for the telematic module
to collect J2735 data from V2xHub. The design refers to
https://usdot-carma.atlassian.net/wiki/spaces/WFD2/pages/2640379977/V2xHub+WFD+Bridge+Design

Connect to V2xHub

Subscribe all TMX messages from V2xhub.

If there are J2735 message payloads in the TMX messages, decode the
J2735 into human readable message.

Convert TMX messages into messages in JSON format.
<!--- Describe your changes in detail -->

## Related Issue
NA
<!--- This project only accepts pull requests related to open issues -->
<!--- If suggesting a new feature or change, please discuss it in an
issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps
to reproduce -->
<!--- Please link to the issue here: -->

## Motivation and Context
CDA telematic
<!--- Why is this change required? What problem does it solve? -->

## How Has This Been Tested?
Unit test
Integration test
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->

## Types of changes

<!--- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->

- [ ] Defect fix (non-breaking change that fixes an issue)
- [x] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that cause existing functionality
to change)

## Checklist:

<!--- Go over all the following points, and put an `x` in all the boxes
that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->

- [ ] I have added any new packages to the sonar-scanner.properties file
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [x] I have read the **CONTRIBUTING** document.
[V2XHUB Contributing
Guide](https://github.com/usdot-fhwa-OPS/V2X-Hub/blob/develop/Contributing.md)
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.
  • Loading branch information
dan-du-car authored Nov 21, 2023
1 parent a098635 commit 774b31f
Show file tree
Hide file tree
Showing 14 changed files with 503 additions and 7 deletions.
7 changes: 6 additions & 1 deletion .sonarqube/sonar-scanner.properties
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ sonar.modules= PedestrianPlugin, \
CARMAStreetsPlugin, \
ERVCloudForwardingPlugin, \
CDASimAdapter, \
RSUHealthMonitorPlugin
RSUHealthMonitorPlugin, \
TelematicBridgePlugin



Expand Down Expand Up @@ -84,6 +85,7 @@ CARMAStreetsPlugin.sonar.projectBaseDir =src/v2i-hub/CARMAStreetsPlugin
ERVCloudForwardingPlugin.sonar.projectBaseDir =src/v2i-hub/ERVCloudForwardingPlugin
CDASimAdapter.sonar.projectBaseDir =src/v2i-hub/CDASimAdapter
RSUHealthMonitorPlugin.sonar.projectBaseDir =src/v2i-hub/RSUHealthMonitorPlugin
TelematicBridgePlugin.sonar.projectBaseDir =src/v2i-hub/TelematicBridgePlugin



Expand Down Expand Up @@ -121,6 +123,8 @@ CDASimAdapter.sonar.sources =src
CDASimAdapter.sonar.exclusions =test/**
RSUHealthMonitorPlugin.sonar.sources =src
RSUHealthMonitorPlugin.sonar.exclusions =test/**
TelematicBridgePlugin.sonar.sources =src
TelematicBridgePlugin.sonar.exclusions =test/**

# Tests
# Note: For C++ setting this field does not cause test analysis to occur. It only allows the test source code to be evaluated.
Expand Down Expand Up @@ -149,3 +153,4 @@ CARMAStreetsPlugin.sonar.tests=test
ERVCloudForwardingPlugin.sonar.tests=test
CDASimAdapter.sonar.tests=test
RSUHealthMonitorPlugin.sonar.tests=test
TelematicBridgePlugin.sonar.tests=test
18 changes: 17 additions & 1 deletion ext/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,25 @@ popd

# GPS Parser
pushd /tmp
if [ -d "NemaTode" ]; then
rm -r NemaTode
fi
git clone https://github.com/ckgt/NemaTode.git
cd NemaTode
cmake .
make -j${numCPU}
make install
popd
popd

# Nats C API
pushd /tmp
if [ -d "nats.c" ]; then
rm -r nats.c
fi
git clone https://github.com/nats-io/nats.c
cd nats.c
cmake . -DNATS_BUILD_NO_SPIN=ON
make -j${numCPU}
make install
popd

3 changes: 3 additions & 0 deletions scripts/install_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ DEPENDENCIES="build-essential \
wget \
zip \
zlib1g \
rapidjson-dev \
librapidxml-dev \
libprotobuf-c-dev \
curl"

# STOL library dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ namespace RSUHealthMonitor
}
else if (success)
{
rsuStatuJson.append(populateJson(config.field, responseVal));
auto json = populateJson(config.field, responseVal);
for(const auto &key: json.getMemberNames())
{
rsuStatuJson[key] = json[key];
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,22 @@ namespace RSUHealthMonitor
double expected_longitude = -77.1496;
ASSERT_NEAR(expected_latitude, json["rsuGpsOutputStringLatitude"].asDouble(), 0.001);
ASSERT_NEAR(expected_longitude, json["rsuGpsOutputStringLongitude"].asDouble(), 0.001);
rsuStatusJson.append(json);
for(const auto& key: json.getMemberNames())
{
rsuStatusJson[key] = json[key];
}

snmp_response_obj intObj;
intObj.type = snmp_response_obj::response_type::INTEGER;
intObj.val_int = 4;

json = _rsuWorker->populateJson("rsuMode", intObj);
ASSERT_EQ(4, json["rsuMode"].asInt64());
rsuStatusJson.append(json);
rsuStatusJson["rsuMode"] = json["rsuMode"];

Json::FastWriter fasterWirter;
string json_str = fasterWirter.write(rsuStatusJson);
string expectedStr = "[{\"rsuGpsOutputString\":\"$GPGGA,142440.00,3857.3065,N,07708.9734,W,2,18,0.65,86.18,M,-34.722,M,,*62\",\"rsuGpsOutputStringLatitude\":38.955108330000002,\"rsuGpsOutputStringLongitude\":-77.149556669999996},{\"rsuMode\":4}]\n";
string expectedStr = "{\"rsuGpsOutputString\":\"$GPGGA,142440.00,3857.3065,N,07708.9734,W,2,18,0.65,86.18,M,-34.722,M,,*62\",\"rsuGpsOutputStringLatitude\":38.955108330000002,\"rsuGpsOutputStringLongitude\":-77.149556669999996,\"rsuMode\":4}\n";
ASSERT_EQ(expectedStr, json_str);
ASSERT_EQ(4, _rsuWorker->getJsonKeys(rsuStatusJson).size());
ASSERT_EQ(1, _rsuWorker->getJsonKeys(json).size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ TEST(PedestrianDetectionForSPAT, updateEncodedSpat)
EXPECT_EQ(spatPtr->intersections.list.array[0]->states.list.array[0]->signalGroup, 1);
EXPECT_EQ(spatPtr->intersections.list.array[0]->states.list.array[1]->signalGroup, 2);
ASSERT_NE(spatPtr->intersections.list.array[0]->maneuverAssistList, nullptr);
EXPECT_EQ(spatPtr->intersections.list.array[0]->maneuverAssistList->list.count, 1);
EXPECT_NE(spatPtr->intersections.list.array[0]->maneuverAssistList->list.count, 0);
ASSERT_NE(spatPtr->intersections.list.array[0]->maneuverAssistList->list.array[0]->pedBicycleDetect, nullptr);
EXPECT_EQ(*(spatPtr->intersections.list.array[0]->maneuverAssistList->list.array[0]->pedBicycleDetect), 1);
}
Expand Down
15 changes: 15 additions & 0 deletions src/v2i-hub/TelematicBridgePlugin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
PROJECT (TelematicBridgePlugin VERSION 7.5.1 LANGUAGES CXX)

set (TMX_PLUGIN_NAME "Telematic Bridge")

BuildTmxPlugin()
TARGET_LINK_LIBRARIES ( ${PROJECT_NAME} tmxutils jsoncpp)

####################################################
################## Testing #######################
####################################################
enable_testing()
include_directories(${PROJECT_SOURCE_DIR}/src)
file(GLOB_RECURSE TEST_SOURCES LIST_DIRECTORIES false test/*.h test/*.cpp)
add_executable(${PROJECT_NAME}_test ${TEST_SOURCES})
target_link_libraries(${PROJECT_NAME}_test PRIVATE gtest tmxutils jsoncpp)
16 changes: 16 additions & 0 deletions src/v2i-hub/TelematicBridgePlugin/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "TelematicBridge",
"description": "Plugin that listens for TMX messages and forward them to the Telematic cloud services.",
"version": "@PROJECT_VERSION@",
"exeLocation": "/bin/TelematicBridgePlugin",
"coreIpAddr": "127.0.0.1",
"corePort": 24601,
"messageTypes": [],
"configuration": [
{
"key": "LogLevel",
"default": "INFO",
"description": "The log level for this plugin"
}
]
}
11 changes: 11 additions & 0 deletions src/v2i-hub/TelematicBridgePlugin/src/TelematicBridgeException.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once
#include <tmx/TmxException.hpp>

namespace TelematicBridge
{
class TelematicBridgeException : public tmx::TmxException
{
public:
using TmxException::TmxException;
};
}
Loading

0 comments on commit 774b31f

Please sign in to comment.