From 08b17b724b7ea822ea2ed86bddeffae2a42e4b61 Mon Sep 17 00:00:00 2001
From: Ale <alessandroassirell98@gmail.com>
Date: Wed, 17 Aug 2022 11:18:36 +0200
Subject: [PATCH] fix multiprocessing gait shape

---
 python/quadruped_reactive_walking/WB_MPC_Wrapper.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/python/quadruped_reactive_walking/WB_MPC_Wrapper.py b/python/quadruped_reactive_walking/WB_MPC_Wrapper.py
index 73a8f362..2316e985 100644
--- a/python/quadruped_reactive_walking/WB_MPC_Wrapper.py
+++ b/python/quadruped_reactive_walking/WB_MPC_Wrapper.py
@@ -44,7 +44,7 @@ class MPC_Wrapper:
             self.in_xs = Array("d", [0] * ((pd.T + 1) * pd.nx))
             self.in_us = Array("d", [0] * (pd.T * pd.nu))
             self.in_footstep = Array("d", [0] * 12)
-            self.in_gait = Array("d", [0] * (pd.T * 4))
+            self.in_gait = Array("d", [0] * ( (pd.T+1) * 4))
             self.out_xs = Array("d", [0] * ((pd.T + 1) * pd.nx))
             self.out_us = Array("d", [0] * (pd.T * pd.nu))
             self.out_k = Array("d", [0] * (pd.T * pd.nu * pd.ndx))
@@ -158,7 +158,7 @@ class MPC_Wrapper:
         with self.in_footstep.get_lock():
             np.frombuffer(self.in_footstep.get_obj()).reshape((3, 4))[:, :] = footstep
         with self.in_gait.get_lock():
-            np.frombuffer(self.in_gait.get_obj()).reshape((self.pd.T, 4))[:, :] = gait
+            np.frombuffer(self.in_gait.get_obj()).reshape((self.pd.T + 1, 4))[:, :] = gait
 
         if xs is None or us is None:
             self.in_warm_start.value = False
@@ -185,7 +185,7 @@ class MPC_Wrapper:
         with self.in_footstep.get_lock():
             footstep = np.frombuffer(self.in_footstep.get_obj()).reshape((3, 4))
         with self.in_gait.get_lock():
-            gait = np.frombuffer(self.in_gait.get_obj()).reshape((self.pd.T, 4))
+            gait = np.frombuffer(self.in_gait.get_obj()).reshape((self.pd.T + 1, 4))
 
         if not self.in_warm_start.value:
             return k, x0, footstep, gait, None, None
-- 
GitLab