Skip to content

Commit

Permalink
Add curbs to the builder.
Browse files Browse the repository at this point in the history
Signed-off-by: Agustin Alba Chicar <[email protected]>
  • Loading branch information
agalbachicar committed Feb 5, 2024
1 parent 2b62902 commit aab2317
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/maliput_malidrive/builder/builder_tools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const std::map<xodr::Lane::Type, XodrLaneProperties> kXodrLaneTypesToMaliputProp
{xodr::Lane::Type::kBorder, {false, "NonVehicles", {}}},
{xodr::Lane::Type::kRestricted, {false, "NonVehicles", {}}},
{xodr::Lane::Type::kParking, {false, "Unrestricted", {}}},
{xodr::Lane::Type::kCurb, {false, "NonVehicles", {}}},
{xodr::Lane::Type::kMwyEntry, {true, "NonPedestrians", {"MotorizedVehicleOnly"}}},
{xodr::Lane::Type::kMwyExit, {true, "NonPedestrians", {"MotorizedVehicleOnly"}}},
{xodr::Lane::Type::kSpecial1, {true, "NonPedestrians", {}}},
Expand Down
2 changes: 2 additions & 0 deletions src/maliput_malidrive/xodr/lane.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const std::map<std::string, Lane::Type> str_to_type_map{
{"border", Lane::Type::kBorder},
{"restricted", Lane::Type::kRestricted},
{"parking", Lane::Type::kParking},
{"curb", Lane::Type::kCurb},
{"bidirectional", Lane::Type::kBidirectional},
{"median", Lane::Type::kMedian},
{"special1", Lane::Type::kSpecial1},
Expand Down Expand Up @@ -73,6 +74,7 @@ const std::map<Lane::Type, std::string> type_to_str_map{
{Lane::Type::kBorder, "border"},
{Lane::Type::kRestricted, "restricted"},
{Lane::Type::kParking, "parking"},
{Lane::Type::kCurb, "curb"},
{Lane::Type::kBidirectional, "bidirectional"},
{Lane::Type::kMedian, "median"},
{Lane::Type::kSpecial1, "special1"},
Expand Down
1 change: 1 addition & 0 deletions src/maliput_malidrive/xodr/lane.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ struct Lane {
kBorder,
kRestricted,
kParking,
kCurb,
/// `bidirectional` could be used on a narrow road which may be used in both directios or in a continuous two-way
/// left turn lane on multi-lane roads.
kBidirectional,
Expand Down
63 changes: 53 additions & 10 deletions test/regression/xodr/lane_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,65 @@ GTEST_TEST(LaneSpeed, EqualityOperator) {
EXPECT_EQ(kSpeed, speed);
};

GTEST_TEST(Lane, TypeToStr) {
const std::string kExpected1{"driving"};
const std::string kExpected2{"shoulder"};
EXPECT_EQ(kExpected1, Lane::type_to_str(Lane::Type::kDriving));
EXPECT_EQ(kExpected2, Lane::type_to_str(Lane::Type::kShoulder));
// Holds the Lane::Type and its string representation.
struct LaneTypeAndStrType {
Lane::Type type{};
std::string str_type{};
};

// Provides a list with all the Lane::Type and its string representations.
std::vector<LaneTypeAndStrType> GetTestingLaneTypeAndStringTypes() {
return std::vector<LaneTypeAndStrType>{
{Lane::Type::kNone, "none"},
{Lane::Type::kDriving, "driving"},
{Lane::Type::kStop, "stop"},
{Lane::Type::kShoulder, "shoulder"},
{Lane::Type::kBiking, "biking"},
{Lane::Type::kSidewalk, "sidewalk"},
{Lane::Type::kBorder, "border"},
{Lane::Type::kRestricted, "restricted"},
{Lane::Type::kParking, "parking"},
{Lane::Type::kCurb, "curb"},
{Lane::Type::kBidirectional, "bidirectional"},
{Lane::Type::kMedian, "median"},
{Lane::Type::kSpecial1, "special1"},
{Lane::Type::kSpecial2, "special2"},
{Lane::Type::kSpecial3, "special3"},
{Lane::Type::kRoadWorks, "roadworks"},
{Lane::Type::kTram, "tram"},
{Lane::Type::kRail, "rail"},
{Lane::Type::kEntry, "entry"},
{Lane::Type::kExit, "exit"},
{Lane::Type::kOffRamp, "offRamp"},
{Lane::Type::kOnRamp, "onRamp"},
{Lane::Type::kConnectingRamp, "connectingRamp"},
{Lane::Type::kBus, "bus"},
{Lane::Type::kTaxi, "taxi"},
{Lane::Type::kHOV, "hov"},
{Lane::Type::kMwyEntry, "mwyEntry"},
{Lane::Type::kMwyExit, "mwyExit"},
};
}

GTEST_TEST(Lane, StrToType) {
const std::string kDriving{"driving"};
const std::string kShoulder{"shoulder"};
EXPECT_EQ(Lane::Type::kDriving, Lane::str_to_type(kDriving));
EXPECT_EQ(Lane::Type::kShoulder, Lane::str_to_type(kShoulder));
// Tests Lane::Type to and from string conversion.
class TypeStringConversionTest : public ::testing::TestWithParam<LaneTypeAndStrType> {
public:
const Lane::Type type_{GetParam().type};
const std::string str_type_{GetParam().str_type};
};

TEST_P(TypeStringConversionTest, TypeToStr) { ASSERT_EQ(str_type_, Lane::type_to_str(type_)); }

TEST_P(TypeStringConversionTest, StrToType) { ASSERT_EQ(type_, Lane::str_to_type(str_type_)); }

GTEST_TEST(LaneTypeTest, StrToTypeThrowsWithUnknownToken) {
const std::string kWrongValue{"WrongValue"};
EXPECT_THROW(Lane::str_to_type(kWrongValue), maliput::common::assertion_error);
}

INSTANTIATE_TEST_CASE_P(GroupTypeStringConversionTest, TypeStringConversionTest,
::testing::ValuesIn(GetTestingLaneTypeAndStringTypes()));

GTEST_TEST(Lane, EqualityOperator) {
const LaneLink lane_link{LaneLink::LinkAttributes{LaneLink::LinkAttributes::Id("35")},
LaneLink::LinkAttributes{LaneLink::LinkAttributes::Id("70")}};
Expand Down

0 comments on commit aab2317

Please sign in to comment.