00001 /************************************************************************************************** 00002 Software License Agreement (BSD License) 00003 00004 Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt 00005 All rights reserved. 00006 00007 Redistribution and use in source and binary forms, with or without modification, are permitted 00008 provided that the following conditions are met: 00009 00010 *Redistributions of source code must retain the above copyright notice, this list of 00011 conditions and the following disclaimer. 00012 *Redistributions in binary form must reproduce the above copyright notice, this list of 00013 conditions and the following disclaimer in the documentation and/or other materials provided 00014 with the distribution. 00015 *Neither the name of the University of Aveiro nor the names of its contributors may be used to 00016 endorse or promote products derived from this software without specific prior written permission. 00017 00018 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 00019 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 00020 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 00021 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00022 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00023 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 00024 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00025 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 ***************************************************************************************************/ 00033 #include <ros/ros.h> 00034 #include <visualization_msgs/Marker.h> 00035 00036 #include "wrapper_collada.h" 00037 #define PFLN {printf("DEBUG PRINT FILE %s LINE %d\n",__FILE__,__LINE__);} 00038 00039 00040 00041 00042 int main(int argc, char* argv[]) { 00043 00044 00045 //daeElement* bindVertexInput = instanceMaterial->add("bind_vertex_input"); 00046 //bindVertexInput->setAttribute("semantic", "uv0"); 00047 //bindVertexInput->setAttribute("input_semantic", "TEXCOORD"); 00048 //bindVertexInput->setAttribute("input_set", "0"); 00049 00050 00051 00052 //MAIN CYCLE 00053 ros::init(argc, argv, "point_cloud_publisher"); // Initialize ROS coms 00054 ros::NodeHandle n; //The node handle 00055 ros::Rate r(0.1); 00056 visualization_msgs::Marker marker; 00057 ros::Publisher marker_pub = n.advertise<visualization_msgs::Marker>("/wrapper_collada", 1); 00058 marker.id = 1; 00059 marker.header.stamp = ros::Time::now(); 00060 marker.type = visualization_msgs::Marker::MESH_RESOURCE; 00061 marker.action = visualization_msgs::Marker::ADD; 00062 marker.ns = "ns"; 00063 //marker.mesh_resource = "package://wrapper_collada/bin/polygons1.dae"; 00064 marker.mesh_use_embedded_materials = 1; 00065 marker.header.frame_id = "/atc/vehicle/ground"; 00066 //marker.scale.x = 2.54/100; 00067 //marker.scale.y = 2.54/100; 00068 //marker.scale.z = 2.54/100; 00069 marker.scale.x = 1; 00070 marker.scale.y = 1; 00071 marker.scale.z = 1; 00072 marker.color.r = 0.2; 00073 marker.color.g = 0.3; 00074 marker.color.b = 0.4; 00075 marker.color.a = 1; 00076 int a=0; 00077 while(n.ok()) 00078 { 00079 a++; 00080 //char str[1024]; 00081 //sprintf(str, "mesh/polygons%d.dae",a); 00082 //wrapper_collada wc(str); 00083 00086 //std::string polygon_name("plg0");//the polygon name 00087 //pcl::PointCloud<pcl::PointXYZ>::Ptr cloud; //the point cloud with the polygon vertices list 00088 //cloud = pcl::PointCloud<pcl::PointXYZ>::Ptr(new pcl::PointCloud<pcl::PointXYZ>); 00089 //cloud->points.push_back(pcl::PointXYZ(-1,-1, 0)); 00090 //cloud->points.push_back(pcl::PointXYZ(1,-1, 0)); 00091 //cloud->points.push_back(pcl::PointXYZ(1,1, 0)); 00092 //cloud->points.push_back(pcl::PointXYZ(-1,1, 0)); 00093 00094 //pcl::PointCloud<pcl::PointXYZ>::Ptr normal; //the point cloud with the polygon vertices list 00095 //normal = pcl::PointCloud<pcl::PointXYZ>::Ptr(new pcl::PointCloud<pcl::PointXYZ>); 00096 //normal->points.push_back(pcl::PointXYZ(0, 0, 1)); //the normal vector to the polygon 00097 00098 00099 //wc.add_polygon_fixed_color(polygon_name, cloud, normal, 1,0,0,1); 00100 00101 //wc.write_file(); 00102 00103 char str1[1024]; 00104 //sprintf(str1, "package://wrapper_collada/bin/%s",str); 00105 //sprintf(str1, "package://wrapper_collada/models/car1.dae"); 00106 sprintf(str1, "package://wrapper_collada/models/decisive_woman.obj"); 00107 marker.mesh_resource = str1; 00108 marker.header.stamp = ros::Time::now(); 00109 marker_pub.publish(marker); 00110 00111 ros::Duration(0.4).sleep(); 00112 ros::spinOnce(); 00113 00114 } 00115 00116 return 0; 00117 }