Skip to content

Commit f5b35fd

Browse files
author
Rather1337
committed
[wip] add trigger
1 parent 53df9b9 commit f5b35fd

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

lsy_estimators/ros_nodes/ros2_node.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from munch import Munch, munchify
3939
from rclpy.qos import QoSHistoryPolicy, QoSProfile, QoSReliabilityPolicy
4040
from std_msgs.msg import Float64MultiArray
41+
from std_srvs.srv import Trigger
4142
from tf2_msgs.msg import TFMessage
4243
from visualization_msgs.msg import MarkerArray
4344

@@ -324,19 +325,30 @@ def cmd_callback(msg: Float64MultiArray):
324325
_cmd_msg_buffer[1] = time.time()
325326
_cmd_msg_buffer[2:] = msg.data
326327

328+
def calibration_callback(self, request, response):
329+
self.get_logger().info("Trigger service called.")
330+
# Do some action here
331+
response.success = True
332+
response.message = "Action completed successfully."
333+
return response
334+
327335
sub_tf = node.create_subscription(TFMessage, "/tf", tf_callback, qos_profile=qos_profile)
328336
sub_cmd = node.create_subscription(
329337
Float64MultiArray,
330338
f"/drones/{drone_name}/command",
331339
cmd_callback,
332340
qos_profile=qos_profile,
333341
)
342+
sub_calib = node.create_client(
343+
Trigger, f"/drones/{drone_name}/calibration", calibration_callback
344+
)
334345
startup.wait(10.0) # Register this process as ready for startup barrier
335346

336347
while not shutdown.is_set():
337348
rclpy.spin_once(node, timeout_sec=0.1)
338349
sub_tf.destroy()
339350
sub_cmd.destroy()
351+
sub_calib.destroy()
340352
node.destroy_node()
341353

342354
@staticmethod

0 commit comments

Comments
 (0)