|
38 | 38 | from munch import Munch, munchify |
39 | 39 | from rclpy.qos import QoSHistoryPolicy, QoSProfile, QoSReliabilityPolicy |
40 | 40 | from std_msgs.msg import Float64MultiArray |
| 41 | +from std_srvs.srv import Trigger |
41 | 42 | from tf2_msgs.msg import TFMessage |
42 | 43 | from visualization_msgs.msg import MarkerArray |
43 | 44 |
|
@@ -324,19 +325,30 @@ def cmd_callback(msg: Float64MultiArray): |
324 | 325 | _cmd_msg_buffer[1] = time.time() |
325 | 326 | _cmd_msg_buffer[2:] = msg.data |
326 | 327 |
|
| 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 | + |
327 | 335 | sub_tf = node.create_subscription(TFMessage, "/tf", tf_callback, qos_profile=qos_profile) |
328 | 336 | sub_cmd = node.create_subscription( |
329 | 337 | Float64MultiArray, |
330 | 338 | f"/drones/{drone_name}/command", |
331 | 339 | cmd_callback, |
332 | 340 | qos_profile=qos_profile, |
333 | 341 | ) |
| 342 | + sub_calib = node.create_client( |
| 343 | + Trigger, f"/drones/{drone_name}/calibration", calibration_callback |
| 344 | + ) |
334 | 345 | startup.wait(10.0) # Register this process as ready for startup barrier |
335 | 346 |
|
336 | 347 | while not shutdown.is_set(): |
337 | 348 | rclpy.spin_once(node, timeout_sec=0.1) |
338 | 349 | sub_tf.destroy() |
339 | 350 | sub_cmd.destroy() |
| 351 | + sub_calib.destroy() |
340 | 352 | node.destroy_node() |
341 | 353 |
|
342 | 354 | @staticmethod |
|
0 commit comments