Skip to content

Commit caed9a2

Browse files
committed
Changed integrate_database name to just mocha
1 parent 198cda9 commit caed9a2

File tree

6 files changed

+46
-46
lines changed

6 files changed

+46
-46
lines changed

mocha_core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ install(
3939

4040
# Install executables as scripts
4141
install(PROGRAMS
42-
mocha_core/integrate_database.py
42+
mocha_core/mocha.py
4343
mocha_core/database_server.py
4444
mocha_core/synchronize_channel.py
4545
mocha_core/zmq_comm_node.py

mocha_core/launch/database_translators_publishers.launch.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ def generate_launch_description():
1111
"""
1212
Launch database, translator, and topic publisher nodes for MOCHA system
1313
"""
14-
14+
1515
# Declare launch arguments
1616
robot_name_arg = DeclareLaunchArgument(
1717
'robot_name',
1818
default_value='charon',
1919
description='Name of the robot'
2020
)
21-
21+
2222
robot_configs_arg = DeclareLaunchArgument(
2323
'robot_configs',
2424
default_value=PathJoinSubstitution([
@@ -27,16 +27,16 @@ def generate_launch_description():
2727
]),
2828
description='Path to robot configuration file'
2929
)
30-
30+
3131
topic_configs_arg = DeclareLaunchArgument(
32-
'topic_configs',
32+
'topic_configs',
3333
default_value=PathJoinSubstitution([
3434
FindPackageShare('mocha_core'),
3535
'config', 'topic_configs.yaml'
3636
]),
3737
description='Path to topic configuration file'
3838
)
39-
39+
4040
radio_configs_arg = DeclareLaunchArgument(
4141
'radio_configs',
4242
default_value=PathJoinSubstitution([
@@ -45,18 +45,18 @@ def generate_launch_description():
4545
]),
4646
description='Path to radio configuration file'
4747
)
48-
48+
4949
# Get launch configurations
5050
robot_name = LaunchConfiguration('robot_name')
5151
robot_configs = LaunchConfiguration('robot_configs')
5252
topic_configs = LaunchConfiguration('topic_configs')
5353
radio_configs = LaunchConfiguration('radio_configs')
54-
54+
5555
# Define nodes
56-
integrate_database_node = Node(
56+
mocha_node = Node(
5757
package='mocha_core',
58-
executable='integrate_database.py',
59-
name='integrate_database',
58+
executable='mocha.py',
59+
name='mocha',
6060
output='screen',
6161
parameters=[{
6262
'robot_name': robot_name,
@@ -66,7 +66,7 @@ def generate_launch_description():
6666
'rssi_threshold': 35
6767
}]
6868
)
69-
69+
7070
translator_node = Node(
7171
package='mocha_core',
7272
executable='translator.py',
@@ -78,7 +78,7 @@ def generate_launch_description():
7878
'topic_configs': topic_configs
7979
}]
8080
)
81-
81+
8282
topic_publisher_node = Node(
8383
package='mocha_core',
8484
executable='topic_publisher.py',
@@ -90,13 +90,13 @@ def generate_launch_description():
9090
'topic_configs': topic_configs
9191
}]
9292
)
93-
93+
9494
return LaunchDescription([
9595
robot_name_arg,
9696
robot_configs_arg,
9797
topic_configs_arg,
9898
radio_configs_arg,
99-
integrate_database_node,
99+
mocha_node,
100100
translator_node,
101101
topic_publisher_node
102-
])
102+
])

mocha_core/mocha_core/integrate_database.py renamed to mocha_core/mocha_core/mocha.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ def ping(host):
3535
return False
3636

3737

38-
class IntegrateDatabase(Node):
38+
class Mocha(Node):
3939
def __init__(self):
40-
super().__init__("integrate_database")
40+
super().__init__("mocha_setver")
4141

4242
# Handle shutdown signal
4343
self.shutdownTriggered = threading.Event()
4444
self.shutdownTriggered.clear()
4545

4646
def signal_handler(sig, frame):
47-
self.logger.warning(f"{self.this_robot} - Integrate - Got SIGINT. Triggering shutdown.")
47+
self.logger.warning(f"{self.this_robot} - MOCHA Server - Got SIGINT. Triggering shutdown.")
4848
self.shutdown("Killed by user")
4949
signal.signal(signal.SIGINT, signal_handler)
5050

@@ -63,13 +63,13 @@ def signal_handler(sig, frame):
6363
self.rssi_threshold = self.get_parameter("rssi_threshold").get_parameter_value().integer_value
6464

6565
if len(self.this_robot) == 0:
66-
self.logger.error(f"{self.this_robot} - Integrate - Empty robot name")
66+
self.logger.error(f"{self.this_robot} - MOCHA Server - Empty robot name")
6767
raise ValueError("Empty robot name")
6868

69-
self.logger.info(f"{self.this_robot} - Integrate - " +
69+
self.logger.info(f"{self.this_robot} - MOCHA Server - " +
7070
f"RSSI threshold: {self.rssi_threshold}")
7171
self.client_timeout = self.get_parameter("client_timeout").get_parameter_value().double_value
72-
self.logger.info(f"{self.this_robot} - Integrate - " +
72+
self.logger.info(f"{self.this_robot} - MOCHA Server - " +
7373
f"Client timeout: {self.client_timeout}")
7474

7575
# Load and check robot configs
@@ -78,10 +78,10 @@ def signal_handler(sig, frame):
7878
with open(self.robot_configs_file, "r") as f:
7979
self.robot_configs = yaml.load(f, Loader=yaml.FullLoader)
8080
except Exception as e:
81-
self.logger.error(f"{self.this_robot} - Integrate - robot_configs file")
81+
self.logger.error(f"{self.this_robot} - MOCHA Server - robot_configs file")
8282
raise e
8383
if self.this_robot not in self.robot_configs.keys():
84-
self.logger.error(f"{self.this_robot} - Integrate - robot_configs file")
84+
self.logger.error(f"{self.this_robot} - MOCHA Server - robot_configs file")
8585
raise ValueError("Robot not in config file")
8686

8787
# Load and check radio configs
@@ -90,11 +90,11 @@ def signal_handler(sig, frame):
9090
with open(self.radio_configs_file, "r") as f:
9191
self.radio_configs = yaml.load(f, Loader=yaml.FullLoader)
9292
except Exception as e:
93-
self.logger.error(f"{self.this_robot} - Integrate - radio_configs file")
93+
self.logger.error(f"{self.this_robot} - MOCHA Server - radio_configs file")
9494
raise e
9595
self.radio = self.robot_configs[self.this_robot]["using-radio"]
9696
if self.radio not in self.radio_configs.keys():
97-
self.logger.error(f"{self.this_robot} - Integrate - radio_configs file")
97+
self.logger.error(f"{self.this_robot} - MOCHA Server - radio_configs file")
9898
raise ValueError("Radio {self.radio} not in config file")
9999

100100
# Load and check topic configs
@@ -103,17 +103,17 @@ def signal_handler(sig, frame):
103103
with open(self.topic_configs_file, "r") as f:
104104
self.topic_configs = yaml.load(f, Loader=yaml.FullLoader)
105105
except Exception as e:
106-
self.logger.error(f"{self.this_robot} - Integrate - topics_configs file")
106+
self.logger.error(f"{self.this_robot} - MOCHA Server - topics_configs file")
107107
raise e
108108
self_type = self.robot_configs[self.this_robot]["node-type"]
109109
if self_type not in self.topic_configs.keys():
110-
self.logger.error(f"{self.this_robot} - Integrate - topics_configs file")
110+
self.logger.error(f"{self.this_robot} - MOCHA Server - topics_configs file")
111111
raise ValueError("Node type not in config file")
112112

113113
# Check that we can ping the radios
114114
ip = self.robot_configs[self.this_robot]["IP-address"]
115115
if not ping(ip):
116-
self.logger.error(f"{self.this_robot} - Integrate - " +
116+
self.logger.error(f"{self.this_robot} - MOCHA Server - " +
117117
f"Cannot ping self {ip}. Is the radio on?")
118118
raise ValueError("Cannot ping self")
119119

@@ -124,7 +124,7 @@ def signal_handler(sig, frame):
124124

125125
self.num_robot_in_comm = 0
126126

127-
self.logger.info(f"{self.this_robot} - Integrate - " +
127+
self.logger.info(f"{self.this_robot} - MOCHA Server - " +
128128
"Created all communication channels!")
129129

130130
# Start comm channels with other robots
@@ -134,7 +134,7 @@ def signal_handler(sig, frame):
134134
for other_robot in self.other_robots:
135135
if other_robot not in self.robot_configs[self.this_robot]["clients"]:
136136
self.logger.warning(
137-
f"{self.this_robot} - Integrate - "+
137+
f"{self.this_robot} - MOCHA Server - "+
138138
f"Skipping channel {self.this_robot}->{other_robot} " +
139139
"as it is not in the graph of this robot"
140140
)
@@ -167,16 +167,16 @@ def shutdown(self, reason):
167167
self.shutdownTriggered.set()
168168

169169
assert isinstance(reason, str)
170-
self.logger.error(f"{self.this_robot} - Integrate - " + reason)
170+
self.logger.error(f"{self.this_robot} - MOCHA Server - " + reason)
171171
# Shutting down communication channels
172172
if hasattr(self, 'all_channels') and len(self.all_channels) != 0:
173173
for channel in self.all_channels:
174174
channel.stop()
175-
self.logger.warning(f"{self.this_robot} - Integrate - " + "Killed Channels")
175+
self.logger.warning(f"{self.this_robot} - MOCHA Server - " + "Killed Channels")
176176
# Wait for all the channels to be gone. This needs to be slightly
177177
# larger than RECV_TIMEOUT
178178
time.sleep(3.5)
179-
self.logger.warning(f"{self.this_robot} - Integrate - " + "Shutdown complete")
179+
self.logger.warning(f"{self.this_robot} - MOCHA Server - " + "Shutdown complete")
180180

181181
def rssi_cb(self, data, comm_node):
182182
rssi = data.data
@@ -195,30 +195,30 @@ def main(args=None):
195195

196196
# Start the node
197197
try:
198-
integrate_db = IntegrateDatabase()
198+
mocha = Mocha()
199199
except Exception as e:
200200
print(f"Node initialization failed: {e}")
201201
rclpy.shutdown()
202202
return
203203

204204
# Load mtexecutor
205205
mtexecutor = MultiThreadedExecutor(num_threads=4)
206-
mtexecutor.add_node(integrate_db)
206+
mtexecutor.add_node(mocha)
207207

208208
# Use context manager for clean shutdown
209209
try:
210210
# Spin with periodic checking for shutdown
211-
while rclpy.ok() and not integrate_db.shutdownTriggered.is_set():
211+
while rclpy.ok() and not mocha.shutdownTriggered.is_set():
212212
mtexecutor.spin_once(timeout_sec=0.1)
213213
except KeyboardInterrupt:
214214
print("Keyboard Interrupt")
215-
integrate_db.shutdown("KeyboardInterrupt")
215+
mocha.shutdown("KeyboardInterrupt")
216216
except Exception as e:
217217
print(f"Exception: {e}")
218-
integrate_db.shutdown(f"Exception: {e}")
218+
mocha.shutdown(f"Exception: {e}")
219219
finally:
220220
# Clean up node and ROS2 from main thread (safe)
221-
integrate_db.destroy_node()
221+
mocha.destroy_node()
222222
rclpy.shutdown()
223223

224224
if __name__ == "__main__":

mocha_core/mocha_core/translator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def __init__(
3131

3232
# Create service client
3333
self.add_update_db_cli = self.ros_node.create_client(AddUpdateDB,
34-
"/integrate_database/add_update_db",
34+
"/mocha/add_update_db",
3535
qos_profile=ds.DatabaseServer.QOS_PROFILE)
3636
wait_counter = 0
3737
while not self.add_update_db_cli.wait_for_service(timeout_sec=1.0):

mocha_core/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
tests_require=["pytest"],
2020
entry_points={
2121
"console_scripts": [
22-
"integrate_database = mocha_core.integrate_database:main",
22+
"mocha = mocha_core.mocha:main",
2323
"database_server = mocha_core.database_server:main",
2424
"synchronize_channel = mocha_core.synchronize_channel:main",
2525
"zmq_comm_node = mocha_core.zmq_comm_node:main",
2626
"topic_publisher = mocha_core.topic_publisher:main",
2727
"translator = mocha_core.translator:main",
2828
],
2929
},
30-
)
30+
)

mocha_core/test/test_translator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
class Database_server_test(Node):
3131
def __init__(self):
3232
# Important to match the topic that the translator expects
33-
super().__init__("integrate_database")
33+
super().__init__("mocha")
3434

3535

3636
class test_translator(unittest.TestCase):
@@ -155,7 +155,7 @@ def test_translator_processes_messages(self):
155155
# Use the translator node's service client to query the database
156156
select_client = translator_node.create_client(
157157
SelectDB,
158-
"/integrate_database/select_db",
158+
"/mocha/select_db",
159159
qos_profile=ds.DatabaseServer.QOS_PROFILE
160160
)
161161
while not select_client.wait_for_service(timeout_sec=1.0):
@@ -288,7 +288,7 @@ def topic_publisher(topic_id, topic_info, msgs_count):
288288

289289
select_client = translator_node.create_client(
290290
SelectDB,
291-
"/integrate_database/select_db",
291+
"/mocha/select_db",
292292
qos_profile=ds.DatabaseServer.QOS_PROFILE
293293
)
294294
while not select_client.wait_for_service(timeout_sec=1.0):

0 commit comments

Comments
 (0)