@@ -64,7 +64,7 @@ inline namespace SDF_VERSION_NAMESPACE {
64
64
namespace usd
65
65
{
66
66
UsdErrors parseUSDWorld (const std::string &_inputFileName,
67
- sdf::World &_world)
67
+ bool _useGazeboPlugins, sdf::World &_world)
68
68
{
69
69
UsdErrors errors;
70
70
USDData usdData (_inputFileName);
@@ -189,6 +189,66 @@ namespace usd
189
189
}
190
190
}
191
191
192
+ if (_useGazeboPlugins && primType == " RosDifferentialBase" )
193
+ {
194
+ if (!modelPtr)
195
+ {
196
+ errors.push_back (UsdError (UsdErrorCode::USD_TO_SDF_PARSING_ERROR,
197
+ " Unable to store RosDifferentialBase in a DiffDrive plugin "
198
+ " because the corresponding sdf::Model object wasn't found." ));
199
+ return errors;
200
+ }
201
+
202
+ auto leftWheelAttr = prim.GetAttribute (
203
+ pxr::TfToken (" leftWheelJointName" ));
204
+ auto rightWheelAttr = prim.GetAttribute (
205
+ pxr::TfToken (" rightWheelJointName" ));
206
+ auto wheelBaseAttr = prim.GetAttribute (
207
+ pxr::TfToken (" wheelBase" ));
208
+ auto wheelRadiusAttr = prim.GetAttribute (
209
+ pxr::TfToken (" wheelRadius" ));
210
+
211
+ sdf::Plugin diffDrivePlugin;
212
+ diffDrivePlugin.SetName (" ignition::gazebo::systems::DiffDrive" );
213
+ diffDrivePlugin.SetFilename (" ignition-gazebo-diff-drive-system" );
214
+
215
+ std::string leftWheelName;
216
+ std::string rightWheelName;
217
+ float wheelBase;
218
+ float wheelRadius;
219
+ wheelBaseAttr.Get <float >(&wheelBase);
220
+ wheelRadiusAttr.Get <float >(&wheelRadius);
221
+ leftWheelAttr.Get <std::string>(&leftWheelName);
222
+ rightWheelAttr.Get <std::string>(&rightWheelName);
223
+
224
+ sdf::ElementPtr leftJointContent (new sdf::Element);
225
+ leftJointContent->SetName (" left_joint" );
226
+ leftJointContent->AddValue (" string" , " " , false );
227
+ leftJointContent->Set (leftWheelName + " _joint" );
228
+ diffDrivePlugin.InsertContent (leftJointContent);
229
+
230
+ sdf::ElementPtr rightJointContent (new sdf::Element);
231
+ rightJointContent->SetName (" right_joint" );
232
+ rightJointContent->AddValue (" string" , " " , false );
233
+ rightJointContent->Set (rightWheelName + " _joint" );
234
+ diffDrivePlugin.InsertContent (rightJointContent);
235
+
236
+ sdf::ElementPtr wheelSeparationContent (new sdf::Element);
237
+ wheelSeparationContent->SetName (" wheel_separation" );
238
+ wheelSeparationContent->AddValue (" float" , " 0.0" , false );
239
+ wheelSeparationContent->Set (wheelBase);
240
+ diffDrivePlugin.InsertContent (wheelSeparationContent);
241
+
242
+ sdf::ElementPtr wheelRadiusContent (new sdf::Element);
243
+ wheelRadiusContent->SetName (" wheel_radius" );
244
+ wheelRadiusContent->AddValue (" float" , " 0.0" , false );
245
+ wheelRadiusContent->Set (wheelRadius);
246
+ diffDrivePlugin.InsertContent (wheelRadiusContent);
247
+
248
+ modelPtr->AddPlugin (diffDrivePlugin);
249
+ continue ;
250
+ }
251
+
192
252
if (prim.IsA <pxr::UsdLuxBoundableLightBase>() ||
193
253
prim.IsA <pxr::UsdLuxNonboundableLightBase>())
194
254
{
@@ -340,28 +400,31 @@ namespace usd
340
400
}
341
401
}
342
402
343
- // Add some plugins to run the Ignition Gazebo simulation
344
- sdf::Plugin physicsPlugin;
345
- physicsPlugin.SetName (" ignition::gazebo::systems::Physics" );
346
- physicsPlugin.SetFilename (" ignition-gazebo-physics-system" );
347
- _world.AddPlugin (physicsPlugin);
348
-
349
- sdf::Plugin sensorsPlugin;
350
- sensorsPlugin.SetName (" ignition::gazebo::systems::Sensors" );
351
- sensorsPlugin.SetFilename (" ignition-gazebo-sensors-system" );
352
- _world.AddPlugin (sensorsPlugin);
353
-
354
- sdf::Plugin userCommandsPlugin;
355
- userCommandsPlugin.SetName (" ignition::gazebo::systems::UserCommands" );
356
- userCommandsPlugin.SetFilename (" ignition-gazebo-user-commands-system" );
357
- _world.AddPlugin (userCommandsPlugin);
358
-
359
- sdf::Plugin sceneBroadcasterPlugin;
360
- sceneBroadcasterPlugin.SetName (
361
- " ignition::gazebo::systems::SceneBroadcaster" );
362
- sceneBroadcasterPlugin.SetFilename (
363
- " ignition-gazebo-scene-broadcaster-system" );
364
- _world.AddPlugin (sceneBroadcasterPlugin);
403
+ if (_useGazeboPlugins)
404
+ {
405
+ // Add some plugins to run the Ignition Gazebo simulation
406
+ sdf::Plugin physicsPlugin;
407
+ physicsPlugin.SetName (" ignition::gazebo::systems::Physics" );
408
+ physicsPlugin.SetFilename (" ignition-gazebo-physics-system" );
409
+ _world.AddPlugin (physicsPlugin);
410
+
411
+ sdf::Plugin sensorsPlugin;
412
+ sensorsPlugin.SetName (" ignition::gazebo::systems::Sensors" );
413
+ sensorsPlugin.SetFilename (" ignition-gazebo-sensors-system" );
414
+ _world.AddPlugin (sensorsPlugin);
415
+
416
+ sdf::Plugin userCommandsPlugin;
417
+ userCommandsPlugin.SetName (" ignition::gazebo::systems::UserCommands" );
418
+ userCommandsPlugin.SetFilename (" ignition-gazebo-user-commands-system" );
419
+ _world.AddPlugin (userCommandsPlugin);
420
+
421
+ sdf::Plugin sceneBroadcasterPlugin;
422
+ sceneBroadcasterPlugin.SetName (
423
+ " ignition::gazebo::systems::SceneBroadcaster" );
424
+ sceneBroadcasterPlugin.SetFilename (
425
+ " ignition-gazebo-scene-broadcaster-system" );
426
+ _world.AddPlugin (sceneBroadcasterPlugin);
427
+ }
365
428
366
429
return errors;
367
430
}
0 commit comments