@@ -87,7 +87,11 @@ void MapUpdateModule::update_map(const geometry_msgs::msg::Point & position)
87
87
// the main ndt_ptr_) overlap, the latency of updating/alignment reduces partly.
88
88
// If the updating is done the main ndt_ptr_, either the update or the NDT
89
89
// align will be blocked by the other.
90
- update_ndt (position, *secondary_ndt_ptr_);
90
+ const bool updated = update_ndt (position, *secondary_ndt_ptr_);
91
+ if (!updated) {
92
+ last_update_position_ = position;
93
+ return ;
94
+ }
91
95
92
96
ndt_ptr_mutex_->lock ();
93
97
auto input_source = ndt_ptr_->getInputSource ();
@@ -106,7 +110,7 @@ void MapUpdateModule::update_map(const geometry_msgs::msg::Point & position)
106
110
publish_partial_pcd_map ();
107
111
}
108
112
109
- void MapUpdateModule::update_ndt (const geometry_msgs::msg::Point & position, NdtType & ndt)
113
+ bool MapUpdateModule::update_ndt (const geometry_msgs::msg::Point & position, NdtType & ndt)
110
114
{
111
115
auto request = std::make_shared<autoware_map_msgs::srv::GetDifferentialPointCloudMap::Request>();
112
116
@@ -128,7 +132,7 @@ void MapUpdateModule::update_ndt(const geometry_msgs::msg::Point & position, Ndt
128
132
while (status != std::future_status::ready) {
129
133
RCLCPP_INFO (logger_, " waiting response" );
130
134
if (!rclcpp::ok ()) {
131
- return ;
135
+ return false ; // No update
132
136
}
133
137
status = result.wait_for (std::chrono::seconds (1 ));
134
138
}
@@ -140,7 +144,7 @@ void MapUpdateModule::update_ndt(const geometry_msgs::msg::Point & position, Ndt
140
144
logger_, " Update map (Add: %lu, Remove: %lu)" , maps_to_add.size (), map_ids_to_remove.size ());
141
145
if (maps_to_add.empty () && map_ids_to_remove.empty ()) {
142
146
RCLCPP_INFO (logger_, " Skip map update" );
143
- return ;
147
+ return false ; // No update
144
148
}
145
149
146
150
const auto exe_start_time = std::chrono::system_clock::now ();
@@ -170,6 +174,7 @@ void MapUpdateModule::update_ndt(const geometry_msgs::msg::Point & position, Ndt
170
174
std::chrono::duration_cast<std::chrono::microseconds>(exe_end_time - exe_start_time).count ();
171
175
const auto exe_time = static_cast <double >(duration_micro_sec) / 1000.0 ;
172
176
RCLCPP_INFO (logger_, " Time duration for creating new ndt_ptr: %lf [ms]" , exe_time);
177
+ return true ; // Updated
173
178
}
174
179
175
180
void MapUpdateModule::publish_partial_pcd_map ()
0 commit comments