Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <ros/ros.h>
00031 #include <ros/node_handle.h>
00032
00033
00034
00035 #include <string.h>
00036 #include <vision_msgs/cop_answer.h>
00037
00038 using namespace std;
00039
00040 class SyntheticPercepts {
00041
00042 public:
00043 double rate_;
00044 int object_id_;
00045 std::vector<std::string> objects_;
00046 std::string missing_object_;
00047 SyntheticPercepts(ros::NodeHandle &n) :
00048 n_(n)
00049 {
00050 tabletop_pub_ = n_.advertise<vision_msgs::cop_answer>("tabletop_percepts",10);
00051 n_.param ("object_id", object_id_, 700000);
00052 n_.param("missing_object", missing_object_, string(""));
00053 objects_.push_back("BreakfastCereal"), objects_.push_back("CowsMilk-Product"), objects_.push_back("Bowl-Eating");
00054 for (unsigned int i = 0; i < objects_.size(); i++)
00055 {
00056 if (objects_[i] == missing_object_)
00057 {
00058 objects_.erase (objects_.begin()+i);
00059 }
00060 }
00061 }
00062
00063
00064 ~SyntheticPercepts()
00065 {
00066 }
00067
00069
00070 bool spin ()
00071 {
00072 ros::Rate loop_rate(1);
00073 vision_msgs::cop_answer msg;
00074 vision_msgs::cop_descriptor cop_descriptor;
00075 vision_msgs::aposteriori_position aposteriori_position;
00076 vision_msgs::cop_descriptor cop_descriptor2;
00077 vision_msgs::aposteriori_position aposteriori_position2;
00078 msg.found_poses.push_back(aposteriori_position);
00079 msg.found_poses.push_back(aposteriori_position2);
00080
00081 msg.found_poses[0].models.push_back(cop_descriptor);
00082 msg.found_poses[1].models.push_back(cop_descriptor2);
00083
00084 msg.found_poses[0].objectId = 0;
00085 msg.found_poses[1].objectId = 1;
00086
00087 while (n_.ok ())
00088 {
00089 ROS_INFO ("Publishing data on topic %s.", n_.resolveName ("tabletop_percepts").c_str ());
00090 msg.found_poses[0].models[0].type = "ODUFinder";
00091
00092 msg.found_poses[0].models[0].sem_class = objects_[0];
00093 msg.found_poses[0].models[0].object_id = ++object_id_;
00094 msg.found_poses[0].position = 0;
00095
00096 msg.found_poses[1].models[0].type = "ODUFinder";
00097
00098 msg.found_poses[1].models[0].sem_class = objects_[1];
00099 msg.found_poses[1].models[0].object_id = ++object_id_;
00100 msg.found_poses[1].position = 0;
00101
00102 tabletop_pub_.publish(msg);
00103 loop_rate.sleep();
00104 ros::spinOnce ();
00105 }
00106 return (true);
00107 }
00108
00109 protected:
00110
00111 ros::NodeHandle n_;
00112 ros::Publisher tabletop_pub_;
00113
00114 };
00115
00116 int main(int argc, char** argv)
00117 {
00118 ros::init(argc, argv, "synthetic_percepts");
00119 ros::NodeHandle n("~");
00120 SyntheticPercepts sp(n);
00121 sp.spin();
00122 return 0;
00123 }