{"id":84,"date":"2017-04-23T21:49:02","date_gmt":"2017-04-24T01:49:02","guid":{"rendered":"http:\/\/commons.trincoll.edu\/trinityrobotics\/?p=84"},"modified":"2017-04-23T21:49:03","modified_gmt":"2017-04-24T01:49:03","slug":"setting-up-ros-client-over-network","status":"publish","type":"post","link":"https:\/\/commons.trincoll.edu\/trinityrobotics\/setting-up-ros-client-over-network\/","title":{"rendered":"Setting up ROS client over network"},"content":{"rendered":"<p>Client code<\/p>\n<pre>#!\/usr\/bin\/env python\r\n\r\nfrom service_tutorial.srv import *\r\nimport rospy\r\nimport sys\r\n\r\ndef concat_things_client(string1, string2, num1, num2):\r\n rospy.wait_for_service('concat_things')\r\n try:\r\n   concat_things = rospy.ServiceProxy('concat_things',   ConcatThings)\r\n   resp = concat_things(string1, string2, num1, num2)\r\n   return resp.result\r\n except rospy.ServiceException, e:\r\n   print \"Service call failed: %s\" % e\r\n\r\nif __name__ == \"__main__\":\r\n if len(sys.argv) == 5:\r\n   string1 = sys.argv[1]\r\n   string2 = sys.argv[2]\r\n   num1 = int(sys.argv[3])\r\n   num2 = int(sys.argv[4])\r\n else:\r\n   print \"Please provide all args\"\r\n   sys.exit(1)\r\n   print \"Requesting service\"\r\n   print \"%s\" % concat_things_client(string1, string2, num1, num2)<\/pre>\n<p>\/etc\/hosts on the client<\/p>\n<pre>127.0.0.1 localhost comp1\r\n127.0.1.1 guest\r\n10.99.0.12 server\r\n\r\n# The following lines are desirable for IPv6 capable hosts\r\n::1 localhost ip6-localhost ip6-loopback\r\nff02::1 ip6-allnodes\r\nff02::2 ip6-allrouters\r\n\r\n127.0.0.1 vultr.guest\r\n::1 vultr.guest<\/pre>\n<p>\/etc\/hosts on the server<\/p>\n<pre>127.0.0.1 localhost server\r\n127.0.1.1 guest\r\n10.99.0.10 comp1\r\n10.99.0.11 comp2\r\n\r\n# The following lines are desirable for IPv6 capable hosts\r\n::1 localhost ip6-localhost ip6-loopback\r\nff02::1 ip6-allnodes\r\nff02::2 ip6-allrouters<\/pre>\n<pre>#!\/usr\/bin\/env python\r\n\r\nfrom service_tutorial.srv import *\r\nimport rospy\r\nimport sys<\/pre>\n<p>Commands to debug<\/p>\n<p><strong>Are all the network ports necessary to communicate <\/strong>open<strong>?<\/strong><\/p>\n<p>On server &#8211;\u00a0<code>netcat -l 1234<\/code> : echo all things received from port 1234<\/p>\n<p>On client &#8211;\u00a0<code>netcat server 1234<\/code> : send input to server through port 1234<\/p>\n<p><strong>Can I connect to ROS core through <\/strong>network<strong>?<\/strong><\/p>\n<p>Try running ROS commands, like rostopic<\/p>\n<p><strong>Am I even connected to the server?<\/strong><\/p>\n<p><code><strong>ping server<\/strong><\/code><\/p>\n<p><strong>Is the service available?<\/strong><\/p>\n<p><code>rossrv list<\/code><\/p>\n<p><strong>Is my environmental variables set to what I think they should be?<\/strong><\/p>\n<p><code>echo $ROS_MASTER_URI<\/code> or\u00a0<code>${Environmental variable name}<\/code><\/p>\n<p><strong>What is my IP?<\/strong><\/p>\n<p><code>ifconfig<\/code> and check under wlan0 and wlan1.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Client code #!\/usr\/bin\/env python from service_tutorial.srv import * import rospy import sys def concat_things_client(string1, string2, num1, num2): rospy.wait_for_service(&#8216;concat_things&#8217;) try: concat_things = rospy.ServiceProxy(&#8216;concat_things&#8217;, ConcatThings) resp = concat_things(string1, string2, num1, num2) return resp.result except rospy.ServiceException, e: print &#8220;Service call failed: %s&#8221; % e if __name__ == &#8220;__main__&#8221;: if len(sys.argv) == 5: string1 = sys.argv[1] string2 = sys.argv[2] &hellip; <a href=\"https:\/\/commons.trincoll.edu\/trinityrobotics\/setting-up-ros-client-over-network\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Setting up ROS client over network&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1933,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/commons.trincoll.edu\/trinityrobotics\/wp-json\/wp\/v2\/posts\/84"}],"collection":[{"href":"https:\/\/commons.trincoll.edu\/trinityrobotics\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/commons.trincoll.edu\/trinityrobotics\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/commons.trincoll.edu\/trinityrobotics\/wp-json\/wp\/v2\/users\/1933"}],"replies":[{"embeddable":true,"href":"https:\/\/commons.trincoll.edu\/trinityrobotics\/wp-json\/wp\/v2\/comments?post=84"}],"version-history":[{"count":2,"href":"https:\/\/commons.trincoll.edu\/trinityrobotics\/wp-json\/wp\/v2\/posts\/84\/revisions"}],"predecessor-version":[{"id":87,"href":"https:\/\/commons.trincoll.edu\/trinityrobotics\/wp-json\/wp\/v2\/posts\/84\/revisions\/87"}],"wp:attachment":[{"href":"https:\/\/commons.trincoll.edu\/trinityrobotics\/wp-json\/wp\/v2\/media?parent=84"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/commons.trincoll.edu\/trinityrobotics\/wp-json\/wp\/v2\/categories?post=84"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/commons.trincoll.edu\/trinityrobotics\/wp-json\/wp\/v2\/tags?post=84"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}