Skip to content

Commit

Permalink
Naming fixes, removal of lights, TODO additions
Browse files Browse the repository at this point in the history
  • Loading branch information
willjohnsonk committed Sep 11, 2023
1 parent 39550fe commit a86cc09
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/v2i-hub/CARMAStreetsPlugin/src/CARMAStreetsPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ void CARMAStreetsPlugin::SubscribeSDSMKafkaTopic(){
SetStatus<uint>(Key_SDSMMessageSkipped, ++_sdsmMessageSkipped);
continue;
}
//Convert the SSM JSON string into J3224 SDSM message and encode it.
//Convert the SDSM JSON string into J3224 SDSM message and encode it.
auto sdsm_ptr = std::make_shared<SensorDataSharingMessage>();
sdsm_convertor.convertJsonToSDSM(sdsmDoc, sdsm_ptr);
tmx::messages::SdsmEncodedMessage sdsmEncodedMsg;
Expand All @@ -689,7 +689,7 @@ void CARMAStreetsPlugin::SubscribeSDSMKafkaTopic(){
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_SensorDataSharingMessage, sdsm_ptr.get()); // same as above
PLOG(logDEBUG) << "sdsmEncodedMsg: " << sdsmEncodedMsg;

//Broadcast the encoded SSM message
//Broadcast the encoded SDSM message
sdsmEncodedMsg.set_flags(IvpMsgFlags_RouteDSRC);
sdsmEncodedMsg.addDsrcMetadata(0x8002);
BroadcastMessage(static_cast<routeable_message &>(sdsmEncodedMsg));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,5 @@ namespace CARMAStreetsPlugin

}
}

//std::cout << SDSMDataJson.toStyledString() << std::endl;
}
}
28 changes: 14 additions & 14 deletions src/v2i-hub/CARMAStreetsPlugin/src/JsonToJ3224SDSMConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace CARMAStreetsPlugin
{

// TODO: Move these template functions to a more central location such as in a utility file
// Template to use when created shared pointer objects for optional data
template <typename T>
T *create_store_shared(std::vector<std::shared_ptr<void>> &shared_pointers)
Expand All @@ -21,7 +21,7 @@ namespace CARMAStreetsPlugin
return array_shared.get();
}


// TODO: Consolidate parseJsonString into a more central location since it is being used verbatim in other converters
bool JsonToJ3224SDSMConverter::parseJsonString(const std::string &consumedMsg, Json::Value &sdsmJsonOut) const
{
const auto jsonLen = static_cast<int>(consumedMsg.length());
Expand Down Expand Up @@ -55,8 +55,8 @@ namespace CARMAStreetsPlugin
sdsm->sourceID = tempID;

sdsm->equipmentType = sdsm_json["equipment_type"].asInt64();



// sDSMTimeStamp
auto sdsm_time_stamp_ptr = CARMAStreetsPlugin::create_store_shared<DDateTime_t>(shared_ptrs);

Expand Down Expand Up @@ -201,17 +201,17 @@ namespace CARMAStreetsPlugin
// set presence val to veh
optional_data_ptr->present = DetectedObjectOptionalData_PR_detVeh;

// TODO: find a better way to convert lights val
// 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
lights_ptr->size = 2 * sizeof(uint8_t);
lights_ptr->bits_unused = 0;
lights_ptr->buf[1] = static_cast<int8_t>(lights);
lights_ptr->buf[0] = (lights >> 8);

optional_data_ptr->choice.detVeh.lights = lights_ptr;
// TODO: find a better way to convert/test lights val without calloc
// // 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
// lights_ptr->size = 2 * sizeof(uint8_t);
// lights_ptr->bits_unused = 0;
// lights_ptr->buf[1] = static_cast<int8_t>(lights);
// lights_ptr->buf[0] = (lights >> 8);

// optional_data_ptr->choice.detVeh.lights = lights_ptr;


// vehAttitude
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,10 @@ namespace CARMAStreetsPlugin
auto sdsmPtr = std::make_shared<SensorDataSharingMessage>();
converter.convertJsonToSDSM(root, sdsmPtr);

// Similar to sourceID, need a better way to compare retrieved ASN.1 values (in this case bit strings) to verify conversion
size_t test_size = 2;
ASSERT_EQ(test_size, sdsmPtr->objects.list.array[0]->detObjOptData->choice.detVeh.lights->size);
// TODO: Find a better way to test light data following an updated implementation
// // Similar to sourceID, need a better way to compare retrieved ASN.1 values (in this case bit strings) to verify conversion
// size_t test_size = 2;
// ASSERT_EQ(test_size, sdsmPtr->objects.list.array[0]->detObjOptData->choice.detVeh.lights->size);

ASSERT_EQ(2400, sdsmPtr->objects.list.array[0]->detObjOptData->choice.detVeh.vehAttitude->pitch);
ASSERT_EQ(-12000, sdsmPtr->objects.list.array[0]->detObjOptData->choice.detVeh.vehAttitude->roll);
Expand Down

0 comments on commit a86cc09

Please sign in to comment.