32 lines
959 B
Python
32 lines
959 B
Python
import rclpy
|
|
from rclpy.node import Node
|
|
|
|
# Service Type Files
|
|
from custom_interfaces.srv import CustomSrv1
|
|
|
|
# Service Minimal Host and Client
|
|
from pubsub.pubsub_library_v4 import MinimalServiceProvider
|
|
|
|
|
|
def main(args=None):
|
|
rclpy.init(args=args)
|
|
|
|
minimal_service = MinimalServiceProvider(NODE_NAME="Srv_host_test_node", SRV_NAME="test_srv", SRV_TYPE=CustomSrv1)
|
|
|
|
while rclpy.ok():
|
|
try:
|
|
rclpy.spin_once(minimal_service, timeout_sec=0.1)
|
|
|
|
# Either the scripts checks to see if new srv calls are available to work off,
|
|
# or you implement this work inside the class
|
|
# pro/cons: abstraction is at a maximum, every further level is already too specific for the general task
|
|
|
|
except (KeyboardInterrupt, SystemExit):
|
|
print("\n\nShutting down...")
|
|
minimal_service.destroy_node()
|
|
rclpy.shutdown()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|