@@ -136,6 +136,7 @@ bool MergeMapsKinematic::addSubmapCallback(
136
136
submap_marker_transform_[num_submaps_] =
137
137
tf2::Transform (tf2::Quaternion (0 ., 0 ., 0 ., 1.0 ),
138
138
tf2::Vector3 (0 , 0 , 0 )); // no initial correction -- identity mat
139
+ prev_submap_marker_transform_ = submap_marker_transform_;
139
140
submap_locations_[num_submaps_] =
140
141
Eigen::Vector3d (transform.getOrigin ().getX (),
141
142
transform.getOrigin ().getY (), 0 .);
@@ -267,11 +268,12 @@ bool MergeMapsKinematic::mergeMapCallback(
267
268
for (LocalizedRangeScansIt iter = it_LRV->begin ();
268
269
iter != it_LRV->end (); ++iter)
269
270
{
270
- tf2::Transform submap_correction = submap_marker_transform_[id];
271
+ tf2::Transform submap_correction = submap_marker_transform_[id] * prev_submap_marker_transform_[id]. inverse () ;
271
272
transformScan (iter, submap_correction);
272
273
transformed_scans.push_back ((*iter));
273
274
}
274
275
}
276
+ prev_submap_marker_transform_ = submap_marker_transform_;
275
277
276
278
// create the map
277
279
nav_msgs::srv::GetMap::Response map;
@@ -317,46 +319,47 @@ void MergeMapsKinematic::processInteractiveFeedback(
317
319
{
318
320
const int id = std::stoi (feedback->marker_name , nullptr , 10 );
319
321
322
+ tf2::Quaternion quat (feedback->pose .orientation .x ,
323
+ feedback->pose .orientation .y ,
324
+ feedback->pose .orientation .z ,
325
+ feedback->pose .orientation .w );
326
+
320
327
if (feedback->event_type ==
321
328
visualization_msgs::msg::InteractiveMarkerFeedback::MOUSE_UP &&
322
329
feedback->mouse_point_valid )
323
330
{
324
331
tf2Scalar yaw = tf2::getYaw (feedback->pose .orientation );
325
- tf2::Quaternion quat (0 ., 0 ., 0 ., 1.0 );
326
332
tf2::fromMsg (feedback->pose .orientation , quat); // relative
327
333
328
334
tf2::Transform previous_submap_correction;
329
335
previous_submap_correction.setIdentity ();
330
336
previous_submap_correction.setOrigin (tf2::Vector3 (submap_locations_[id](0 ),
331
337
submap_locations_[id](1 ), 0 .));
332
-
338
+ previous_submap_correction. setRotation (submap_marker_transform_[id]. getRotation ());
333
339
// update internal knowledge of submap locations
334
340
submap_locations_[id] = Eigen::Vector3d (feedback->pose .position .x ,
335
341
feedback->pose .position .y ,
336
- submap_locations_[id]( 2 ) + yaw );
342
+ 0.0 );
337
343
338
344
// add the map_N frame there
339
345
tf2::Transform new_submap_location;
340
- new_submap_location.setOrigin (tf2::Vector3 (submap_locations_[id]( 0 ) ,
341
- submap_locations_[id]( 1 ) , 0 .));
346
+ new_submap_location.setOrigin (tf2::Vector3 (feedback-> pose . position . x ,
347
+ feedback-> pose . position . y , 0 .));
342
348
new_submap_location.setRotation (quat);
343
-
344
349
geometry_msgs::msg::TransformStamped msg;
345
350
msg.transform = tf2::toMsg (new_submap_location);
346
351
msg.child_frame_id = " /map_" + std::to_string (id);
347
352
msg.header .frame_id = " /map" ;
348
353
msg.header .stamp = this ->now ();
349
354
tfB_->sendTransform (msg);
350
355
351
- submap_marker_transform_[id] = submap_marker_transform_[id] *
352
- previous_submap_correction.inverse () * new_submap_location;
356
+ submap_marker_transform_[id] = new_submap_location;
353
357
}
354
358
355
359
if (feedback->event_type ==
356
360
visualization_msgs::msg::InteractiveMarkerFeedback::POSE_UPDATE)
357
361
{
358
362
tf2Scalar yaw = tf2::getYaw (feedback->pose .orientation );
359
- tf2::Quaternion quat (0 ., 0 ., 0 ., 1.0 );
360
363
tf2::fromMsg (feedback->pose .orientation , quat); // relative
361
364
362
365
// add the map_N frame there
@@ -372,6 +375,7 @@ void MergeMapsKinematic::processInteractiveFeedback(
372
375
msg.header .stamp = this ->now ();
373
376
tfB_->sendTransform (msg);
374
377
}
378
+ this ->mergeMapCallback (nullptr , nullptr , nullptr );
375
379
}
376
380
377
381
/* ****************************************************************************/
0 commit comments