-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
Signed-off-by: Franco Cipollone <[email protected]>
test/export/mcap_test.py
Outdated
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
# 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. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
CI will fail until #41 is merged |
There was a problem hiding this 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.
test/export/mcap_test.py
Outdated
from mcap.reader import make_reader | ||
|
||
|
||
def GetRoadNetwork(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def GetRoadNetwork(): | |
def get_road_network() -> maliput.api.RoadNetwork: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
test/export/mcap_test.py
Outdated
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 |
There was a problem hiding this comment.
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.
# 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. |
There was a problem hiding this comment.
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.
Signed-off-by: Franco Cipollone <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
🎉 New feature
Related to #23
Summary
Checklist