tigertest.cpp
Go to the documentation of this file.
00001 
00006 #include<iostream>
00007 #include<time.h>
00008 #include "ros/ros.h"
00009 #include "appl/appl_request.h"
00010 using namespace std;
00011 int obs[8]={0,1,0,1,0,1,0,0};
00012 int main(int argc,char**argv)
00013 {
00014 
00015         /*ros initializations*/
00016         ros::init(argc,argv,"tiger");
00017         ros::NodeHandle nh;
00018         ros::ServiceClient client = nh.serviceClient<appl::appl_request>("appl_request");
00019         
00020         srand((unsigned)time(0));
00021         int tiger;//0=left 1=right
00022         tiger=rand()%2;
00023         
00024         appl::appl_request srv;
00025         srv.request.cmd=1;      //reset the controller first
00026         client.call(srv);
00027         int action=srv.response.action;
00028         ROS_INFO("%d",action);
00029         
00030         string state_str;
00031         int i;
00032         char rob_vel_str[30];
00033         for(i=0;i<8;i++)
00034         {
00035                 if(obs[i]==0)           //left
00036                 {
00037                         state_str="obs-left";
00038                 }
00039                 else
00040                 {
00041                         state_str="obs-right";
00042                 }
00043                 srv.request.cmd=2;
00044                 srv.request.obs=state_str;
00045                 client.call(srv);
00046         }
00047 }


appl
Author(s): petercai
autogenerated on Tue Jan 7 2014 11:02:29