Skip to content

Commit 89619f3

Browse files
committed
synchronize_channel seems broken ugh
1 parent 1fe6c07 commit 89619f3

File tree

2 files changed

+7
-57
lines changed

2 files changed

+7
-57
lines changed

mocha_core/mocha_core/synchronize_channel.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ def __init__(self, outer):
4949

5050
def execute(self, userdata):
5151
self.outer.publishState("Idle Start")
52-
while (not self.outer.sm_shutdown.is_set() and
53-
not self.outer.shutdown_requested):
52+
while (not self.outer.sm_shutdown.is_set()):
5453
if self.outer.sync.get_state():
5554
# trigger sync and reset bistable
5655
self.outer.publishState("Idle to RequestHash")
@@ -283,9 +282,6 @@ def __init__(self, dbl, this_robot,
283282
self.logger = self.ros_node.get_logger()
284283
self.ros_node_name = self.ros_node.get_fully_qualified_name()
285284

286-
# Add shutdown_requested attribute for ROS2 compatibility
287-
self.shutdown_requested = False
288-
289285
# Override smach logger to use ROS2 loggers
290286
smach.set_loggers(self.logger.debug, self.logger.warn,
291287
self.logger.debug, self.logger.error)

mocha_core/test/test_synchronize_channel.py

Lines changed: 6 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ def tearDown(self):
5252
super().tearDown()
5353

5454
def test_onehop_oneway_sync(self):
55-
dbl1 = sample_db.get_sample_dbl()
55+
""" Start both DBs, insert a message in DB2, trigger_sync DB1, and check that both DBs are the same """
56+
dbl1 = sample_db.get_sample_dbl()
5657
dbl2 = sample_db.get_sample_dbl()
5758
dbm = db.DBMessage(1, 1, 2, 1,
5859
rclpy.time.Time(seconds=123, nanoseconds=456000000), bytes('New data', 'utf-8'))
@@ -74,6 +75,8 @@ def test_onehop_oneway_sync(self):
7475
time.sleep(4)
7576

7677
def test_convoluted_onehop_oneway_sync(self):
78+
""" Start one DB1, insert a message in DB2 but don't start, trigger_sync
79+
DB1 (should be busy), start DB2, trigger_sync DB1, DBs should be the same """
7780
self.maxDiff=None
7881
dbl1 = sample_db.get_sample_dbl()
7982
dbl2 = sample_db.get_sample_dbl()
@@ -111,6 +114,8 @@ def test_convoluted_onehop_oneway_sync(self):
111114
time.sleep(4)
112115

113116
def test_convoluted_onehop_twoway_sync(self):
117+
""" Insert a message in DB1, start DB1, insert a message in DB2 but don't start, trigger_sync
118+
DB1 (should be busy), start DB2, trigger_sync DB1, DBs should be the same """
114119
self.maxDiff=None
115120
dbl1 = sample_db.get_sample_dbl()
116121
dbl2 = sample_db.get_sample_dbl()
@@ -196,57 +201,6 @@ def test_twohop_oneway_sync(self):
196201
time.sleep(2)
197202

198203

199-
def test_delay_run(self):
200-
self.maxDiff = None
201-
db_gs = sample_db.get_sample_dbl()
202-
db_r1 = sample_db.get_sample_dbl()
203-
db_r2 = sample_db.get_sample_dbl()
204-
205-
node_gs_r1 = sync.Channel(db_gs, 'basestation', 'charon', self.robot_configs, 2, self.test_ros_node)
206-
node_gs_r2 = sync.Channel(db_gs, 'basestation', 'styx', self.robot_configs, 2, self.test_ros_node)
207-
208-
node_r1_gs = sync.Channel(db_r1, 'charon', 'basestation', self.robot_configs, 2, self.test_ros_node)
209-
node_r2_gs = sync.Channel(db_r2, 'styx', 'basestation', self.robot_configs, 2, self.test_ros_node)
210-
211-
node_r1_r2 = sync.Channel(db_r1, 'charon', 'styx', self.robot_configs, 2, self.test_ros_node)
212-
node_r2_r1 = sync.Channel(db_r2, 'styx', 'charon', self.robot_configs, 2, self.test_ros_node)
213-
214-
node_gs_r1.run()
215-
node_gs_r2.run()
216-
217-
dbm = db.DBMessage(1, 1, 2, 1, rclpy.time.Time(seconds=int(time.time())), bytes('r1_data', 'utf-8'))
218-
db_r1.add_modify_data(dbm)
219-
220-
node_gs_r1.trigger_sync()
221-
time.sleep(4)
222-
223-
node_r1_gs.run()
224-
node_r2_gs.run()
225-
226-
dbm = db.DBMessage(2, 2, 1, 2, rclpy.time.Time(seconds=int(time.time())), bytes('r2_data', 'utf-8'))
227-
db_r2.add_modify_data(dbm)
228-
229-
node_r1_r2.run()
230-
231-
node_r1_r2.trigger_sync()
232-
time.sleep(4)
233-
234-
node_gs_r2.trigger_sync()
235-
time.sleep(2)
236-
237-
node_r2_r1.run()
238-
239-
node_gs_r1.stop()
240-
node_r1_gs.stop()
241-
242-
node_r1_r2.stop()
243-
node_r2_r1.stop()
244-
245-
node_r2_gs.stop()
246-
node_gs_r2.stop()
247-
248-
time.sleep(2)
249-
250204
def test_delay_run(self):
251205
self.maxDiff = None
252206
db_gs = sample_db.get_sample_dbl()

0 commit comments

Comments
 (0)