SMACC2
service_node_3.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2
3# Copyright 2021 RobosoftAI Inc.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# import roslib
18# import rospy
19import rclpy
20from rclpy.node import Node
21
22import std_srvs
23import std_srvs.srv
24
25if __name__ == "__main__":
26
27 class Service3(Node):
28 def __init__(self):
29 super().__init__("Service3")
30 self.s = self.create_service(
32 )
33
34 def set_bool_service(self, req, res):
35 self.get_logger().info("RECEIVING SET BOOL SERVICE REQUEST: value=" + str(req.data))
36
37 res.message = "OK, value set"
38 res.success = True
39 return res
40
41 rclpy.init(args=None)
43
44 # s = rospy.Service('service_node3', std_srvs.srv.SetBool, set_bool_service)
45 # rospy.spin()
46 rclpy.spin(s)
47 rclpy.shutdown()
def set_bool_service(self, req, res)