Skip to content
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

FCP-5: SensorDetectedObject TMX message definition #628

Merged
merged 13 commits into from
Aug 13, 2024

Conversation

dan-du-car
Copy link
Contributor

@dan-du-car dan-du-car commented Aug 6, 2024

PR Details

Description

Updating SensorDetectedObject message to allow for TMX JSON serialization/deserialization.

Related Issue

https://usdot-carma.atlassian.net/browse/FCP-5

Motivation and Context

Freight Cooperative perception

How Has This Been Tested?

Unit test

Types of changes

  • 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:

  • 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.
  • I have read the CONTRIBUTING document.
    V2XHUB Contributing Guide
  • I have added tests to cover my changes.
  • All new and existing tests passed.

}
static Covariance from_tree(const message_tree_type& tree){
Covariance cov;
cov.value = tree.get<std::string>("");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These will be double values.

Copy link
Contributor Author

@dan-du-car dan-du-car Aug 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://usdot-carma.atlassian.net/wiki/spaces/CRMSIM/pages/2563899417/Detected+Objects+Specification
Sample value for the covariance below:

 "positionCovariance" : ["a11", "a12", "a13", "a21", "a22", "a23", "a31", "a32", "a33"]   

// Cartesian positiion of object. Assumed to be ENU coordinate frame.
tmx::utils::Point position = tmx::utils::Point();
typedef struct Position{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be worth while creating separate .h files for some of these classes in the messages package. This will allow reuse of these types in future messages which I think it pretty likely. It also makes this class more readable since it will not include object definitions of nest objects amongst its own member declaration

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add unit test covering to and from json serialization. I can provide example json payloads for testing

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include tests to cover to and from JSON serialization. I can provide a sample SensorDetectedObject message

Copy link
Contributor

@paulbourelly999 paulbourelly999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have provided a sample message to test against. TMX will turn all doubles into strings during JSON serialization but other than that it should be the same.

@paulbourelly999
Copy link
Contributor

paulbourelly999 commented Aug 12, 2024

@dan-du-car We also need to add the Messages package to the sonar properties file. It does not seem to currently be added. Because of this I do not think we are getting code smells or coverage metrics to this package.

@dan-du-car dan-du-car marked this pull request as draft August 12, 2024 22:22
@dan-du-car dan-du-car marked this pull request as ready for review August 13, 2024 13:12

TEST_F(SensorDetectedObjectTest, deserialize){
auto tmxSdsmPtr2 = std::make_shared<SensorDetectedObject>();
std::string expectedStr = "{\"isSimulated\":1,\"type\":\"CAR\",\"confidence\":1.0,\"sensorId\":\"IntersectionLidar\",\"projString\":\"+proj=tmerc +lat_0=0 +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +geoidgrids=egm96_15.gtx +vunits=m +no_defs\",\"objectId\":207,\"position\":{\"x\":-5.021,\"y\":64.234,\"z\":-10.297},\"positionCovariance\":[[0.04000000000000001,0.0,0.0],[0.0,0.04000000000000001,0.0],[0.0,0.0,0.04000000000000001]],\"velocity\":{\"x\":0.0,\"y\":0.0,\"z\":0.0},\"velocityCovariance\":[[0.04000000000000001,0.0,0.0],[0.0,0.04000000000000001,0.0],[0.0,0.0,0.04000000000000001]],\"angularVelocity\":{\"x\":0.0,\"y\":-0.0,\"z\":-0.0},\"angularVelocityCovariance\":[[0.010000000000000002,0.0,0.0],[0.0,0.010000000000000002,0.0],[0.0,0.0,0.010000000000000002]],\"size\":{\"length\":2.257,\"height\":1.003,\"width\":0.762},\"timestamp\":110200}";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT is there a reason we are not using raw string here. Makes the input more readable.

std::string expectedStr = R"(
{
  "isSimulated": 1,
  "type": "CAR",
  "confidence": 1,
  "sensorId": "IntersectionLidar",
  "projString": "+proj=tmerc +lat_0=0 +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +geoidgrids=egm96_15.gtx +vunits=m +no_defs",
  "objectId": 207,
  "position": {
    "x": -5.021,
    "y": 64.234,
    "z": -10.297
  },
  "positionCovariance": [
    [
      0.04000000000000001,
      0,
      0
    ],
    [
      0,
      0.04000000000000001,
      0
    ],
    [
      0,
      0,
      0.04000000000000001
    ]
  ],
  "velocity": {
    "x": 0,
    "y": 0,
    "z": 0
  },
  "velocityCovariance": [
    [
      0.04000000000000001,
      0,
      0
    ],
    [
      0,
      0.04000000000000001,
      0
    ],
    [
      0,
      0,
      0.04000000000000001
    ]
  ],
  "angularVelocity": {
    "x": 0,
    "y": 0,
    "z": 0
  },
  "angularVelocityCovariance": [
    [
      0.010000000000000002,
      0,
      0
    ],
    [
      0,
      0.010000000000000002,
      0
    ],
    [
      0,
      0,
      0.010000000000000002
    ]
  ],
  "size": {
    "length": 2.257,
    "height": 1.003,
    "width": 0.762
  },
  "timestamp": 110200
}
)"

Copy link
Contributor

@paulbourelly999 paulbourelly999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comment about using raw string literals and then one additional comment. Have you looked into resolving the code smell related to typedef vs using.

Copy link

sonarcloud bot commented Aug 13, 2024

@paulbourelly999 paulbourelly999 merged commit be5a5af into develop Aug 13, 2024
3 checks passed
@paulbourelly999 paulbourelly999 deleted the fix_tmx_sensordetectedobject branch August 13, 2024 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants