# Add two int in ROS



```
#!/usr/bin/env python

import sys
import rospy
from beginner_tutorials.srv import *

def add_two_ints_client(x, y):
    rospy.wait_for_service('add_two_ints')
    try:
        add_two_ints = rospy.ServiceProxy('add_two_ints', AddTwoInts)
        resp1 = add_two_ints(x, y)
        return resp1.sum
    except rospy.ServiceException, e:
        print "Service call failed: %s"%e

def usage():
    return "%s [x y]"%sys.argv[0]

if __name__ == "__main__":
    if len(sys.argv) == 3:
        x = int(sys.argv[1])
        y = int(sys.argv[2])
    else:
        print usage()
        sys.exit(1)
    print "Requesting %s+%s"%(x, y)
    print "%s + %s = %s"%(x, y, add_two_ints_client(x, y))

```

make the file executable by $ chmod +x add\_two\_ints\_client.py

![Here we add two ints which are single digit](https://2337796245-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LiHGnU31k3UMwGKWEZa%2F-Lkc5jobdbh-XgErDntH%2F-Lkc6E8NPHyHNy_yWr6V%2FMVIMG_20190719_191844.jpg?alt=media\&token=2e016ed7-9ff7-44e7-9f9d-1b040985cb58)

![We had tried adding 3 digit as well and it worked](https://2337796245-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LiHGnU31k3UMwGKWEZa%2F-Lkc5jobdbh-XgErDntH%2F-Lkc6HKTpchtqmSa4Vcd%2FMVIMG_20190719_192153.jpg?alt=media\&token=23217b76-90ca-4828-9974-15d8b4a63a89)
