Commits

Nathan Koenig committed de09ebf Merge

Merged in issue_453 (pull request #254)

Update to address issue #453

Comments (0)

Files changed (3)

gazebo/common/LogRecord.cc

 }
 
 //////////////////////////////////////////////////
+bool LogRecord::GetRunning() const
+{
+  return !this->stop;
+}
+
+//////////////////////////////////////////////////
 const std::string &LogRecord::GetEncoding() const
 {
   return this->encoding;

gazebo/common/LogRecord.hh

       /// bzip2 compressed data with Base64 encoding.
       public: const std::string &GetEncoding() const;
 
+      /// \brief Return true if running.
+      /// \return True if LogRecord has been started.
+      public: bool GetRunning() const;
+
       /// \brief Update the log files
       ///
       /// Captures the current state of all registered entities, and outputs

gazebo/physics/World.cc

   // Output the contact information
   this->physicsEngine->GetContactManager()->PublishContacts();
 
-  int currState = (this->stateToggle + 1) % 2;
-  this->prevStates[currState] = WorldState(shared_from_this());
-  WorldState diffState = this->prevStates[currState] -
-                         this->prevStates[this->stateToggle];
+  if (common::LogRecord::Instance()->GetRunning())
+  {
+    int currState = (this->stateToggle + 1) % 2;
+    this->prevStates[currState] = WorldState(shared_from_this());
+    WorldState diffState = this->prevStates[currState] -
+      this->prevStates[this->stateToggle];
 
-  if (!diffState.IsZero())
-  {
-    this->stateToggle = currState;
-    this->states.push_back(diffState);
-    if (this->states.size() > 1000)
-      this->states.pop_front();
+    if (!diffState.IsZero())
+    {
+      this->stateToggle = currState;
+      this->states.push_back(diffState);
+      if (this->states.size() > 1000)
+        this->states.pop_front();
+    }
   }
 
   event::Events::worldUpdateEnd();