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
Builder for BranchPoints #24
Conversation
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
@francocipollone I would appreciate your review on 90ccc36. I am mostly interested in knowing your thoughts on its use. |
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 overall.
I agree with the proposed api for the branchpoint building. I left some minor comments.
Populating the branchpoints is something that in general has to be implemented in each backend. I think that having this helper as agnostic to the backend as it is at maliput::base could be beneficial to avoid reimplementing code? Wdyt?
@@ -337,6 +376,12 @@ class RoadGeometryBuilder final { | |||
void SetJunction(maliput::common::Passkey<JunctionBuilder>, | |||
std::unique_ptr<maliput::geometry_base::Junction> junction); | |||
|
|||
void SetBranchPoints(maliput::common::Passkey<BranchPointBuilder>, |
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.
Missing docstring
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.
src/builder/builder.cc
Outdated
std::set<BranchPointBuilder::LaneEnd> b_side{}; | ||
}; | ||
|
||
// Proivdes maliput::api::BranchPointId with an increasing counter to make each ID |
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.
typo: Proivdes
to Provides
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.
src/builder/builder.cc
Outdated
} | ||
|
||
private: | ||
int branch_point_count_{0}; |
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.
could be unsigned as negatives aren't being used?
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.
Yes but it actually won't go negative until we go over int range. Do you think this is a problem?
|
||
void RoadGeometryBuilder::SetBranchPoints( | ||
maliput::common::Passkey<BranchPointBuilder>, | ||
std::vector<std::unique_ptr<maliput::geometry_base::BranchPoint>>&& branch_points) { |
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.
We probably have to assert that the vector isn't size zero also.
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.
src/builder/builder.cc
Outdated
for (int i = 0; i < junction->num_segments(); ++i) { | ||
const maliput::api::Segment* segment = junction->segment(j); | ||
for (int j = 0; j < segment->num_lanes(); ++j) { | ||
maliput::geometry_base::Lane* lane = segment->lane(j); |
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.
nit: add const
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.
src/builder/builder.cc
Outdated
const maliput::api::LaneId& lane_id_a, const maliput::api::LaneEnd::Which which_a, | ||
const maliput::api::LaneId& lane_id_b, const maliput::api::LaneEnd::Which which_b) { | ||
const LaneEnd lane_end_a = std::make_pair(lane_id_a, which_a); | ||
const LaneEnd lane_end_b = std::make_pair(lane_id_a, which_b); |
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.
const LaneEnd lane_end_b = std::make_pair(lane_id_a, which_b); | |
const LaneEnd lane_end_b = std::make_pair(lane_id_b, which_b); |
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.
Changed the implementation.
src/builder/builder.cc
Outdated
it_a_side->b_side.insert(b_side_set.begin(), b_side_set.end()); | ||
} else if (it_b_side != branch_point_sets->end()) { | ||
auto a_side_set = GetLaneEndSet(lane_end, lane_ends); | ||
it_b_side->b_side.insert(a_side_set.begin(), a_side_set.end()); |
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_b_side->b_side.insert(a_side_set.begin(), a_side_set.end()); | |
it_b_side->b_side.insert(b_side_set.begin(), a_side_set.end()); |
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.
Changed the implementation.
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
8ee9c24
to
e6bca61
Compare
This PR now depends on maliput/maliput#524 |
I've just triggered CI again @francocipollone |
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! Nice job! This is a great addition!
src/builder/builder.cc
Outdated
auto range_a_b = lane_ends_.equal_range(lane_end_a); | ||
auto range_b_a = lane_ends_.equal_range(lane_end_b); |
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.
can't these be const?
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.
Yes, good catch!
src/builder/builder.cc
Outdated
// When @p lane_ends appears on the A side of a BranchPointSets, the B side of such entity is updated. | ||
// When @p lane_ends appears on the B side of a BranchPointSets, the A side of such entity is updated. |
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.
// When @p lane_ends appears on the A side of a BranchPointSets, the B side of such entity is updated. | |
// When @p lane_ends appears on the B side of a BranchPointSets, the A side of such entity is updated. | |
// When @p lane_end appears on the A side of a BranchPointSets, the B side of such entity is updated. | |
// When @p lane_end appears on the B side of a BranchPointSets, the A side of such entity is updated. |
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. Changed a bit the entire docstring.
src/builder/builder.cc
Outdated
return branch_point; | ||
} | ||
|
||
const std::unordered_map<maliput::api::LaneId, const maliput::geometry_base::Lane*> lanes_; |
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.
can't you receive a reference here instead of copying the unordered map?
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! Thanks for catching it.
ASSERT_TRUE(lane_end_is_in(lane_a->GetOngoingBranches(finish)->get(0), expected_lane_ends)); | ||
ASSERT_TRUE(lane_end_is_in(lane_a->GetOngoingBranches(finish)->get(1), expected_lane_ends)); | ||
ASSERT_TRUE(lane_end_is_in(lane_a->GetOngoingBranches(finish)->get(2), expected_lane_ends)); |
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.
nit: This might hide one case:
- when get(0), get(1) and get(2) returns the same value for example.
expected_lane_ends
should be iterated and for each value, there should be one value in the lane_a->GetOngoingBranches(finish)
set that matches.
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.
You are right. I did not think of it. Let me address that in a follow up PR.
Signed-off-by: Agustin Alba Chicar <ag.albachicar@gmail.com>
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.
🥇
🎉 New feature
Part of #10
Summary
Implements the BranchPoint builder.
Test it
Via unit tests (not yet).
Checklist
Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
messages.Note to maintainers: this PR is in draft state. There are missing tests and it doesn't compile yet but it just aims to show how it would be used for preliminary discussions.