-
Notifications
You must be signed in to change notification settings - Fork 67
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
Added conversion between JSON and ASN.1 C-struct for SDSM with Kafka updates #562
Conversation
Needs fixes to sourceID and lights fields - in progress May consider checking required fields with "isMember" before setting data Some of the json access statements are very long, I find this more readable from a hierarchy standpoint but may be obtrusive. Can use variables to simply access if needed |
@@ -49,6 +49,8 @@ void CARMAStreetsPlugin::UpdateConfigSettings() { | |||
GetConfigValue<string>("MapTopic", _transmitMAPTopic); | |||
GetConfigValue<string>("SRMTopic", _transmitSRMTopic); | |||
GetConfigValue<string>("SimSensorDetectedObjTopic", _transmitSimSensorDetectedObjTopic); | |||
GetConfigValue<string>("SdsmTopic", _subscribeToSdsmTopic); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you will need to add this as configuration parameter to the manifest.json for this to work.
@@ -49,6 +49,8 @@ void CARMAStreetsPlugin::UpdateConfigSettings() { | |||
GetConfigValue<string>("MapTopic", _transmitMAPTopic); | |||
GetConfigValue<string>("SRMTopic", _transmitSRMTopic); | |||
GetConfigValue<string>("SimSensorDetectedObjTopic", _transmitSimSensorDetectedObjTopic); | |||
GetConfigValue<string>("SdsmTopic", _subscribeToSdsmTopic); | |||
GetConfigValue<string>("SdsmTopic", _transmitSDSMTopic); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep figured I missed something minor. I meant to ask- can/should these use the same name? The other configs seem to use [x]Topic interchangeably for subscribe/transmit but this one does both
@@ -67,6 +69,12 @@ class CARMAStreetsPlugin: public PluginClientClockAware { | |||
* @param routeableMsg | |||
*/ | |||
void HandleMapMessage(MapDataMessage &msg, routeable_message &routeableMsg); | |||
/** | |||
* @brief Subscribe to SDSM broadcast. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets have a better description here. This method handles incoming SDSMs received by RSU and forwards them to CARMA Streets as JSON string messages.
SetStatus<uint>(Key_SDSMMessageSkipped, ++_sdsmMessageSkipped); | ||
continue; | ||
} | ||
//Convert the SSM JSON string into J3224 SDSM message and encode it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still referencing SSM. Minor fix comment.
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_SensorDataSharingMessage, sdsm_ptr.get()); // same as above | ||
PLOG(logDEBUG) << "sdsmEncodedMsg: " << sdsmEncodedMsg; | ||
|
||
//Broadcast the encoded SSM message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SSM?
} | ||
} | ||
|
||
//std::cout << SDSMDataJson.toStyledString() << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this method still exist. Any reason why we would keep this commented out line in the final commit?
namespace CARMAStreetsPlugin | ||
{ | ||
|
||
// Template to use when created shared pointer objects for optional data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we create a TODO comment to move this these functions to a more reusable place since they may be helpful in general for manipulating asn1c generated structs.
{ | ||
|
||
// Template to use when created shared pointer objects for optional data | ||
template <typename T> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait why are we redefining functions we already defined in the previous header file?
|
||
bool JsonToJ3224SDSMConverter::parseJsonString(const std::string &consumedMsg, Json::Value &sdsmJsonOut) const | ||
{ | ||
const auto jsonLen = static_cast<int>(consumedMsg.length()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this method at all unique to sdsms or is it just parsing strings into JSON values? If it is not unique maybe we can add a TODO comment to consolidate all the places parse strings into JSON values and try to reuse a single method. Maybe atleast for CARMA-Streets Plugin.
// lights | ||
auto lights_ptr = CARMAStreetsPlugin::create_store_shared<ExteriorLights_t>(shared_ptrs); | ||
auto lights = static_cast<int16_t>((*itr)["detected_object_data"]["detected_object_optional_data"]["detected_vehicle_data"]["lights"].asInt()); | ||
lights_ptr->buf = (uint8_t *)calloc(2, sizeof(uint8_t)); // TODO: find calloc alternative if possible, causes a memory leak |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment out and leave a TODO comment to fix this optional fields.
@@ -381,7 +381,7 @@ namespace unit_test | |||
ASSERT_EQ(5, sdsmJson["objects"][0]["detected_object_data"]["detected_object_common_data"]["speed_confidence_z"].asInt()); | |||
ASSERT_EQ(15000, sdsmJson["objects"][0]["detected_object_data"]["detected_object_common_data"]["heading"].asInt()); | |||
ASSERT_EQ(5, sdsmJson["objects"][0]["detected_object_data"]["detected_object_common_data"]["heading_conf"].asInt()); | |||
ASSERT_EQ(200, sdsmJson["objects"][0]["detected_object_data"]["detected_object_common_data"]["accel_4_way"]["long"].asInt()); | |||
ASSERT_EQ(200, sdsmJson["objects"][0]["detected_object_data"]["detected_object_common_data"]["accel_4_way"]["Long"].asInt()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this Long instead of long?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
PR Details
Description
Added functionality to convert SDSMs from inbound json strings to outbound ASN.1 styled C-structs to facilitate communication over the CARMA Streets plugin in both directions.
Related Issue
CDAR-308
#589
Motivation and Context
How Has This Been Tested?
Tested locally in VSCode with new unit tests for the conversion between jsons and the ASN.1 C-struct messages.
Types of changes
Checklist:
V2XHUB Contributing Guide