Skip to content

Commit 1ec4886

Browse files
authored
Merge pull request ros-visualization#38 from kousuke-takeuchi/noetic-devel
fix unpacking the user data
2 parents 56105ad + 5a35d2c commit 1ec4886

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

smach_viewer/scripts/smach_viewer.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
import rospy
3434
import rospkg
35+
import roslib
3536

3637
from smach_msgs.msg import SmachContainerStatus,SmachContainerInitialStatusCmd,SmachContainerStructure
3738

@@ -44,6 +45,7 @@
4445
import StringIO
4546
import colorsys
4647
import time
48+
import base64
4749

4850
import wxversion
4951
if wxversion.checkInstalled("2.8"):
@@ -161,6 +163,14 @@ def update_structure(self, msg):
161163

162164
return needs_update
163165

166+
def _load_local_data(self, msg):
167+
"""Unpack the user data"""
168+
try:
169+
local_data = pickle.loads(msg.local_data)
170+
except KeyError:
171+
local_data = pickle.loads(base64.b64decode(msg.local_data.encode('utf-8')))
172+
return local_data
173+
164174
def update_status(self, msg):
165175
"""Update the known userdata and active state set and return True if the graph needs to be redrawn."""
166176

@@ -182,14 +192,14 @@ def update_status(self, msg):
182192
# Unpack the user data
183193
while not rospy.is_shutdown():
184194
try:
185-
self._local_data._data = pickle.loads(msg.local_data)
195+
self._local_data._data = self._load_local_data(msg)
186196
break
187197
except ImportError as ie:
188198
# This will only happen once for each package
189199
modulename = ie.args[0][16:]
190200
packagename = modulename[0:modulename.find('.')]
191201
roslib.load_manifest(packagename)
192-
self._local_data._data = pickle.loads(msg.local_data)
202+
self._local_data._data = self._load_local_data(msg)
193203

194204
# Store the info string
195205
self._info = msg.info
@@ -1061,4 +1071,4 @@ def main():
10611071
if __name__ == '__main__':
10621072
rospy.init_node('smach_viewer',anonymous=False, disable_signals=True,log_level=rospy.INFO)
10631073
sys.argv = rospy.myargv()
1064-
main()
1074+
main()

0 commit comments

Comments
 (0)