From abb5b67b9d8b3203049d6bdb889f0f9c7f20b768 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?M=C3=A9d=C3=A9ric=20Fourmy?= <mfourmy@laas.fr>
Date: Fri, 20 Mar 2020 15:11:41 +0100
Subject: [PATCH] Fix segfault

---
 src/problem/problem.cpp | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/problem/problem.cpp b/src/problem/problem.cpp
index b5be6eeac..eeb6fe5f6 100644
--- a/src/problem/problem.cpp
+++ b/src/problem/problem.cpp
@@ -358,16 +358,15 @@ void Problem::getState(const TimeStamp& _ts, Eigen::VectorXd& _state) const
 {
     // if _ts is too recent, for some of the processor is motion, they return the state corresponding to their last frame timestamp
     FrameBasePtr closest_frame = trajectory_ptr_->closestKeyOrAuxFrameToTimeStamp(_ts);
-    Eigen::VectorXd closest_frame_state = closest_frame->getState();
     if (processor_is_motion_list_.empty()){
         if (closest_frame != nullptr)
-            _state = closest_frame_state;
+            _state = closest_frame->getState();
         else
             _state = zeroState();
     }
 
     // RETRIEVE FROM PROCESSOR MOTION
-    // TODO: current implementation really messy, would be much easier with a state being an std::unordered_map
+    // TODO: current implementation messy, would be much easier with a state being an std::unordered_map
     else {
         // Iterate over the problem state structure and get the corresponding state
         // in the first processor is motion that provides it
@@ -383,7 +382,7 @@ void Problem::getState(const TimeStamp& _ts, Eigen::VectorXd& _state) const
                 // not already there
                 if (states_to_concat_map.find(sb_name) == states_to_concat_map.end()){
                     if (sb_name == 'O'){
-                        int size_sb = dim_ == 3 ? 4 : 1;  // really bad...
+                        int size_sb = dim_ == 3 ? 4 : 1;  // really bad: should be more transparent
                         states_to_concat_map[sb_name] = proc_state.segment(idx, size_sb);
                         idx += size_sb;
                     }
-- 
GitLab