Lavorare con il formato URDF

Contents
[ ]

{% alert color=“primary” %}

Questa funzionalità è supportata dalla versione 26.8 o successiva.

{% /alert %}

Cos’è URDF?

URDF (Unified Robot Description Format) è un formato XML usato da ROS e dai simulatori di robotica come Gazebo per descrivere i robot: i loro link, giunti e la geometria ad essi collegata. Importando un file URDF si ottiene una normale scena Aspose.3D, che può essere convertita in glTF, FBX o qualsiasi altro formato supportato.

Aprire i file in formato URDF

Aspose.3D importa la geometria <visual> di ogni link. Impostare UrdfLoadOptions.LoadCollisionGeometry su true per importare anche la geometria <collision>, usata dai robot per la simulazione fisica.

using Aspose.ThreeD.Formats;
// Create a new scene
var scene = new Scene();
// Build a simple robot link
var link = scene.RootNode.CreateChildNode("link1");
link.Entity = new Box();
// Save the scene as URDF file
scene.Save("output.urdf", FileFormat.URDF);

// Load it back with URDF options
var loadOptions = new UrdfLoadOptions();
// Load collision geometry from the URDF file
loadOptions.LoadCollisionGeometry = true;
var loaded = new Scene();
loaded.Open("output.urdf", loadOptions);

Salvare in formato URDF

Le scene vengono esportate in URDF con il formato file URDF. I link la cui geometria è una mesh vengono scritti come file mesh esterni accanto al file URDF — la proprietà UrdfSaveOptions.MeshFormat seleziona il formato mesh da usare e Indented abilita l’output XML formattato.

using Aspose.ThreeD.Formats;
// Load the scene to save
var scene = Scene.FromFile("output.urdf");
// Save with options: pretty-printed XML, meshes exported as OBJ
var saveOptions = new UrdfSaveOptions();
saveOptions.Indented = true;
saveOptions.MeshFormat = FileFormat.WavefrontOBJ;
scene.Save("output_indented.urdf", saveOptions);

Per una scena contenente un link denominato link1 con geometria a mesh, questo produce un file URDF che fa riferimento alla mesh esportata:

<?xml version="1.0" encoding="utf-8"?>
<robot name="RootNode">
  <link name="link1">
    <visual>
      <geometry>
        <mesh filename="link1_visual0.obj" />
      </geometry>
    </visual>
  </link>
</robot>