@@ -279,6 +279,20 @@ namespace robot_dart {
279
279
#endif
280
280
_skeleton->getMutex ().unlock ();
281
281
auto robot = std::make_shared<Robot>(tmp_skel, _robot_name);
282
+
283
+ #if DART_VERSION_AT_LEAST(6, 13, 0)
284
+ // Deep copy everything
285
+ for (auto & bd : robot->skeleton ()->getBodyNodes ()) {
286
+ auto & visual_shapes = bd->getShapeNodesWith <dart::dynamics::VisualAspect>();
287
+ for (auto & shape : visual_shapes) {
288
+ if (shape->getShape ()->getType () != dart::dynamics::SoftMeshShape::getStaticType ())
289
+ shape->setShape (shape->getShape ()->clone ());
290
+ }
291
+ }
292
+ #endif
293
+
294
+ robot->set_positions (this ->positions ());
295
+
282
296
robot->_model_filename = _model_filename;
283
297
robot->_controllers .clear ();
284
298
for (auto & ctrl : _controllers) {
@@ -311,13 +325,26 @@ namespace robot_dart {
311
325
shape->removeAspect <dart::dynamics::CollisionAspect>();
312
326
}
313
327
328
+ // ghost robots do not have dynamics
329
+ auto & dyn_shapes = bd->getShapeNodesWith <dart::dynamics::DynamicsAspect>();
330
+ for (auto & shape : dyn_shapes) {
331
+ shape->removeAspect <dart::dynamics::DynamicsAspect>();
332
+ }
333
+
314
334
// ghost robots have a different color (same for all bodies)
315
335
auto & visual_shapes = bd->getShapeNodesWith <dart::dynamics::VisualAspect>();
316
336
for (auto & shape : visual_shapes) {
337
+ #if DART_VERSION_AT_LEAST(6, 13, 0)
338
+ if (shape->getShape ()->getType () != dart::dynamics::SoftMeshShape::getStaticType ())
339
+ shape->setShape (shape->getShape ()->clone ());
340
+ #endif
317
341
shape->getVisualAspect ()->setRGBA (ghost_color);
318
342
}
319
343
}
320
344
345
+ // set positions
346
+ robot->set_positions (this ->positions ());
347
+
321
348
// ghost robots, by default, use the color from the VisualAspect
322
349
robot->set_color_mode (" aspect" );
323
350
0 commit comments