Skip to content

Commit

Permalink
dont use rate in singlethreadedexecuter and split data if multiple
Browse files Browse the repository at this point in the history
  • Loading branch information
Richardvdketterij committed Feb 16, 2024
1 parent 1be2caa commit 54adb18
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions smach_ros/smach_ros/introspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from std_msgs.msg import Header

import base64
import time
import pickle
import threading
from functools import partial
Expand Down Expand Up @@ -91,13 +92,11 @@ def local_cb(msg_response, msg):
1)
init_pub.publish(initial_status_msg)

clock = ROSClock()
rate = self.create_rate(4, clock)
start_time = clock.now()
start_time = self.get_clock().now()

# Block until we get a new state back
if timeout is not None:
while clock.now() - start_time < timeout:
while self.get_clock().now() - start_time < timeout:
# Send the initial state command
init_pub.publish(initial_status_msg)

Expand All @@ -115,7 +114,7 @@ def local_cb(msg_response, msg):

if state_match and ud_match:
return True
rate.sleep()
time.sleep(0.25)
return False

class ContainerProxy():
Expand Down Expand Up @@ -207,15 +206,15 @@ def _publish_status(self, info_str=''):
with self._status_pub_lock:
path = self._path

#print str(structure_msg)
# Construct status message
#print self._container.get_active_states()
# Transform userdata to dictionary for pickling
keys = list(self._container.userdata.keys())
data = {key: self._container.userdata[key] for key in keys}
state_msg = SmachContainerStatus(
header=Header(stamp = ROSClock().now().to_msg()),
path=path,
initial_states=self._container.get_initial_states(),
active_states=self._container.get_active_states(),
local_data=base64.b64encode(pickle.dumps(self._container.userdata._data, 2)),
local_data=base64.b64encode(pickle.dumps(data, 2)),
info=info_str)
# Publish message
self._status_pub.publish(state_msg)
Expand Down

0 comments on commit 54adb18

Please sign in to comment.