Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ server service ros

#include "ros/ros.h"
#include "beginner_tutorials/AddTwoInts.h"

bool add(beginner_tutorials::AddTwoInts::Request  &req,
         beginner_tutorials::AddTwoInts::Response &res)
{
  res.sum = req.a + req.b;
  ROS_INFO("request: x=%ld, y=%ld", (long int)req.a, (long int)req.b);
  ROS_INFO("sending back response: [%ld]", (long int)res.sum);
  return true;
}

int main(int argc, char **argv)
{
  ros::init(argc, argv, "add_two_ints_server");
  ros::NodeHandle n;

  ros::ServiceServer service = n.advertiseService("add_two_ints", add);
  ROS_INFO("Ready to add two ints.");
  ros::spin();

  return 0;
}
Comment

c++ server service ros

#include "ros/ros.h"
#include "beginner_tutorials/AddTwoInts.h"

bool add(beginner_tutorials::AddTwoInts::Request  &req,
         beginner_tutorials::AddTwoInts::Response &res)
{
  res.sum = req.a + req.b;
  ROS_INFO("request: x=%ld, y=%ld", (long int)req.a, (long int)req.b);
  ROS_INFO("sending back response: [%ld]", (long int)res.sum);
  return true;
}

int main(int argc, char **argv)
{
  ros::init(argc, argv, "add_two_ints_server");
  ros::NodeHandle n;

  ros::ServiceServer service = n.advertiseService("add_two_ints", add);
  ROS_INFO("Ready to add two ints.");
  ros::spin();

  return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ coding questions for interview 
Cpp :: Call db.close() on Button_Click (QT/C++) 
Cpp :: how to make negative number positive in c++ 
Cpp :: compile c++ MPI Program 
Cpp :: template in cpp 
Cpp :: how to analyse a poem 
Cpp :: c++ max function 
Cpp :: Casino Number Guessing Game - C++ 
Cpp :: print number with leading zeros 
Cpp :: c++ shift array to the right 
Cpp :: Basic stack implementation in c++ 
Cpp :: program to find third smallest number c++ 
Cpp :: split string by delimiter cpp 
Cpp :: how to make sound in c++ 
Cpp :: c++ handling 
Cpp :: #include using namespace std; int main() { double leashamt,collaramt,foodamt,totamt; cout<<"Enter the amount spent for a leash : "; 
C :: _CRT_SECURE_NO_WARNINGS 
C :: Write a C program to print all unique elements in the array. 
C :: c colour 
C :: zizag c 
C :: grep find and replace 
C :: random number c 
C :: for loop c 
C :: how to mutex lock in c 
C :: sdl2 c programming 
C :: scanf string in c 
C :: vbnet create and write on file 
C :: merge sort for strings in c 
C :: arduino wifi client 
C :: compare c strings 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =