Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-du-car committed Jul 25, 2023
1 parent 48b73ea commit ba1ebbc
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 64 deletions.
58 changes: 1 addition & 57 deletions src/tmx/Messages/include/simulation/SensorDetectedObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,64 +25,8 @@ namespace tmx
// Message type for routing this message through TMX core
static constexpr const char *MessageType = MSGTYPE_APPLICATION_STRING;

// Message sub type for routing this message through TMX core
// // Message sub type for routing this message through TMX core
static constexpr const char *MessageSubType = MSGSUBTYPE_SENSOR_DETECTED_OBJECT_STRING;
/**
* Metadata to describe the external object
*/
std_attribute(this->msg, bool, MetadataIsSimulation, false, );
std_attribute(this->msg, uint64_t, MetadataTimestamp, 0, );
std_attribute(this->msg, std::string, SensorProjString, "", );
std_attribute(this->msg, std::string, SensorType, "", );
std_attribute(this->msg, std::string, SensorId, "", );
std_attribute(this->msg, double, SensorLocationX, 0, );
std_attribute(this->msg, double, SensorLocationY, 0, );
std_attribute(this->msg, double, SensorLocationZ, 0, );
std_attribute(this->msg, std::string, MetadataInfrastructureId, "", );
std_attribute(this->msg, std::string, MetadataSensorId, "", );

// Object id. Matching ids on a topic should refer to the same object within some time period, expanded
std_attribute(this->msg, std::string, Id, "", );

// Pose of the object within the frame specified in header
// This represents a pose in free space with uncertainty.
std_attribute(this->msg, double, PositionX, 0, );
std_attribute(this->msg, double, PositionY, 0, );
std_attribute(this->msg, double, PositionZ, 0, );
// This represents an orientation in free space in quaternion form.
std_attribute(this->msg, double, OrientationX, 0, );
std_attribute(this->msg, double, OrientationY, 0, );
std_attribute(this->msg, double, OrientationZ, 0, );
std_attribute(this->msg, double, OrientationW, 0, );
array_attribute( Covariance, PositionCovariance);

// #Average velocity of the object within the frame specified in header
std_attribute(this->msg, double, VelocityTwistLinearX, 0, );
std_attribute(this->msg, double, VelocityTwistLinearY, 0, );
std_attribute(this->msg, double, VelocityTwistLinearZ, 0, );
std_attribute(this->msg, double, VelocityTwistAngularX, 0, );
std_attribute(this->msg, double, VelocityTwistAngularY, 0, );
std_attribute(this->msg, double, VelocityTwistAngularZ, 0, );
array_attribute( Covariance, VelocityCovariance);

// #The size of the object aligned along the axis of the object described by the orientation in pose
// #Dimensions are specified in meters
/**
* # This represents a vector in free space.
# It is only meant to represent a direction. Therefore, it does not
# make sense to apply a translation to it (e.g., when applying a
# generic rigid transformation to a Vector3, tf2 will only apply the
# rotation).
*/
std_attribute(this->msg, double, SizeLength, 0, );
std_attribute(this->msg, double, SizeWidth, 0, );
std_attribute(this->msg, double, SizeHeight, 0, );

// #Confidence
std_attribute(this->msg, double, Confidence, 0, );

// #describes a general object type as defined in this message
std_attribute(this->msg, std::string, ObjectType, "", );
};

}
Expand Down
7 changes: 7 additions & 0 deletions src/v2i-hub/CARMAStreetsPlugin/src/CARMAStreetsPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ CARMAStreetsPlugin::CARMAStreetsPlugin(string name) :
AddMessageFilter < tsm2Message > (this, &CARMAStreetsPlugin::HandleMobilityPathMessage);
AddMessageFilter < MapDataMessage > (this, &CARMAStreetsPlugin::HandleMapMessage);
AddMessageFilter < SrmMessage > (this, &CARMAStreetsPlugin::HandleSRMMessage);
AddMessageFilter < simulation::SensorDetectedObject > (this, &CARMAStreetsPlugin::HandleSimulatedExternalMessage );

SubscribeToMessages();
}
Expand All @@ -50,6 +51,7 @@ void CARMAStreetsPlugin::UpdateConfigSettings() {
GetConfigValue<string>("MobilityPathTopic", _transmitMobilityPathTopic);
GetConfigValue<string>("MapTopic", _transmitMAPTopic);
GetConfigValue<string>("SRMTopic", _transmitSRMTopic);
GetConfigValue<string>("SimExternalObjTopic", _transmitSimExternalObjTopic);
// Populate strategies config
string config;
GetConfigValue<string>("MobilityOperationStrategies", config);
Expand Down Expand Up @@ -628,6 +630,11 @@ void CARMAStreetsPlugin::SubscribeSSMKafkaTopic(){

}

void CARMAStreetsPlugin::HandleSimulatedExternalMessage(simulation::SensorDetectedObject &msg, routeable_message &routeableMsg)
{
PLOG(logINFO) << "Produce External Object Message in JSON format: " << msg.to_string() <<std::endl;
produce_kafka_msg( msg.to_string(), _transmitSimExternalObjTopic);
}

bool CARMAStreetsPlugin::getEncodedtsm3( tsm3EncodedMessage *tsm3EncodedMsg, Json::Value metadata, Json::Value payload_json )
{
Expand Down
3 changes: 3 additions & 0 deletions src/v2i-hub/CARMAStreetsPlugin/src/CARMAStreetsPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <kafka/kafka_client.h>
#include <kafka/kafka_consumer_worker.h>
#include "JsonToJ2735SSMConverter.h"
#include <simulation/SensorDetectedObject.h>
#include "PluginClientClockAware.h"


Expand Down Expand Up @@ -48,6 +49,7 @@ class CARMAStreetsPlugin: public PluginClientClockAware {
void HandleMobilityOperationMessage(tsm3Message &msg, routeable_message &routeableMsg);
void HandleMobilityPathMessage(tsm2Message &msg, routeable_message &routeableMsg);
void HandleBasicSafetyMessage(BsmMessage &msg, routeable_message &routeableMsg);
void HandleSimulatedExternalMessage(simulation::SensorDetectedObject &msg, routeable_message &routeableMsg);
/**
* @brief Overide PluginClientClockAware HandleTimeSyncMessage to producer TimeSyncMessage to kafka for CARMA Streets Time Synchronization.
* @param msg TimeSyncMessage received by plugin when in simulation mode. Message provides current simulation time to all processes.
Expand Down Expand Up @@ -104,6 +106,7 @@ class CARMAStreetsPlugin: public PluginClientClockAware {
std::string _transmitBSMTopic;
std::string _transmitMAPTopic;
std::string _transmitSRMTopic;
std::string _transmitSimExternalObjTopic;
std::string _kafkaBrokerIp;
std::string _kafkaBrokerPort;
std::shared_ptr<kafka_producer_worker> _kafka_producer_ptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
count_num = 0

def generate_sim_external_object():
jsonResult =
{
"type": "Application",
"subtype": "SensorDetectedObject",
"content": {
jsonResult = {
"metadata": {
"type": "Application",
"subtype": "SensorDetectedObject",
"timestamp": 123,
"isSimulated": true,
"isSimulated": True
},
"payload": {
"sensor": {
"id": "SomeID",
"type": "SematicLidar",
Expand Down
2 changes: 1 addition & 1 deletion src/v2i-hub/CDASimAdapter/src/CDASimConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ namespace CDASimAdapter{
if(external_object_listener)
{
std::string str_msg = consume_server_message(external_object_listener);
//ToDo: To populate the simulation detected object, this JSON string has to follow this specification: https://usdot-carma.atlassian.net/wiki/spaces/CRMSIM/pages/2563899417/Detected+Objects+Specification#CARMA-Street-and-V2xHub
externalObj.set_contents(str_msg);
}
else
{
Expand Down

0 comments on commit ba1ebbc

Please sign in to comment.