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

Adds tests for mcap export. #42

Merged
merged 4 commits into from
Jul 25, 2023
Merged

Conversation

francocipollone
Copy link
Contributor

🎉 New feature

Related to #23

Summary

  • Adds tests for mcap exporter

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if it affects the public API)

Signed-off-by: Franco Cipollone <[email protected]>
Comment on lines 50 to 64
def GetRoadNetwork():
"""
Returns an arbitrary road network.
"""
# TODO(#12): Rely on a road network loader once that is implemented.
# Create road network model
env = os.getenv("MALIPUT_MALIDRIVE_RESOURCE_ROOT").split(":")
env = env[0]
rn_configuration = {
"opendrive_file": env + "/resources/odr/TShapeRoad.xodr" if env is not None else "",
"road_geometry_id": "TShapeRoadRoadNetwork"
}
maliput_road_network = create_road_network(
"maliput_malidrive", rn_configuration)
return maliput_road_network
Copy link
Contributor Author

Choose a reason for hiding this comment

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

My first approach was to mock the road network and to patch the call to maliput_sim.utils.obj.get_obj_description(road_network) (which happens within mcap exporter) for returning a known obj description instead of having to load up the road network.

For a reason that I don't know I couldn't make it work, the patch didn't work out, so I ended up loading up a road network.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's fine. We can revisit this in the future if required.

Comment on lines +199 to +207
# TODO: Check the content of the message.

pose_msgs = list(reader.iter_decoded_messages(
topics=["/agent_1/pose"]))
# Pose msg isn't being published in first iteration.
self.assertEqual(len(pose_msgs), 2)
for schema, channel, message, proto_msg in pose_msgs:
self.assertEqual(schema.name, "foxglove.Pose")
# TODO: Check the content of the message.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added some TODOs here for checking out the content of the message to verify that the content being written is the desired content. I plan to leave this to a follow PR to avoid delaying more on having this tested and to increse the LOC in this PR

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good. I recommend using a template that you simply match rather than verifying the contents of the message one by one.

@francocipollone
Copy link
Contributor Author

CI will fail until #41 is merged

Copy link
Contributor

@agalbachicar agalbachicar left a comment

Choose a reason for hiding this comment

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

Just a few comments, ptal.

from mcap.reader import make_reader


def GetRoadNetwork():
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def GetRoadNetwork():
def get_road_network() -> maliput.api.RoadNetwork:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment on lines 50 to 64
def GetRoadNetwork():
"""
Returns an arbitrary road network.
"""
# TODO(#12): Rely on a road network loader once that is implemented.
# Create road network model
env = os.getenv("MALIPUT_MALIDRIVE_RESOURCE_ROOT").split(":")
env = env[0]
rn_configuration = {
"opendrive_file": env + "/resources/odr/TShapeRoad.xodr" if env is not None else "",
"road_geometry_id": "TShapeRoadRoadNetwork"
}
maliput_road_network = create_road_network(
"maliput_malidrive", rn_configuration)
return maliput_road_network
Copy link
Contributor

Choose a reason for hiding this comment

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

It's fine. We can revisit this in the future if required.

test/export/mcap_test.py Outdated Show resolved Hide resolved
test/export/mcap_test.py Outdated Show resolved Hide resolved
test/export/mcap_test.py Outdated Show resolved Hide resolved
test/export/mcap_test.py Outdated Show resolved Hide resolved
test/export/mcap_test.py Outdated Show resolved Hide resolved
Comment on lines +199 to +207
# TODO: Check the content of the message.

pose_msgs = list(reader.iter_decoded_messages(
topics=["/agent_1/pose"]))
# Pose msg isn't being published in first iteration.
self.assertEqual(len(pose_msgs), 2)
for schema, channel, message, proto_msg in pose_msgs:
self.assertEqual(schema.name, "foxglove.Pose")
# TODO: Check the content of the message.
Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good. I recommend using a template that you simply match rather than verifying the contents of the message one by one.

test/export/mcap_test.py Show resolved Hide resolved
Copy link
Contributor

@agalbachicar agalbachicar left a comment

Choose a reason for hiding this comment

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

LGTM

@francocipollone francocipollone merged commit 4171171 into main Jul 25, 2023
@francocipollone francocipollone deleted the francocipollone/mcap_tests branch July 25, 2023 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants