Skip to content

Commit d818711

Browse files
committed
Publish database header in database_cb, makes topic_publisher easier
1 parent 800180e commit d818711

File tree

4 files changed

+5
-2
lines changed

4 files changed

+5
-2
lines changed

mocha_core/mocha_core/database.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def add_modify_data(self, dbm):
118118
self.lock.release()
119119
# Callback on insertion of new data
120120
if self.insertion_cb is not None:
121-
self.insertion_cb(dbm.robot_id, dbm.topic_id, dbm.ts)
121+
self.insertion_cb(dbm.robot_id, dbm.topic_id, dbm.ts, dbm.header)
122122
return dbm.header
123123

124124
def get_header_list(self, filter_robot_id=None, filter_latest=None):

mocha_core/mocha_core/database_server.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,13 @@ def __init__(self, robot_configs, topic_configs, robot_name, ros_node):
5959
f"{self.ros_node_name}/database_cb",
6060
10
6161
)
62-
def database_cb(robot_id, topic_id, ts):
62+
def database_cb(robot_id, topic_id, ts, header):
6363
database_cb_msg = mocha_core.msg.DatabaseCB()
6464
database_cb_msg.header.stamp = ts.to_msg()
6565
database_cb_msg.header.frame_id = self.robot_name
6666
database_cb_msg.robot_id = robot_id
6767
database_cb_msg.topic_id = topic_id
68+
database_cb_msg.msgheader = header
6869
pub_database.publish(database_cb_msg)
6970

7071
# Create the empty database with lock

mocha_core/msg/DatabaseCB.msg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
std_msgs/Header header
22
uint16 robot_id
33
uint16 topic_id
4+
uint8[] msgheader

mocha_core/test/test_database_server.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ def test_add_retrieve_single_msg(self):
218218
self.assertTrue(client_node.data_answer is not None)
219219
self.assertEqual(client_node.data_answer.topic_id, tid)
220220
self.assertEqual(client_node.data_answer.header.frame_id, self.robot_name)
221+
self.assertEqual(client_node.data_answer.msgheader, answ_header)
221222

222223
def test_add_select_robot(self):
223224
# Create a single client

0 commit comments

Comments
 (0)