mvsim-service-caller-example.cpp
Go to the documentation of this file.
1 
2 #include <mrpt/core/exceptions.h>
3 #include <mvsim/Comms/Client.h>
4 #include <iostream>
5 
6 // mvsim_msgs:
7 #include <mvsim/mvsim-msgs/GenericAnswer.pb.h>
8 #include <mvsim/mvsim-msgs/SrvSetPose.pb.h>
9 #include <mvsim/mvsim-msgs/SrvSetPoseTwist.pb.h>
10 
11 int main(int argc, char** argv)
12 {
13  try
14  {
16  client.connect();
17 
18  for (int i = 0; i < 20; i++)
19  {
20  // Request:
21  mvsim_msgs::SrvSetPose req;
22 
23  req.set_objectid("r1");
24  req.mutable_pose()->set_x(i * 0.50);
25  req.mutable_pose()->set_y(0.0);
26  req.mutable_pose()->set_z(0.0);
27  req.mutable_pose()->set_yaw(0.0);
28  req.mutable_pose()->set_pitch(0.0);
29  req.mutable_pose()->set_roll(0.0);
30 
31  mvsim_msgs::GenericAnswer ans;
32  client.callService("set_pose", req, ans);
33 
34  std::cout << "called service. Input:\n"
35  << req.DebugString() << "Response:\n"
36  << ans.DebugString() << std::endl;
37 
38  std::this_thread::sleep_for(std::chrono::milliseconds(1000));
39  }
40 
41  return 0;
42  }
43  catch (const std::exception& e)
44  {
45  std::cerr << mrpt::exception_to_str(e);
46  return 1;
47  }
48 }
int main(int argc, char **argv)
void callService(const std::string &serviceName, const INPUT_MSG_T &input, OUTPUT_MSG_T &output)
Definition: Client.h:192


mvsim
Author(s):
autogenerated on Fri May 7 2021 03:05:51