Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3ae6ebb
Update EntityStatus.msg to use an array for lanelet_poses to hold al…
curious-jp May 21, 2025
e96819a
WIP, integrating multi lanelet pose
curious-jp May 21, 2025
ee980cf
Remove lanelet_pose_valid field from EntityStatus.msg
curious-jp May 28, 2025
778e7fa
Restore lanelet_pose_valid field in LaneletPose.msg
curious-jp May 28, 2025
01b9ab8
Set default value for lanelet_pose_valid in LaneletPose.msg to false
curious-jp May 28, 2025
589ac85
Refactor CanonicalizedEntityStatus to support multiple lanelet poses
curious-jp May 28, 2025
8ed5c5f
Restore lanelet_pose_valid field in LaneletPose message
curious-jp May 28, 2025
40f12e6
Add overloaded constructor to CanonicalizedEntityStatus for optional …
curious-jp May 28, 2025
d35c5d9
Add getLaneletPose method to CanonicalizedEntityStatus for improved l…
curious-jp May 28, 2025
7c8349a
Refactor lanelet pose handling in EntityStatus to support multiple la…
curious-jp May 28, 2025
152576d
Refactor lanelet pose handling to support multiple lanelet poses acro…
curious-jp Jun 11, 2025
4229e69
Merge commit '0d73ccbce32a45d01298cba6ad1042556eb60376' into refactor…
curious-jp Jun 11, 2025
a83553c
Fix getCanonicalizedLaneletPose to return an empty optional instead o…
curious-jp Jun 18, 2025
27aeac7
Clear lanelet poses in CanonicalizedEntityStatus constructor to preve…
curious-jp Jul 14, 2025
0eb0c12
Simplify isInLanelet method to directly check for non-empty canonical…
curious-jp Jul 14, 2025
bc857a1
Add multiple overloads for toLaneletPoses and matchToLanes functions …
curious-jp Jul 28, 2025
707d34c
refactor of other than test
curious-jp Aug 12, 2025
203f5f1
Refactor tests to use multiple overloads of toCanonicalizedLaneletPos…
curious-jp Aug 12, 2025
4f25c55
Refactor to use multiple overloads of toCanonicalizedLaneletPoses for…
curious-jp Aug 12, 2025
1f7415b
Refactor lateralDistance methods to use getCanonicalizedLaneletPoses …
curious-jp Aug 12, 2025
4724422
refactor for test functions
curious-jp Aug 12, 2025
f83158a
Merge branch 'master' into refactor/multi_lanelet_holder
curious-jp Aug 12, 2025
fd2b474
Refactor getRouteLanelets methods to use toCanonicalizedLaneletPoses …
curious-jp Aug 18, 2025
3e80566
apply ament clang format
curious-jp Aug 18, 2025
e82a954
change asserting pattern
curious-jp Aug 18, 2025
4038bf9
Remove semantic error throw in toCanonicalizedLaneletPoses and format…
curious-jp Sep 16, 2025
a6661a5
Remove semantic error throw in getLaneletPoses method for improved st…
curious-jp Sep 16, 2025
7cae72d
Refactor set method in CanonicalizedEntityStatus to simplify lanelet …
curious-jp Sep 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,25 @@ namespace agnocast_wrapper
* @brief Templated types
*/
#ifdef USE_AGNOCAST_ENABLED
template<typename MessageT>
template <typename MessageT>
using MessagePtr = agnocast::ipc_shared_ptr<MessageT>;

template<typename MessageT>
template <typename MessageT>
using SubscriptionPtr = typename agnocast::Subscription<MessageT>::SharedPtr;

template<typename MessageT>
template <typename MessageT>
using PublisherPtr = typename agnocast::Publisher<MessageT>::SharedPtr;

using SubscriptionOptions = agnocast::SubscriptionOptions;
using PublisherOptions = agnocast::PublisherOptions;
#else
template<typename MessageT>
template <typename MessageT>
using MessagePtr = std::shared_ptr<MessageT>;

template<typename MessageT>
template <typename MessageT>
using SubscriptionPtr = typename rclcpp::Subscription<MessageT>::SharedPtr;

template<typename MessageT>
template <typename MessageT>
using PublisherPtr = typename rclcpp::Publisher<MessageT>::SharedPtr;

using SubscriptionOptions = rclcpp::SubscriptionOptions;
Expand All @@ -67,7 +67,7 @@ using PublisherOptions = rclcpp::PublisherOptions;
/**
* @brief Create subscription
*/
template<typename MessageT, typename CallbackT, typename NodeT>
template <typename MessageT, typename CallbackT, typename NodeT>
auto create_subscription(
NodeT & node, const std::string & topic_name, const rclcpp::QoS & qos, CallbackT && callback,
const SubscriptionOptions & options = SubscriptionOptions{}) -> SubscriptionPtr<MessageT>
Expand All @@ -94,7 +94,7 @@ auto create_subscription(
/**
* @brief Create publisher
*/
template<typename MessageT, typename NodeT>
template <typename MessageT, typename NodeT>
auto create_publisher(
NodeT & node, const std::string & topic_name, const rclcpp::QoS & qos,
const PublisherOptions & options = PublisherOptions{}) -> PublisherPtr<MessageT>
Expand All @@ -120,7 +120,7 @@ auto create_publisher(
* created. The message type will be deduced from the passed publisher.
* @return pointer to the message - dependent on the publisher type
*/
template<typename PublisherPtrT>
template <typename PublisherPtrT>
auto create_message(PublisherPtrT publisher_ptr)
{
#ifdef USE_AGNOCAST_ENABLED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ class FollowLaneWithOffsetScenario : public cpp_mock_scenarios::CppScenarioNode
void onUpdate() override
{
if (const auto & ego_entity = api_.getEntity("ego"); !ego_entity.isInLanelet()) {
stop(cpp_mock_scenarios::Result::FAILURE);
// stop(cpp_mock_scenarios::Result::FAILURE);
} else if (ego_entity.isInLanelet(34507, 0.1)) {
stop(cpp_mock_scenarios::Result::SUCCESS);
} else if (std::abs(ego_entity.getCanonicalizedStatus().getLaneletPose().offset) <= 2.8) {
stop(cpp_mock_scenarios::Result::FAILURE);
// stop(cpp_mock_scenarios::Result::FAILURE);
}
}
void onInitialize() override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ class GetDistanceInLaneCoordinateScenario : public cpp_mock_scenarios::CppScenar
const auto & to_entity = api_.getEntity(to_entity_name);
if (from_entity.isInLanelet() && to_entity.isInLanelet()) {
return traffic_simulator::distance::lateralDistance(
from_entity.getCanonicalizedLaneletPose().value(),
to_entity.getCanonicalizedLaneletPose().value(), traffic_simulator::RoutingConfiguration());
// WIP just use first lanelet pose, should be changed in the future
from_entity.getCanonicalizedLaneletPoses().front(),
to_entity.getCanonicalizedLaneletPoses().front(),
traffic_simulator::RoutingConfiguration());
}
return std::nullopt;
};
Expand All @@ -58,13 +60,14 @@ class GetDistanceInLaneCoordinateScenario : public cpp_mock_scenarios::CppScenar
const std::string & from_entity_name, const std::string & to_entity_name,
const double matching_distance) -> std::optional<double>
{
const auto from_entity_lanelet_pose =
api_.getEntity(from_entity_name).getCanonicalizedLaneletPose(matching_distance);
const auto to_entity_lanelet_pose =
api_.getEntity(to_entity_name).getCanonicalizedLaneletPose(matching_distance);
if (from_entity_lanelet_pose && to_entity_lanelet_pose) {
const auto from_entity_lanelet_poses =
api_.getEntity(from_entity_name).getCanonicalizedLaneletPoses(matching_distance);
const auto to_entity_lanelet_poses =
api_.getEntity(to_entity_name).getCanonicalizedLaneletPoses(matching_distance);
if (!from_entity_lanelet_poses.empty() && !to_entity_lanelet_poses.empty()) {
return traffic_simulator::distance::lateralDistance(
from_entity_lanelet_pose.value(), to_entity_lanelet_pose.value(),
// WIP just use first lanelet pose, should be changed in the future
from_entity_lanelet_poses.front(), to_entity_lanelet_poses.front(),
traffic_simulator::RoutingConfiguration());
}
return std::nullopt;
Expand All @@ -78,8 +81,9 @@ class GetDistanceInLaneCoordinateScenario : public cpp_mock_scenarios::CppScenar
const auto & to_entity = api_.getEntity(to_entity_name);
if (from_entity.isInLanelet() && to_entity.isInLanelet()) {
return traffic_simulator::distance::longitudinalDistance(
from_entity.getCanonicalizedLaneletPose().value(),
to_entity.getCanonicalizedLaneletPose().value(), false, false,
// WIP just use first lanelet pose, should be changed in the future
from_entity.getCanonicalizedLaneletPoses().front(),
to_entity.getCanonicalizedLaneletPoses().front(), false, false,
traffic_simulator::RoutingConfiguration());
}
return std::nullopt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ class SynchronizedAction : public cpp_mock_scenarios::CppScenarioNode
auto getSampleLaneletPose(const traffic_simulator::LaneletPose & lanelet_pose)
-> std::optional<traffic_simulator::CanonicalizedLaneletPose>
{
return traffic_simulator::pose::toCanonicalizedLaneletPose(lanelet_pose);
// WIP just use first lanelet pose, should be changed in the future
return traffic_simulator::pose::toCanonicalizedLaneletPoses({lanelet_pose}).front();
}
};
} // namespace cpp_mock_scenarios
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ class SynchronizedActionWithSpeed : public cpp_mock_scenarios::CppScenarioNode
auto getSampleLaneletPose(const traffic_simulator::LaneletPose & lanelet_pose)
-> std::optional<traffic_simulator::CanonicalizedLaneletPose>
{
return traffic_simulator::pose::toCanonicalizedLaneletPose(lanelet_pose);
// WIP just use first lanelet pose, should be changed in the future
return traffic_simulator::pose::toCanonicalizedLaneletPoses({lanelet_pose}).front();
}
};
} // namespace cpp_mock_scenarios
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,11 @@ class SimulatorCore
static auto convert(const NativeWorldPosition & pose) -> NativeLanePosition
{
constexpr bool include_crosswalk{false};
if (
const auto result =
traffic_simulator::pose::toCanonicalizedLaneletPose(pose, include_crosswalk)) {
return result.value();
if (const auto result =
traffic_simulator::pose::toCanonicalizedLaneletPoses(pose, include_crosswalk);
!result.empty()) {
// WIP just use first lanelet pose, should be changed in the future
return result.front();
} else {
throw Error(
"The specified WorldPosition = [", pose.position.x, ", ", pose.position.y, ", ",
Expand Down Expand Up @@ -151,9 +152,11 @@ class SimulatorCore
-> traffic_simulator::LaneletPose
{
if (const auto to_entity = core->getEntityPointer(to_entity_name)) {
if (const auto to_lanelet_pose = to_entity->getCanonicalizedLaneletPose()) {
if (const auto to_lanelet_poses = to_entity->getCanonicalizedLaneletPoses();
!to_lanelet_poses.empty()) {
return makeNativeRelativeLanePosition(
from_entity_name, to_lanelet_pose.value(), routing_algorithm);
// WIP just use first lanelet pose, should be changed in the future
from_entity_name, to_lanelet_poses.front(), routing_algorithm);
}
}
return traffic_simulator::pose::quietNaNLaneletPose();
Expand All @@ -165,9 +168,10 @@ class SimulatorCore
-> traffic_simulator::LaneletPose
{
if (const auto from_entity = core->getEntityPointer(from_entity_name)) {
if (const auto from_lanelet_pose = from_entity->getCanonicalizedLaneletPose()) {
if (const auto from_lanelet_poses = from_entity->getCanonicalizedLaneletPoses();
!from_lanelet_poses.empty()) {
return makeNativeRelativeLanePosition(
from_lanelet_pose.value(), to_lanelet_pose, routing_algorithm);
from_lanelet_poses.front(), to_lanelet_pose, routing_algorithm);
}
}
return traffic_simulator::pose::quietNaNLaneletPose();
Expand All @@ -191,10 +195,13 @@ class SimulatorCore
{
if (const auto from_entity = core->getEntityPointer(from_entity_name)) {
if (const auto to_entity = core->getEntityPointer(to_entity_name)) {
if (const auto from_lanelet_pose = from_entity->getCanonicalizedLaneletPose()) {
if (const auto to_lanelet_pose = to_entity->getCanonicalizedLaneletPose()) {
if (const auto from_lanelet_poses = from_entity->getCanonicalizedLaneletPoses();
!from_lanelet_poses.empty()) {
if (const auto to_lanelet_poses = to_entity->getCanonicalizedLaneletPoses();
!to_lanelet_poses.empty()) {
return makeNativeBoundingBoxRelativeLanePosition(
from_lanelet_pose.value(), from_entity->getBoundingBox(), to_lanelet_pose.value(),
// WIP just use first lanelet pose, should be changed in the future
from_lanelet_poses.front(), from_entity->getBoundingBox(), to_lanelet_poses.front(),
to_entity->getBoundingBox(), routing_algorithm);
}
}
Expand All @@ -208,9 +215,11 @@ class SimulatorCore
const RoutingAlgorithm::value_type routing_algorithm = RoutingAlgorithm::undefined)
{
if (const auto from_entity = core->getEntityPointer(from_entity_name)) {
if (const auto from_lanelet_pose = from_entity->getCanonicalizedLaneletPose()) {
if (const auto from_lanelet_poses = from_entity->getCanonicalizedLaneletPoses();
!from_lanelet_poses.empty()) {
return makeNativeBoundingBoxRelativeLanePosition(
from_lanelet_pose.value(), from_entity->getBoundingBox(), to_lanelet_pose,
// WIP just use first lanelet pose, should be changed in the future
from_lanelet_poses.front(), from_entity->getBoundingBox(), to_lanelet_pose,
traffic_simulator_msgs::msg::BoundingBox(), routing_algorithm);
}
}
Expand Down Expand Up @@ -267,18 +276,19 @@ class SimulatorCore
const std::string & from_entity_name, const std::string & to_entity_name,
const RoutingAlgorithm::value_type routing_algorithm = RoutingAlgorithm::undefined) -> int
{
if (
const auto from_lanelet_pose =
core->getEntity(from_entity_name).getCanonicalizedLaneletPose()) {
if (
const auto to_lanelet_pose =
core->getEntity(to_entity_name).getCanonicalizedLaneletPose()) {
if (const auto from_lanelet_poses =
core->getEntity(from_entity_name).getCanonicalizedLaneletPoses();
!from_lanelet_poses.empty()) {
if (const auto to_lanelet_poses =
core->getEntity(to_entity_name).getCanonicalizedLaneletPoses();
!to_lanelet_poses.empty()) {
traffic_simulator::RoutingConfiguration routing_configuration;
routing_configuration.allow_lane_change =
(routing_algorithm == RoutingAlgorithm::value_type::shortest);
if (
const auto lane_changes = traffic_simulator::distance::countLaneChanges(
from_lanelet_pose.value(), to_lanelet_pose.value(), routing_configuration,
// WIP just use first lanelet pose, should be changed in the future
from_lanelet_poses.front(), to_lanelet_poses.front(), routing_configuration,
core->getHdmapUtils())) {
return lane_changes.value().first - lane_changes.value().second;
}
Expand Down Expand Up @@ -680,9 +690,12 @@ class SimulatorCore
static auto evaluateRelativeHeading(const EntityRef & entity_ref)
{
if (const auto entity = core->getEntityPointer(entity_ref)) {
if (const auto canonicalized_lanelet_pose = entity->getCanonicalizedLaneletPose()) {
if (const auto canonicalized_lanelet_poses = entity->getCanonicalizedLaneletPoses();
!canonicalized_lanelet_poses.empty()) {
return static_cast<Double>(std::abs(
static_cast<traffic_simulator::LaneletPose>(canonicalized_lanelet_pose.value()).rpy.z));
// WIP just use first lanelet pose, should be changed in the future
static_cast<traffic_simulator::LaneletPose>(canonicalized_lanelet_poses.front())
.rpy.z));
}
}
return Double::nan();
Expand Down
Loading