Skip to content

Commit

Permalink
update external object converter
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-du-car committed Jul 18, 2023
1 parent c3b7ba8 commit c98778d
Show file tree
Hide file tree
Showing 14 changed files with 668 additions and 111 deletions.
38 changes: 38 additions & 0 deletions src/tmx/Messages/include/simulation/BSMID.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#ifndef INCLUDE_SIMULATED_BSMID_H_
#define INCLUDE_SIMULATED_BSMID_H_

#include <iostream>
#include <tmx/messages/message.hpp>

namespace tmx
{
namespace messages
{
namespace simulation
{

struct BSMID
{
uint8_t BsmId = 0;

BSMID() {}
BSMID(std::uint8_t bsmId) : BsmId(bsmId) {}

static message_tree_type to_tree(BSMID element)
{
message_tree_type treeElement;
treeElement.put("BsmId", element.BsmId);
return treeElement;
}

static BSMID from_tree(message_tree_type &treeElement)
{
BSMID element;
element.BsmId = treeElement.get<std::uint8_t>("BsmId");
return element;
}
};
}
}
}
#endif
41 changes: 41 additions & 0 deletions src/tmx/Messages/include/simulation/Covariance.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#ifndef INCLUDE_SIMULATED_COVARIANCE_H_
#define INCLUDE_SIMULATED_COVARIANCE_H_

#include <iostream>
#include <tmx/messages/message.hpp>

namespace tmx
{
namespace messages
{
namespace simulation
{
// Row-major representation of the 6x6 covariance matrix
// # The orientation parameters use a fixed-axis representation.
// # In order, the parameters are:
// # (x, y, z, rotation about X axis, rotation about Y axis, rotation about Z axis)
struct Covariance
{
double covariance = 0;

Covariance() {}
Covariance(double covariance) : covariance(covariance) {}

static message_tree_type to_tree(Covariance element)
{
message_tree_type treeElement;
treeElement.put("Covariance", element.covariance);
return treeElement;
}

static Covariance from_tree(message_tree_type &treeElement)
{
Covariance element;
element.covariance = treeElement.get<double>("Covariance");
return element;
}
};
}
}
}
#endif
64 changes: 8 additions & 56 deletions src/tmx/Messages/include/simulation/ExternalObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

#include <tmx/messages/message.hpp>
#include <MessageTypes.h>
// #include <simulation/Header.h>
#include <simulation/PresenceVectorEnumTypes.h>
#include <simulation/ObjectEnumTypes.h>
#include <simulation/BSMID.h>
#include <simulation/Covariance.h>

namespace tmx
{
Expand Down Expand Up @@ -35,9 +36,9 @@ namespace tmx
std_attribute(this->msg, bool, MetadataIsSimulation, false, );
std_attribute(this->msg, std::string, MetadataDatum, "", );
std_attribute(this->msg, std::string, MetadataProjString, "", );
std_attribute(this->msg, std::string, MetadataSensorX, "", );
std_attribute(this->msg, std::string, MetadataSensorY, "", );
std_attribute(this->msg, std::string, MetadataSensorZ, "", );
std_attribute(this->msg, double, MetadataSensorX, 0, );
std_attribute(this->msg, double, MetadataSensorY, 0, );
std_attribute(this->msg, double, MetadataSensorZ, 0, );
std_attribute(this->msg, std::string, MetadataInfrastructureId, "", );
std_attribute(this->msg, std::string, MetadataSensorId, "", );
/**
Expand All @@ -56,34 +57,12 @@ namespace tmx

// A presence vector, this message is used to describe objects coming from potentially different
// sources. The presence vector is used to determine what items are set by the producer.
std_attribute(this->msg, PRESENCE_VECTOR_TYPES, PresenceVector, PRESENCE_VECTOR_TYPES::OBJECT_TYPE_PRESENCE_VECTOR, );
std_attribute(this->msg, PRESENCE_VECTOR_TYPES, PresenceVector, PRESENCE_VECTOR_TYPES::UNAVAILABLE, );

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

// bsm id is of form [0xff, 0xff, 0xff, 0xff]. It is not required.
// uint8[] bsm_id
struct BSMID
{
uint8_t BsmId = 0;

BSMID() {}
BSMID(std::uint8_t bsmId) : BsmId(bsmId) {}

static message_tree_type to_tree(BSMID element)
{
message_tree_type treeElement;
treeElement.put("BsmId", element.BsmId);
return treeElement;
}

static BSMID from_tree(message_tree_type &treeElement)
{
BSMID element;
element.BsmId = treeElement.get<std::uint8_t>("BsmId");
return element;
}
};
// bsm id is of form [0xff, 0xff, 0xff, 0xff]. It is not required.
array_attribute( BSMID, BsmId);

// Pose of the object within the frame specified in header
Expand All @@ -92,38 +71,11 @@ namespace tmx
std_attribute(this->msg, double, PosePosePositionX, 0, );
std_attribute(this->msg, double, PosePosePositionY, 0, );
std_attribute(this->msg, double, PosePosePositionZ, 0, );

// This represents an orientation in free space in quaternion form.
std_attribute(this->msg, double, PosePoseOrientationX, 0, );
std_attribute(this->msg, double, PosePoseOrientationY, 0, );
std_attribute(this->msg, double, PosePoseOrientationZ, 0, );
std_attribute(this->msg, double, PosePoseOrientationW, 0, );

// Row-major representation of the 6x6 covariance matrix
// # The orientation parameters use a fixed-axis representation.
// # In order, the parameters are:
// # (x, y, z, rotation about X axis, rotation about Y axis, rotation about Z axis)
struct Covariance
{
double covariance = 0;

Covariance() {}
Covariance(double covariance) : covariance(covariance) {}

static message_tree_type to_tree(Covariance element)
{
message_tree_type treeElement;
treeElement.put("Covariance", element.covariance);
return treeElement;
}

static Covariance from_tree(message_tree_type &treeElement)
{
Covariance element;
element.covariance = treeElement.get<std::uint8_t>("Covariance");
return element;
}
};
array_attribute( Covariance, PoseCovariance);

// #Average velocity of the object within the frame specified in header
Expand Down Expand Up @@ -169,7 +121,7 @@ namespace tmx
// # Binary value to show if the object is static or dynamic (1: dynamic, 0: static)
std_attribute(this->msg, bool, DynamticObj, false, );

// Predictions for the object. It is not required.
// Ignored: Predictions for the object.
// carma_perception_msgs/PredictedState[] predictions
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace tmx
{
enum PRESENCE_VECTOR_TYPES
{
UNAVAILABLE = 0,
ID_PRESENCE_VECTOR = 1,
POSE_PRESENCE_VECTOR = 2,
VELOCITY_PRESENCE_VECTOR = 4,
Expand Down
3 changes: 2 additions & 1 deletion src/tmx/TmxUtils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ TARGET_LINK_LIBRARIES (${PROJECT_NAME} PUBLIC
rdkafka++
::carma-clock
gmock
jsoncpp
pthread m rt)

SET (TMXUTILS_LIBRARIES ${PROJECT_NAME} PARENT_SCOPE)
Expand Down Expand Up @@ -54,4 +55,4 @@ add_executable(${BINARY} ${TEST_SOURCES})

add_test(NAME ${BINARY} COMMAND ${BINARY})

target_link_libraries(${BINARY} PUBLIC ${PROJECT_NAME} rdkafka++ gmock ${TMXAPI_LIBRARIES} ${ASN_J2735_LIBRARIES} ${UUID_LIBRARY} gtest)
target_link_libraries(${BINARY} PUBLIC ${PROJECT_NAME} rdkafka++ gmock ${TMXAPI_LIBRARIES} ${ASN_J2735_LIBRARIES} ${UUID_LIBRARY} gtest jsoncpp)
Loading

0 comments on commit c98778d

Please sign in to comment.