-
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Builds up RoadGeometry out of parsed information. #40
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3be34fe
Builds up RoadGeometry out of parsed information.
francocipollone 872a9ef
Merge branch 'main' into francocipollone/migrate_manager
francocipollone 9d26ba9
Updates with last changes in main.
francocipollone c956ced
Addresses comments.
francocipollone File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// BSD 3-Clause License | ||
// | ||
// Copyright (c) 2022, Woven Planet. | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are met: | ||
// | ||
// * Redistributions of source code must retain the above copyright notice, this | ||
// list of conditions and the following disclaimer. | ||
// | ||
// * Redistributions in binary form must reproduce the above copyright notice, | ||
// this list of conditions and the following disclaimer in the documentation | ||
// and/or other materials provided with the distribution. | ||
// | ||
// * Neither the name of the copyright holder nor the names of its | ||
// contributors may be used to endorse or promote products derived from | ||
// this software without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
#pragma once | ||
|
||
#include <map> | ||
#include <optional> | ||
#include <string> | ||
|
||
#include <maliput/api/road_geometry.h> | ||
#include <maliput/math/vector.h> | ||
|
||
namespace maliput_sparse { | ||
namespace loader { | ||
|
||
/// Holds the configuration parameters for the builder. | ||
struct BuilderConfiguration { | ||
/// Create a BuilderConfiguration from a string dictionary. | ||
static BuilderConfiguration FromMap(const std::map<std::string, std::string>& config); | ||
|
||
/// @details The keys of the map are listed at @ref builder_configuration_keys. | ||
/// @returns A string-string map containing the builder configuration. | ||
std::map<std::string, std::string> ToStringMap() const; | ||
|
||
/// Id of the road geometry. | ||
maliput::api::RoadGeometryId road_geometry_id{"maliput_sparse"}; | ||
/// Linear resolution of the road geometry. | ||
double linear_tolerance{1.e-3}; | ||
/// Angular resolution of the road geometry. | ||
double angular_tolerance{1.e-3}; | ||
/// Scale factor for road geometry. | ||
double scale_length{1.}; | ||
/// Translation from maliput to maliput_sparse inertial frame. | ||
maliput::math::Vector3 inertial_to_backend_frame_translation{}; | ||
/// Path to the configuration file to load a RuleRegistry | ||
std::optional<std::string> rule_registry{std::nullopt}; | ||
/// Path to the configuration file to load a RoadRulebook | ||
std::optional<std::string> road_rule_book{std::nullopt}; | ||
/// Path to the configuration file to load a TrafficLightBook. | ||
std::optional<std::string> traffic_light_book{std::nullopt}; | ||
/// Path to the configuration file to load a PhaseRingBook. | ||
std::optional<std::string> phase_ring_book{std::nullopt}; | ||
/// Path to the configuration file to load an IntersectionBook. | ||
std::optional<std::string> intersection_book{std::nullopt}; | ||
}; | ||
|
||
} // namespace loader | ||
} // namespace maliput_sparse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// BSD 3-Clause License | ||
// | ||
// Copyright (c) 2022, Woven Planet. | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are met: | ||
// | ||
// * Redistributions of source code must retain the above copyright notice, this | ||
// list of conditions and the following disclaimer. | ||
// | ||
// * Redistributions in binary form must reproduce the above copyright notice, | ||
// this list of conditions and the following disclaimer in the documentation | ||
// and/or other materials provided with the distribution. | ||
// | ||
// * Neither the name of the copyright holder nor the names of its | ||
// contributors may be used to endorse or promote products derived from | ||
// this software without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
#pragma once | ||
|
||
#include <maliput/api/road_geometry.h> | ||
#include <maliput/math/vector.h> | ||
|
||
namespace maliput_sparse { | ||
namespace loader { | ||
namespace config { | ||
|
||
/// @defgroup builder_configuration_keys RoadNetwork configuration builder keys | ||
/// | ||
/// Parameters used during the RoadNetwork building process. | ||
/// | ||
/// When parameters are omitted the default value will be used. | ||
/// | ||
/// @{ | ||
|
||
/// A string that works as ID of the RoadGeometry. | ||
/// - Default: @e "maliput" | ||
static constexpr char const* kRoadGeometryId{"road_geometry_id"}; | ||
|
||
/// RoadGeometry's linear tolerance. | ||
/// - Default: @e "5e-2" | ||
static constexpr char const* kLinearTolerance{"linear_tolerance"}; | ||
|
||
/// RoadGeometry's angular tolerance. | ||
/// - Default: @e "1e-3" | ||
static constexpr char const* kAngularTolerance{"angular_tolerance"}; | ||
|
||
/// RoadGeometry's scale length. | ||
/// - Default: @e "1.0" | ||
static constexpr char const* kScaleLength{"scale_length"}; | ||
|
||
/// Translation from maliput to maliput_osm inertial frame. | ||
/// The format of the 3-dimensional vector that is expected to be passed | ||
/// should be {X, Y, Z}. Same format as maliput::math::Vector3 is | ||
/// serialized. | ||
/// - Default: @e "{0., 0., 0.}" | ||
static constexpr char const* kInertialToBackendFrameTranslation{"inertial_to_backend_frame_translation"}; | ||
|
||
/// Path to the configuration file to load a RoadRulebook | ||
/// - Default: "" | ||
static constexpr char const* kRoadRuleBook{"road_rule_book"}; | ||
|
||
/// Path to the configuration file to load a RoadRulebook | ||
/// - Default: "" | ||
static constexpr char const* kRuleRegistry{"rule_registry"}; | ||
|
||
/// Path to the configuration file to load a TrafficLightBook | ||
/// - Default: "" | ||
static constexpr char const* kTrafficLightBook{"traffic_light_book"}; | ||
|
||
/// Path to the configuration file to load a PhaseRingBook | ||
/// - Default: "" | ||
static constexpr char const* kPhaseRingBook{"phase_ring_book"}; | ||
|
||
/// Path to the configuration file to load a IntersectionBook | ||
/// - Default: "" | ||
static constexpr char const* kIntersectionBook{"intersection_book"}; | ||
|
||
/// @} | ||
|
||
} // namespace config | ||
} // namespace loader | ||
} // namespace maliput_sparse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// BSD 3-Clause License | ||
// | ||
// Copyright (c) 2022, Woven Planet. | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are met: | ||
// | ||
// * Redistributions of source code must retain the above copyright notice, this | ||
// list of conditions and the following disclaimer. | ||
// | ||
// * Redistributions in binary form must reproduce the above copyright notice, | ||
// this list of conditions and the following disclaimer in the documentation | ||
// and/or other materials provided with the distribution. | ||
// | ||
// * Neither the name of the copyright holder nor the names of its | ||
// contributors may be used to endorse or promote products derived from | ||
// this software without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
#pragma once | ||
|
||
#include <memory> | ||
|
||
#include <maliput/api/road_geometry.h> | ||
|
||
#include "maliput_sparse/loader/builder_configuration.h" | ||
#include "maliput_sparse/parser/parser.h" | ||
|
||
namespace maliput_sparse { | ||
namespace loader { | ||
|
||
/// Loads a RoadGeometry based on a maliput_sparse::parser::Parser implementation. | ||
/// This functor is expected to be used by the maliput backends that rely on | ||
/// maliput_sparse to load the RoadGeometry. | ||
class RoadGeometryLoader { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: missing class docstring. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
public: | ||
/// Constructs a RoadGeometryLoader. | ||
/// @param parser The parser to use for building the RoadGeometry. | ||
/// @param builder_configuration The configuration of the builder. | ||
RoadGeometryLoader(std::unique_ptr<parser::Parser> parser, const BuilderConfiguration& builder_configuration); | ||
|
||
/// Builds a RoadGeometry. | ||
std::unique_ptr<const maliput::api::RoadGeometry> operator()(); | ||
|
||
private: | ||
const std::unique_ptr<parser::Parser> parser_; | ||
const BuilderConfiguration builder_configuration_; | ||
}; | ||
|
||
} // namespace loader | ||
} // namespace maliput_sparse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// BSD 3-Clause License | ||
// | ||
// Copyright (c) 2022, Woven Planet. | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are met: | ||
// | ||
// * Redistributions of source code must retain the above copyright notice, this | ||
// list of conditions and the following disclaimer. | ||
// | ||
// * Redistributions in binary form must reproduce the above copyright notice, | ||
// this list of conditions and the following disclaimer in the documentation | ||
// and/or other materials provided with the distribution. | ||
// | ||
// * Neither the name of the copyright holder nor the names of its | ||
// contributors may be used to endorse or promote products derived from | ||
// this software without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
#pragma once | ||
|
||
#include <memory> | ||
|
||
#include <maliput/api/road_network.h> | ||
|
||
#include "maliput_sparse/loader/builder_configuration.h" | ||
#include "maliput_sparse/loader/road_geometry_loader.h" | ||
#include "maliput_sparse/parser/parser.h" | ||
|
||
namespace maliput_sparse { | ||
namespace loader { | ||
|
||
/// Loads a RoadNetwork based on a maliput_sparse::parser::Parser implementation. | ||
/// This functor is expected to be used by the maliput backends that rely on | ||
/// maliput_sparse to load the RoadNetwork. | ||
class RoadNetworkLoader { | ||
public: | ||
/// Constructs a RoadNetworkLoader. | ||
/// @param parser The parser to use for building the RoadNetworkLoader. | ||
/// @param builder_configuration The configuration of the builder. | ||
RoadNetworkLoader(std::unique_ptr<parser::Parser> parser, const BuilderConfiguration& builder_configuration); | ||
|
||
/// Builds a RoadNetworkLoader. | ||
std::unique_ptr<maliput::api::RoadNetwork> operator()(); | ||
|
||
private: | ||
const std::unique_ptr<RoadGeometryLoader> road_geometry_loader_; | ||
const BuilderConfiguration builder_configuration_; | ||
}; | ||
|
||
} // namespace loader | ||
} // namespace maliput_sparse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// BSD 3-Clause License | ||
// | ||
// Copyright (c) 2022, Woven Planet. | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are met: | ||
// | ||
// * Redistributions of source code must retain the above copyright notice, this | ||
// list of conditions and the following disclaimer. | ||
// | ||
// * Redistributions in binary form must reproduce the above copyright notice, | ||
// this list of conditions and the following disclaimer in the documentation | ||
// and/or other materials provided with the distribution. | ||
// | ||
// * Neither the name of the copyright holder nor the names of its | ||
// contributors may be used to endorse or promote products derived from | ||
// this software without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
#pragma once | ||
|
||
#include "maliput_sparse/parser/lane.h" | ||
|
||
namespace maliput_sparse { | ||
namespace parser { | ||
|
||
/// Defines a connection between two lanes. | ||
/// The lanes can be connected from either end. | ||
/// Two connections are considered equal if they connect the same lanes using same ends without regard to the order. | ||
struct Connection { | ||
/// The LaneEnd that is connected from. | ||
LaneEnd from; | ||
/// The LaneEnd that is connected to. | ||
LaneEnd to; | ||
|
||
/// Equality operator. | ||
bool operator==(const Connection& other) const; | ||
}; | ||
|
||
} // namespace parser | ||
} // namespace maliput_sparse |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think that we should make these free functions to keep the style of other repositories.
Consider deleting constructors if you want to enforce a specific way of contring from a map this struct.
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.
Sorry, I am not seeing the full picture here, why make them free functions?
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 a nit.
The comment was to keep PODs as structs or convert them to classes to have functions like these.
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.
Ah I see, thanks for the clarification. Let me move forward with this PR and create an issue for improving the style on that.
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.
#44