node.cpp
Go to the documentation of this file.
00001 #include <string>
00002 #include <iostream>
00003 #include <list>
00004 
00005 #include <ros/ros.h>
00006 #include <designator_integration_msgs/Designator.h>
00007 #include <designator_integration_msgs/DesignatorCommunication.h>
00008 
00009 #include <designators/CDesignator.h>
00010 
00011 using namespace std;
00012 
00013 
00014 ros::Publisher pub;
00015 
00016 
00017 bool desigCommCB(designator_integration_msgs::DesignatorCommunication::Request &req,
00018                  designator_integration_msgs::DesignatorCommunication::Response &res) {
00019   CDesignator *desigRequest = new CDesignator(req.request.designator);
00020   CDesignator *desigResponse = new CDesignator();
00021   desigResponse->setType(OBJECT);
00022   desigResponse->setValue("name", desigRequest->stringValue("name"));
00023   desigResponse->setValue("height", 0.2);
00024   
00025   geometry_msgs::PoseStamped psTest;
00026   psTest.pose.position.x = 0.2;
00027   
00028   desigResponse->setValue("pose", psTest);
00029   
00030   res.response.designators.push_back(desigResponse->serializeToMessage());
00031   
00032   return true;
00033 }
00034 
00035 int main(int argc, char **argv) {
00036   ros::init(argc, argv, "desig_int_test");
00037   ros::NodeHandle nhPrivate("~");
00038   ros::NodeHandle nh;
00039   ros::ServiceServer srvDesigComm = nhPrivate.advertiseService("/designator_comm",
00040                                                                desigCommCB);
00041   
00042   string strTopic = "/uima/trigger";
00043   pub = nh.advertise<designator_integration_msgs::Designator>(strTopic, 1);
00044   
00045   CDesignator *desigTest = new CDesignator();
00046   desigTest->setType(ACTION);
00047   
00048   desigTest->setValue("shape", "box");
00049   desigTest->setValue("color", "red");
00050   
00051   CKeyValuePair* ckvpTest1 = desigTest->addChild("GRASP-POSE", true);
00052   ckvpTest1->setValue("test-content 1");
00053 
00054   CKeyValuePair* ckvpTest2 = desigTest->addChild("GRASP-POSE", true);
00055   ckvpTest2->setValue("test-content 2");
00056   
00057   bool bSent = false;
00058   
00059   while(ros::ok()) {
00060     ros::spinOnce();
00061     
00062     if(!bSent) {
00063       pub.publish(desigTest->serializeToMessage());
00064       
00065       cout << "Sent this designator to topic '" << strTopic << "':" << endl;
00066       desigTest->printDesignator();
00067       bSent = true;
00068     }
00069     
00070     ros::Duration(0.1).sleep();
00071   }
00072   
00073   delete desigTest;
00074   
00075   return 0;
00076 }


designator_integration
Author(s): Jan Winkler
autogenerated on Sun Oct 5 2014 23:26:09