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


mvsim
Author(s):
autogenerated on Tue Jul 4 2023 03:08:21