Skip to content

Commit

Permalink
Fix : lint fixed ament_flake
Browse files Browse the repository at this point in the history
  • Loading branch information
kimsooyoung committed Jun 4, 2021
1 parent 107f907 commit a3a3097
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 68 deletions.
24 changes: 12 additions & 12 deletions py_service_pkg/py_service_pkg/basic_srv_client.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
#!/usr/bin/env/ python3
# !/usr/bin/env/ python3

import sys
from example_interfaces.srv import AddTwoInts
import rclpy
from rclpy.node import Node
from example_interfaces.srv import AddTwoInts


class AdditionClient(Node):

def __init__(self):
super().__init__("addition_client")
self.client = self.create_client(AddTwoInts, "add_two_ints")
super().__init__('addition_client')
self.client = self.create_client(AddTwoInts, 'add_two_ints')

while not self.client.wait_for_service(timeout_sec=1.0):
self.get_logger().info("service not available, waiting again...")
self.get_logger().info('service not available, waiting again...')

self.req = AddTwoInts.Request()
self.get_logger().info("==== Welcome to Two Int Addition Service ====")
self.get_logger().info('==== Welcome to Two Int Addition Service ====')

def send_request(self):
self.req.a = int(input("> Type First Number : "))
self.req.b = int(input("> Type Second Number : "))
self.req.a = int(input('> Type First Number : '))
self.req.b = int(input('> Type Second Number : '))
self.future = self.client.call_async(self.req)
return self.future

Expand All @@ -37,10 +37,10 @@ def main(args=None):
try:
response = future.result()
except Exception as e:
addition_client.get_logger().info("Service call failed %r" % (e,))
addition_client.get_logger().info('Service call failed %r' % (e,))
else:
addition_client.get_logger().info(
"Result of add_two_ints: for %d + %d = %d"
'Result of add_two_ints: for %d + %d = %d'
% (addition_client.req.a, addition_client.req.b, response.sum)
)
break
Expand All @@ -49,5 +49,5 @@ def main(args=None):
rclpy.shutdown()


if __name__ == "__main__":
if __name__ == '__main__':
main()
18 changes: 9 additions & 9 deletions py_service_pkg/py_service_pkg/basic_srv_server.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#!/usr/bin/env/ python3
# !/usr/bin/env/ python3

from example_interfaces.srv import AddTwoInts
import rclpy
from rclpy.node import Node
from example_interfaces.srv import AddTwoInts


class AdditionServer(Node):

def __init__(self):
super().__init__("addition_server")
super().__init__('addition_server')
self.srv = self.create_service(
AddTwoInts, "add_two_ints", self.add_two_ints_callback
AddTwoInts, 'add_two_ints', self.add_two_ints_callback
)
self.get_logger().info("==== Basic Server Started ====")
self.get_logger().info('==== Basic Server Started ====')

def add_two_ints_callback(self, request, response):
response.sum = request.a + request.b
self.get_logger().info(
f"==== Incoming request ==== \n Fisrt Operand : {request.a}, Second Operand: {request.b}"
)
self.get_logger().info(f'==== Incoming request ==== \n Fisrt Operand : {request.a}, \
Second Operand: {request.b}')
return response


Expand All @@ -32,5 +32,5 @@ def main(args=None):
rclpy.shutdown()


if __name__ == "__main__":
if __name__ == '__main__':
main()
36 changes: 17 additions & 19 deletions py_service_pkg/py_service_pkg/custom_srv_client.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
#!/usr/bin/env/ python3
# !/usr/bin/env/ python3

import sys
from custom_interfaces.srv import AddThreeInts
import rclpy
from rclpy.node import Node

from custom_interfaces.srv import AddThreeInts


class AddThreeIntClient(Node):

def __init__(self):
super().__init__("custom_srv_client")
self.client = self.create_client(AddThreeInts, "add_three_ints") # CHANGE
super().__init__('custom_srv_client')
self.client = self.create_client(AddThreeInts, 'add_three_ints') # CHANGE
while not self.client.wait_for_service(timeout_sec=1.0):
self.get_logger().info("service not available, waiting again...")
self.get_logger().info('service not available, waiting again...')

self.req = AddThreeInts.Request()
self.get_logger().info("==== Welcome to Three Int Addition Service ====")
self.get_logger().info('==== Welcome to Three Int Addition Service ====')

def send_request(self):
self.req.a = int(input("> Type First Number : "))
self.req.b = int(input("> Type Second Number : "))
self.req.c = int(input("> Type Third Number : "))
self.req.a = int(input('> Type First Number : '))
self.req.b = int(input('> Type Second Number : '))
self.req.c = int(input('> Type Third Number : '))
self.future = self.client.call_async(self.req)

return self.future
Expand All @@ -37,20 +36,19 @@ def main(args=None):
if future.done():
try:
response = future.result()
except Exception as e:
except Exception:
raise RuntimeError(
"exception while calling service: %r" % future.exception()
'exception while calling service: %r' % future.exception()
)
else:
print("==== Service Call Done ====")
print(
f"Status_message : {add_three_client.req.a} + {add_three_client.req.b} + {add_three_client.req.c} = {response.sum}"
)
add_three_client.get_logger().info('==== Service Call Done ====')
add_three_client.get_logger().info(f'Status_message : {add_three_client.req.a} + \
{add_three_client.req.b} + {add_three_client.req.c} = {response.sum}')
finally:
add_three_client.get_logger().warn("==== Shutting down node. ====")
add_three_client.get_logger().warn('==== Shutting down node. ====')
add_three_client.destroy_node()
rclpy.shutdown()


if __name__ == "__main__":
if __name__ == '__main__':
main()
16 changes: 8 additions & 8 deletions py_service_pkg/py_service_pkg/custom_srv_server.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#!/usr/bin/env/ python3
# !/usr/bin/env/ python3

from custom_interfaces.srv import AddThreeInts # CHANGE
import rclpy
from rclpy.node import Node

from custom_interfaces.srv import AddThreeInts # CHANGE


class AddThreeIntServer(Node):

def __init__(self):
super().__init__("custom_srv_server")
super().__init__('custom_srv_server')
self.srv = self.create_service(
AddThreeInts, "add_three_ints", self.add_three_ints_callback
AddThreeInts, 'add_three_ints', self.add_three_ints_callback
)
self.get_logger().info("==== Addition Server Started, Waiting for Request ====")
self.get_logger().info('==== Addition Server Started, Waiting for Request ====')

def add_three_ints_callback(self, request, response):
response.sum = request.a + request.b + request.c
self.get_logger().info(
f"Incoming requests = a: {request.a}, b: {request.b}, c: {request.c}"
f'Incoming requests = a: {request.a}, b: {request.b}, c: {request.c}'
)
return response

Expand All @@ -33,5 +33,5 @@ def main(args=None):
rclpy.shutdown()


if __name__ == "__main__":
if __name__ == '__main__':
main()
38 changes: 18 additions & 20 deletions py_service_pkg/py_service_pkg/robot_turning_client.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
#!/usr/bin/env/ python3
# !/usr/bin/env/ python3

import sys
from custom_interfaces.srv import TurningControl
import rclpy
from rclpy.node import Node

from custom_interfaces.srv import TurningControl


class RobotTurnClient(Node):
def __init__(self):
super().__init__("robot_turn_client")
self.client = self.create_client(TurningControl, "turn_robot") # CHANGE
super().__init__('robot_turn_client')
self.client = self.create_client(TurningControl, 'turn_robot') # CHANGE

while not self.client.wait_for_service(timeout_sec=1.0):
self.get_logger().info("service not available, waiting again...")
self.get_logger().info('service not available, waiting again...')

self.req = TurningControl.Request()
print("==== Robot Turn Service Client ====")
print('==== Robot Turn Service Client ====')

def send_request(self):

while True:
try:
td = input("> Type turning time duration: ")
vel_x = input("> Type turning linear velocity: ")
vel_z = input("> Type turning angular velocity: ")
td = input('> Type turning time duration: ')
vel_x = input('> Type turning linear velocity: ')
vel_z = input('> Type turning angular velocity: ')

if float(vel_z) > 1.5707 or float(vel_x) > 3:
raise ArithmeticError("Velocity too high !!")
raise ArithmeticError('Velocity too high !!')

self.req.time_duration = int(td)

Expand All @@ -38,13 +36,13 @@ def send_request(self):
print(e)
except Exception as e:
print(e)
print("Not a number, PLZ Type number Again")
print('Not a number, PLZ Type number Again')

self.future = self.client.call_async(self.req)
print(
f"linear_x : {self.req.linear_vel_x} / angular_z : {self.req.angular_vel_z}"
f'linear_x : {self.req.linear_vel_x} / angular_z : {self.req.angular_vel_z}'
)
self.get_logger().info(" Request Sended ")
self.get_logger().info(' Request Sended ')
return self.future


Expand All @@ -61,18 +59,18 @@ def main(args=None):
response = future.result()
except Exception as e:
raise RuntimeError(
"exception while calling service: %r" % future.exception()
'exception while calling service: %r' % future.exception()
)
else:
print("==== Service Call Done ====")
print('==== Service Call Done ====')
print(
f"Result Message : {'Success' if response.success == True else 'Fail'}"
f'Result Message : {'Success' if response.success == True else 'Fail'}'
)
finally:
robot_turn_client.get_logger().warn("==== Shutting down node ====")
robot_turn_client.get_logger().warn('==== Shutting down node ====')
robot_turn_client.destroy_node()
rclpy.shutdown()


if __name__ == "__main__":
if __name__ == '__main__':
main()

0 comments on commit a3a3097

Please sign in to comment.