drive_and_pick.cpp
Go to the documentation of this file.
1 
2 
3 
4 #include <ros/ros.h>
5 #include <std_srvs/Trigger.h>
6 #include <std_srvs/SetBool.h>
7 #include <robotican_msgs_srvs/switch_topic.h>
8 
9 
10 int main(int argc, char **argv) {
11 
12  ros::init(argc, argv, "demo_pick_node");
14 
15  ros::ServiceClient drive_client = n.serviceClient<std_srvs::Trigger>("drive2object_go");
16  ros::ServiceClient pick_client = n.serviceClient<std_srvs::Trigger>("pick_go");
17  ros::ServiceClient sw_client = n.serviceClient<robotican_msgs_srvs::switch_topic>("switch_pcl_topic");
18  // ros::ServiceClient uc_client = n.serviceClient<std_srvs::SetBool>("update_collision_objects");
19 
20  ROS_INFO("Waiting for services...");
21  drive_client.waitForExistence();
22  pick_client.waitForExistence();
23  sw_client.waitForExistence();
24  // uc_client.waitForExistence();
25 
26  robotican_msgs_srvs::switch_topic sw_srv;
27  sw_srv.request.num=1;
28  sw_client.call(sw_srv);
29 
30  ros::Duration(20).sleep();
31  ROS_INFO("Ready!");
32  std_srvs::Trigger drive_srv;
33  if (drive_client.call(drive_srv))
34  {
35  ROS_INFO("drive2object response: %s", drive_srv.response.message.c_str());
36  if (drive_srv.response.success) {
37 
38 
39  sw_srv.request.num=2;
40  sw_client.call(sw_srv);
41 
42 
43 
44  ros::Duration(5).sleep();
45 
46  std_srvs::Trigger pick_srv;
47  if (pick_client.call(pick_srv)) {
48  ROS_INFO("pick response: %s", pick_srv.response.message.c_str());
49  if (pick_srv.response.success) ROS_INFO("Done!");
50  }
51  else ROS_ERROR("Failed to call pick service");
52 
53  }
54  }
55  else ROS_ERROR("Failed to call drive2object service");
56 
58  return 0;
59 }
60 
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
bool sleep() const
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
bool call(MReq &req, MRes &res)
int main(int argc, char **argv)
bool waitForExistence(ros::Duration timeout=ros::Duration(-1))
#define ROS_INFO(...)
ROSCPP_DECL void shutdown()
#define ROS_ERROR(...)


robotican_common
Author(s):
autogenerated on Wed Jan 3 2018 03:48:33