Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ client service ros

#include "ros/ros.h"
#include "beginner_tutorials/AddTwoInts.h"
#include <cstdlib>

int main(int argc, char **argv)
{
  ros::init(argc, argv, "add_two_ints_client");
  if (argc != 3)
  {
    ROS_INFO("usage: add_two_ints_client X Y");
    return 1;
  }

  ros::NodeHandle n;
  ros::ServiceClient client = n.serviceClient<beginner_tutorials::AddTwoInts>("add_two_ints");
  beginner_tutorials::AddTwoInts srv;
  srv.request.a = atoll(argv[1]);
  srv.request.b = atoll(argv[2]);
  if (client.call(srv))
  {
    ROS_INFO("Sum: %ld", (long int)srv.response.sum);
  }
  else
  {
    ROS_ERROR("Failed to call service add_two_ints");
    return 1;
  }

  return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: Subarray with given sum in c++ 
Cpp :: access last element of set c++ 
Cpp :: c++ print text 
Cpp :: read string with spaces in c++ 
Cpp :: grep xargs sed 
Cpp :: unpack tuple c++ 
Cpp :: c++ print 
Cpp :: passing custom function in sort cpp 
Cpp :: data types in c++ 
Cpp :: online ide c++ 
Cpp :: add matic mainnet to metamask mobile 
Cpp :: find positive number factorial in C++ 
Cpp :: Exit Button c++ code 
Cpp :: pointers and arrays in c++ 
Cpp :: resharper fold if statement c+ 
Cpp :: min heap stl 
Cpp :: set iterator 
Cpp :: Operators in C / C++ 
Cpp :: c++ custom hash 
Cpp :: modular exponentiation algorithm c++ 
Cpp :: tabeau pseudo dynamique sur c++ 
Cpp :: size of unordered_set 
Cpp :: c++ class methods 
Cpp :: for_each c++ 
Cpp :: phi function 
Cpp :: vector size c++ 
Cpp :: what destructor used for in c++ 
Cpp :: Initialize Vector Iterator with end() function 
Cpp :: HMC 5883 Example to return x y z values 
Cpp :: Code debut C++ 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =