ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

ROS beginner tutorials:Writing Simple Service and Client (C++) - need explanation [closed]

asked 2013-04-17 22:15:53 -0500

Maheshwar Venkat gravatar image

updated 2013-04-17 22:18:23 -0500

I'm following the ROS beginner tutorials and currently doing 14.Writing Simple Service and Client (C++) (http://www.ros.org/wiki/ROS/Tutorials/WritingServiceClient%28c%2B%2B%29)

In Section 1.2 Writing the Client Node, the following lines of code have not been explained:

   8   if (argc != 3)
   9   {
  10     ROS_INFO("usage: add_two_ints_client X Y");
  11     return 1;
  12   }

Can anyone tell me why this comparison is made? Thanks in advance.

P.S.I'm using ROS groovy on Ubuntu 12.10. Following catkin tutorials.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Arkapravo
close date 2014-06-28 14:31:52.407421

1 Answer

Sort by ยป oldest newest most voted
3

answered 2013-04-17 22:38:30 -0500

prasanna.kumar gravatar image

updated 2013-04-17 22:41:35 -0500

Hi,

argc refers to total number of arguments that can be passed to a node. In your case, when you run rosrun beginner_tutorials add_two_ints_client 5 6, you enter three arguments add_two_ints_client(argv[0]),5(argv[1]) and 6(argv[2]). For the node add_two_ints to function properly second and third arguments, the integers, are required along with node name. The comparison, if (argc != 3) is made to check if the required number of arguments needed to run the client are obtained. If you use rosrun beginner_tutorials add_two_ints_client 5 (argc = 2)or rosrun beginner_tutorials add_two_ints_client 5 6 7 ((argc = 4), usage: add_two_ints_client X Y will appear.

edit flag offensive delete link more

Comments

understood clearly. thank you.!

Maheshwar Venkat gravatar image Maheshwar Venkat  ( 2013-04-17 22:55:53 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2013-04-17 22:15:53 -0500

Seen: 947 times

Last updated: Apr 17 '13