drive_and_pick.cpp
Go to the documentation of this file.
00001 
00002 
00003 
00004 #include <ros/ros.h>
00005 #include <std_srvs/Trigger.h>
00006 #include <std_srvs/SetBool.h>
00007 #include <robotican_common/switch_topic.h>
00008 
00009 
00010 int main(int argc, char **argv) {
00011 
00012     ros::init(argc, argv, "demo_pick_node");
00013     ros::NodeHandle n;
00014 
00015     ros::ServiceClient drive_client = n.serviceClient<std_srvs::Trigger>("drive2object_go");
00016     ros::ServiceClient pick_client = n.serviceClient<std_srvs::Trigger>("pick_go");
00017     ros::ServiceClient sw_client = n.serviceClient<robotican_common::switch_topic>("switch_pcl_topic");
00018    // ros::ServiceClient uc_client = n.serviceClient<std_srvs::SetBool>("update_collision_objects");
00019 
00020      ROS_INFO("Waiting for services...");
00021     drive_client.waitForExistence();
00022     pick_client.waitForExistence();
00023     sw_client.waitForExistence();
00024   //  uc_client.waitForExistence();
00025 
00026     robotican_common::switch_topic sw_srv;
00027     sw_srv.request.num=1;
00028     sw_client.call(sw_srv);
00029 
00030     ros::Duration(5).sleep();
00031      ROS_INFO("Ready!");
00032     std_srvs::Trigger drive_srv;
00033     if (drive_client.call(drive_srv))
00034     {
00035         ROS_INFO("drive2object response: %s", drive_srv.response.message.c_str());
00036         if (drive_srv.response.success) {
00037 
00038 
00039             sw_srv.request.num=2;
00040             sw_client.call(sw_srv);
00041 
00042 
00043 
00044             ros::Duration(5).sleep();
00045 
00046             std_srvs::Trigger pick_srv;
00047             if (pick_client.call(pick_srv)) {
00048                 ROS_INFO("pick response: %s", pick_srv.response.message.c_str());
00049                 if (pick_srv.response.success)  ROS_INFO("Done!");
00050             }
00051             else ROS_ERROR("Failed to call pick service");
00052 
00053         }
00054     }
00055     else ROS_ERROR("Failed to call drive2object service");
00056 
00057 ros::shutdown();
00058     return 0;
00059 }
00060 


robotican_demos
Author(s):
autogenerated on Fri Oct 27 2017 03:02:45