-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FCP-5: SensorDetectedObject TMX message definition (#628)
<!-- Thanks for the contribution, this is awesome. --> # PR Details ## Description Updating SensorDetectedObject message to allow for TMX JSON serialization/deserialization. <!--- Describe your changes in detail --> ## Related Issue https://usdot-carma.atlassian.net/browse/FCP-5 <!--- 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 Freight Cooperative perception <!--- Why is this change required? What problem does it solve? --> ## How Has This Been Tested? Unit 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: --> - [x] Defect fix (non-breaking change that fixes an issue) - [ ] 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
1 parent
4847aa7
commit be5a5af
Showing
13 changed files
with
493 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
#include <tmx/messages/message.hpp> | ||
namespace tmx::messages | ||
{ | ||
struct Covariance{ | ||
double value; | ||
Covariance()=default; | ||
explicit Covariance(double value):value(value){}; | ||
static message_tree_type to_tree(const Covariance& cov){ | ||
message_tree_type tree; | ||
tree.put("",cov.value); | ||
return tree; | ||
} | ||
static Covariance from_tree(const message_tree_type& tree){ | ||
Covariance cov; | ||
cov.value = tree.get<double>(""); | ||
return cov; | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma once | ||
#include <tmx/messages/message.hpp> | ||
namespace tmx::messages | ||
{ | ||
// Cartesian positiion of object. Assumed to be ENU coordinate frame. | ||
struct Position{ | ||
double x; | ||
double y; | ||
double z; | ||
Position()=default; | ||
explicit Position(double x, double y, double z):x(x),y(y),z(z){}; | ||
static message_tree_type to_tree(const Position& pos){ | ||
message_tree_type tree; | ||
tree.put("x", pos.x); | ||
tree.put("y", pos.y); | ||
tree.put("z", pos.z); | ||
return tree; | ||
} | ||
static Position from_tree(const message_tree_type& tree){ | ||
Position pos; | ||
pos.x = tree.get<double>("x"); | ||
pos.y = tree.get<double>("y"); | ||
pos.z = tree.get<double>("z"); | ||
return pos; | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,61 @@ | ||
#ifndef INCLUDE_SIMULATED_SensorDetectedObject_H_ | ||
#define INCLUDE_SIMULATED_SensorDetectedObject_H_ | ||
#pragma once | ||
|
||
#include <tmx/messages/message.hpp> | ||
#include <MessageTypes.h> | ||
#include <Vector3d.h> | ||
#include <Point.h> | ||
#include "Position.h" | ||
#include "Covariance.h" | ||
#include "Velocity.h" | ||
#include "Size.h" | ||
|
||
namespace tmx | ||
namespace tmx::messages | ||
{ | ||
namespace messages | ||
{ | ||
|
||
/** | ||
* This SensorDetectedObject is used to communicate the sensor detected object information with various applications. | ||
* This message is the generic representation of a sensor detection. | ||
*/ | ||
class SensorDetectedObject : public tmx::message | ||
{ | ||
public: | ||
SensorDetectedObject(){}; | ||
SensorDetectedObject(const tmx::message_container_type &contents) : tmx::message(contents) {}; | ||
~SensorDetectedObject(){}; | ||
// Message type for routing this message through TMX core | ||
static constexpr const char *MessageType = MSGTYPE_APPLICATION_STRING; | ||
/** | ||
* This SensorDetectedObject is used to communicate the sensor detected object information with various applications. | ||
* This message is the generic representation of a sensor detection. | ||
*/ | ||
class SensorDetectedObject : public tmx::message | ||
{ | ||
public: | ||
SensorDetectedObject()=default; | ||
explicit SensorDetectedObject(const tmx::message_container_type &contents) : tmx::message(contents) {}; | ||
~SensorDetectedObject() override{}; | ||
// 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 | ||
static constexpr const char *MessageSubType = MSGSUBTYPE_SENSOR_DETECTED_OBJECT_STRING; | ||
|
||
// // Message sub type for routing this message through TMX core | ||
static constexpr const char *MessageSubType = MSGSUBTYPE_SENSOR_DETECTED_OBJECT_STRING; | ||
//Flag to indicate whether sensor detected object is simulated. | ||
std_attribute(this->msg, bool, isSimulated, false,); | ||
// Classification of detected object. | ||
std_attribute(this->msg, std::string, type, "",); | ||
// Confidence of type classification | ||
std_attribute(this->msg, double, confidence, 0.0,); | ||
// Unique indentifier of sensor reporting detection. | ||
std_attribute(this->msg, std::string, sensorId, "", ); | ||
// String describing projection used to convert cartesian data to WGS84 data. | ||
std_attribute(this->msg, std::string, projString, "", ); | ||
// Unique identifier of detected object. | ||
std_attribute(this->msg, int, objectId, 0, ); | ||
|
||
// TODO: Convert this member variable to std::attributes and handle nested object and arrays. (see [CloudHeartbeatMessage.h](./CloudHearbeatMessage.h) array_attribute ) | ||
|
||
// Classification of detected object | ||
std::string type = ""; | ||
// Confidence of type classification | ||
double confidence = 0.0; | ||
// Unique indentifier of sensor reporting detection | ||
std::string sensorId = ""; | ||
// String describing projection used to convert cartesian data to WGS84 data | ||
std::string projString = ""; | ||
// Unique identifier of detected object | ||
int objectId = 0; | ||
// Cartesian positiion of object. Assumed to be ENU coordinate frame. | ||
tmx::utils::Point position = tmx::utils::Point(); | ||
// Cartesian velocity vector of object. Assumed to be ENU coordinate frame. | ||
tmx::utils::Vector3d velocity = tmx::utils::Vector3d(); | ||
// Epoch time in milliseconds | ||
long timestamp = 0; | ||
|
||
}; | ||
|
||
object_attribute(Position, position); | ||
two_dimension_array_attribute(Covariance, positionCovariance); | ||
//Linear velocity in meter per second | ||
object_attribute(Velocity, velocity); | ||
//Covariance associated with linear velocity. | ||
two_dimension_array_attribute(Covariance, velocityCovariance); | ||
//Angular velocity in radians per second. | ||
object_attribute(Velocity, angularVelocity); | ||
//Covariance associated with angular velocity. | ||
two_dimension_array_attribute(Covariance, angularVelocityCovariance); | ||
|
||
} | ||
// Epoch time in milliseconds. | ||
// long timestamp = 0; | ||
std_attribute(this->msg, long, timestamp, 0, ); | ||
object_attribute(Size, size); | ||
|
||
}; | ||
|
||
}; // namespace tmx | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma once | ||
#include <tmx/messages/message.hpp> | ||
namespace tmx::messages | ||
{ | ||
//Length, width and height of object in meter. | ||
struct Size{ | ||
double length; | ||
double width; | ||
double height; | ||
Size()=default; | ||
explicit Size(double length, double width, double height): length(length), width(width), height(height){}; | ||
static message_tree_type to_tree(const Size& size){ | ||
message_tree_type tree; | ||
tree.put("length", size.length); | ||
tree.put("width", size.width); | ||
tree.put("height", size.height); | ||
return tree; | ||
} | ||
static Size from_tree(const message_tree_type & tree){ | ||
Size size; | ||
size.length = tree.get<double>("length"); | ||
size.width = tree.get<double>("width"); | ||
size.height = tree.get<double>("height"); | ||
return size; | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma once | ||
#include <tmx/messages/message.hpp> | ||
namespace tmx::messages | ||
{ | ||
// Cartesian velocity vector of object. Assumed to be ENU coordinate frame. | ||
struct Velocity{ | ||
double x; | ||
double y; | ||
double z; | ||
Velocity()=default; | ||
explicit Velocity(double x, double y, double z):x(x),y(y),z(z){}; | ||
static message_tree_type to_tree(const Velocity& velocity){ | ||
message_tree_type tree; | ||
tree.put("x", velocity.x); | ||
tree.put("y", velocity.y); | ||
tree.put("z", velocity.z); | ||
return tree; | ||
} | ||
static Velocity from_tree(const message_tree_type& tree){ | ||
Velocity velocity; | ||
velocity.x = tree.get<double>("x"); | ||
velocity.y = tree.get<double>("y"); | ||
velocity.z = tree.get<double>("z"); | ||
return velocity; | ||
} | ||
}; | ||
} |
Oops, something went wrong.