88from nav_msgs .msg import Path
99
1010from iarc7_msgs .msg import MotionPointStamped , MotionPointStampedArray
11-
11+ import cPickle as pickle
1212
1313# Convert a 3 element numpy array to a Vector3 message
1414def np_to_msg (array , msg ):
@@ -94,6 +94,8 @@ def __init__(self, start_motion_point):
9494 self ._override_start_position = None
9595 self ._override_start_velocity = None
9696
97+ # self._info = []
98+
9799 linear_motion_profile_generator = None
98100
99101 @staticmethod
@@ -103,8 +105,30 @@ def get_linear_motion_profile_generator():
103105 MotionPointStamped ())
104106 return LinearMotionProfileGenerator .linear_motion_profile_generator
105107
108+ # def dump_info(self):
109+ # name = '/home/andrew/new_data.bin'
110+ # file = open(name, 'wb')
111+ # pickle.dump(self._info, file)
112+ # file.close()
113+
106114 def set_global_plan (self , plan ):
107- self ._last_motion_plan = plan
115+ if len (self ._last_motion_plan .motion_points ) == 0 :
116+ # self._info.append((self._last_motion_plan, plan))
117+ self ._last_motion_plan = plan
118+ else :
119+ new_plan = MotionPointStampedArray ()
120+ new_point_stamp = plan .motion_points [0 ].header .stamp
121+
122+ for i in range (0 , len (self ._last_motion_plan .motion_points )):
123+ current_stamp = self ._last_motion_plan .motion_points [i ].header .stamp
124+ if current_stamp > new_point_stamp :
125+ new_plan .motion_points = self ._last_motion_plan .motion_points [:i ]
126+ break
127+
128+ new_plan .motion_points .extend (plan .motion_points )
129+ # self._info.append((self._last_motion_plan, plan))
130+
131+ self ._last_motion_plan = new_plan
108132
109133 # Get a starting motion point for a given time
110134 def _get_start_point (self ,
0 commit comments