1. OpenSourceRoboticsFoundation
  2. Simulation
  3. gazebo

Commits

Mihai Emanuel Dolha  committed 9527e53

fixed spawning actors in running worlds

  • Participants
  • Parent commits 6d91f8d
  • Branches mihai

Comments (0)

Files changed (1)

File src/physics/World.cc

View file
     }
     else
     {
+      bool isActor = false;
       sdf::ElementPtr elem = factorySDF->root->GetElement("model");
+      if (!elem)
+      {
+        elem = factorySDF->root->GetElement("actor");
+        if (elem)
+          isActor = true;
+      }
       if (!elem && factorySDF->root->GetElement("world"))
+      {
         elem = factorySDF->root->GetElement("world")->GetElement("model");
+        if (!elem)
+        {
+          elem = factorySDF->root->GetElement("world")->GetElement("actor");
+          if (elem)
+            isActor = true;
+        }
+      }
       if (!elem && factorySDF->root->GetElement("gazebo"))
+      {
         elem = factorySDF->root->GetElement("gazebo")->GetElement("model");
+        if (!elem)
+        {
+          elem = factorySDF->root->GetElement("gazebo")->GetElement("actor");
+          if (elem)
+            isActor = true;
+        }
+      }
       if (!elem && factorySDF->root->GetElement("gazebo")->GetElement("world"))
       {
         elem = factorySDF->root->GetElement("gazebo")->GetElement(
             "world")->GetElement("model");
+        if (!elem)
+        {
+          elem = factorySDF->root->GetElement("gazebo")->GetElement(
+              "world")->GetElement("actor");
+          if (elem)
+            isActor = true;
+        }
       }
 
       if (!elem)
         elem->GetOrCreateElement("origin")->GetAttribute("pose")->Set(
             msgs::Convert((*iter).pose()));
 
-      ModelPtr model = this->LoadModel(elem, this->rootElement);
-      model->Init();
+      if (isActor)
+      {
+        ActorPtr actor = this->LoadActor(elem, this->rootElement);
+        actor->Init();
+      }
+      else
+      {
+        ModelPtr model = this->LoadModel(elem, this->rootElement);
+        model->Init();
+      }
     }
   }